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