currency/test/org/apidesign/apifest08/test/Task1Test.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 22 Sep 2008 18:19:25 +0200
changeset 3 81bafaac7336
parent 1 676b4c07fa0a
child 12 b6c21003ddc9
permissions -rw-r--r--
Explaining that the API and its impl shall be kept in one package.
Also stressing that the Convertor shall be "pre-made" in the API, no subclassing needed to create its implementation.
jtulach@0
     1
package org.apidesign.apifest08.test;
jtulach@0
     2
jtulach@0
     3
import junit.framework.TestCase;
jaroslav@1
     4
import org.apidesign.apifest08.currency.Convertor;
jtulach@0
     5
jaroslav@1
     6
/** Finish the Convertor API, and then write bodies of methods inside
jaroslav@3
     7
 * of this class to match the given tasks. To fullfil your task, use the
jaroslav@3
     8
 * API define in the <code>org.apidesign.apifest08.currency</code> package.
jaroslav@3
     9
 * Do not you reflection, or other hacks as your code
jaroslav@3
    10
 * shall run without any runtime permissions.
jtulach@0
    11
 */
jtulach@0
    12
public class Task1Test extends TestCase {
jtulach@0
    13
    public Task1Test(String testName) {
jtulach@0
    14
        super(testName);
jtulach@0
    15
    }
jtulach@0
    16
jtulach@0
    17
    @Override
jtulach@0
    18
    protected void setUp() throws Exception {
jtulach@0
    19
    }
jtulach@0
    20
jtulach@0
    21
    @Override
jtulach@0
    22
    protected void tearDown() throws Exception {
jtulach@0
    23
    }
jaroslav@1
    24
jaroslav@1
    25
    /** Create convertor that understands two currencies, CZK and
jaroslav@1
    26
     *  USD. Make 1 USD == 17 CZK.
jaroslav@1
    27
     *
jaroslav@3
    28
     * Creation of the convertor shall not require subclassing of any class
jaroslav@3
    29
     * or interface on the client side.
jaroslav@3
    30
     *
jaroslav@1
    31
     * @return prepared convertor ready for converting USD to CZK and CZK to USD
jaroslav@1
    32
     */
jaroslav@1
    33
    public static Convertor createCZKtoUSD() {
jaroslav@1
    34
        return null;
jaroslav@1
    35
    }
jaroslav@1
    36
jaroslav@1
    37
    /** Create convertor that understands two currencies, CZK and
jaroslav@1
    38
     *  SKK. Make 100 SKK == 80 CZK.
jaroslav@1
    39
     *
jaroslav@3
    40
     * Creation of the convertor shall not require subclassing of any class
jaroslav@3
    41
     * or interface on the client side.
jaroslav@3
    42
     * 
jaroslav@1
    43
     * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
jaroslav@1
    44
     */
jaroslav@1
    45
    public static Convertor createSKKtoCZK() {
jaroslav@1
    46
        return null;
jaroslav@1
    47
    }
jtulach@0
    48
    
jaroslav@1
    49
    /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
jaroslav@1
    50
     * with it.
jaroslav@1
    51
     */
jtulach@0
    52
    public void testCurrencyCZKUSD() throws Exception {
jaroslav@1
    53
        Convertor c = createCZKtoUSD();
jaroslav@1
    54
        // convert $5 to CZK using c:
jaroslav@1
    55
        // assertEquals("Result is 85 CZK");
jaroslav@1
    56
jaroslav@1
    57
        // convert $8 to CZK
jaroslav@1
    58
        // assertEquals("Result is 136 CZK");
jaroslav@1
    59
jaroslav@1
    60
        // convert 1003CZK to USD
jaroslav@1
    61
        // assertEquals("Result is 59 USD");
jaroslav@1
    62
    }
jaroslav@1
    63
jaroslav@1
    64
    /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
jaroslav@1
    65
     * with it.
jaroslav@1
    66
     */
jaroslav@1
    67
    public void testCurrencySKKCZK() throws Exception {
jaroslav@1
    68
        Convertor c = createSKKtoCZK();
jaroslav@1
    69
        // convert 16CZK using c:
jaroslav@1
    70
        // assertEquals("Result is 20 SKK");
jaroslav@1
    71
jaroslav@1
    72
        // convert 500SKK to CZK
jaroslav@1
    73
        // assertEquals("Result is 400 CZK");
jtulach@0
    74
    }
jtulach@0
    75
}
jaroslav@1
    76