package code.donbonifacio.saft;

import junit.framework.TestCase;

/**
 * Tests for the Result class
 */
public class ResultTest extends TestCase {

    /**
     * Tests the Result.success singleton
     */
    public void testSuccessSingleton() {
        Result r1 = Result.success();
        assertTrue(r1.isSucceeded());
        assertFalse(r1.isFailed());

        Result r2 = Result.success();
        assertTrue(r2.isSucceeded());
        assertFalse(r2.isFailed());

        assertTrue(r1 == r2);
    }

    /**
     * Tests a failed result via exception
     */
    public void testResultException() {
        Exception ex = new RuntimeException();
        Result result = Result.exception(ex);
        assertFalse(result.isSucceeded());
        assertTrue(result.isException());
    }
}

@@ -60,16 +60,42 @@
 tCase;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * T
@@ -812,11 +812,717 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Test toString generation%0A     */%0A    public void testToString() %7B%0A        Result r1 = Result.failure(%22Test1%22);%0A        Result r2 = Result.failure(%22Test2%22);%0A        Result r3 = Result.fromResults(Arrays.asList(r1, r2));%0A%0A        assertEquals(%22Result%7Bsucceeded=false, reason='From list of results', results=%5BResult%7Bsucceeded=false, reason='Test1'%7D, Result%7Bsucceeded=false, reason='Test2'%7D, %5D%7D%22, r3.toString());%0A    %7D%0A%0A    /**%0A     * If fromResults gets a collection with only one result, return%0A     * that result%0A     */%0A    public void testFromResultsAsOne() %7B%0A        Result r1 = Result.success();%0A        Result r2 = Result.fromResults(r1.asList());%0A%0A        assertTrue(r1 == r2);%0A%0A    %7D
 %0A%7D%0A

Add more tests to Result