author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Sat, 20 Sep 2008 18:26:55 +0200 | |
changeset 1 | 676b4c07fa0a |
parent 0 | e0003d2fb0c2 |
child 3 | 81bafaac7336 |
permissions | -rw-r--r-- |
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@1 | 7 |
* of this class to match the given tasks. |
jtulach@0 | 8 |
*/ |
jtulach@0 | 9 |
public class Task1Test extends TestCase { |
jtulach@0 | 10 |
static { |
jtulach@0 | 11 |
// your code shall run without any permissions |
jtulach@0 | 12 |
} |
jtulach@0 | 13 |
|
jtulach@0 | 14 |
public Task1Test(String testName) { |
jtulach@0 | 15 |
super(testName); |
jtulach@0 | 16 |
} |
jtulach@0 | 17 |
|
jtulach@0 | 18 |
@Override |
jtulach@0 | 19 |
protected void setUp() throws Exception { |
jtulach@0 | 20 |
} |
jtulach@0 | 21 |
|
jtulach@0 | 22 |
@Override |
jtulach@0 | 23 |
protected void tearDown() throws Exception { |
jtulach@0 | 24 |
} |
jaroslav@1 | 25 |
|
jaroslav@1 | 26 |
/** Create convertor that understands two currencies, CZK and |
jaroslav@1 | 27 |
* USD. Make 1 USD == 17 CZK. |
jaroslav@1 | 28 |
* |
jaroslav@1 | 29 |
* @return prepared convertor ready for converting USD to CZK and CZK to USD |
jaroslav@1 | 30 |
*/ |
jaroslav@1 | 31 |
public static Convertor createCZKtoUSD() { |
jaroslav@1 | 32 |
return null; |
jaroslav@1 | 33 |
} |
jaroslav@1 | 34 |
|
jaroslav@1 | 35 |
/** Create convertor that understands two currencies, CZK and |
jaroslav@1 | 36 |
* SKK. Make 100 SKK == 80 CZK. |
jaroslav@1 | 37 |
* |
jaroslav@1 | 38 |
* @return prepared convertor ready for converting SKK to CZK and CZK to SKK |
jaroslav@1 | 39 |
*/ |
jaroslav@1 | 40 |
public static Convertor createSKKtoCZK() { |
jaroslav@1 | 41 |
return null; |
jaroslav@1 | 42 |
} |
jtulach@0 | 43 |
|
jaroslav@1 | 44 |
/** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions |
jaroslav@1 | 45 |
* with it. |
jaroslav@1 | 46 |
*/ |
jtulach@0 | 47 |
public void testCurrencyCZKUSD() throws Exception { |
jaroslav@1 | 48 |
Convertor c = createCZKtoUSD(); |
jaroslav@1 | 49 |
// convert $5 to CZK using c: |
jaroslav@1 | 50 |
// assertEquals("Result is 85 CZK"); |
jaroslav@1 | 51 |
|
jaroslav@1 | 52 |
// convert $8 to CZK |
jaroslav@1 | 53 |
// assertEquals("Result is 136 CZK"); |
jaroslav@1 | 54 |
|
jaroslav@1 | 55 |
// convert 1003CZK to USD |
jaroslav@1 | 56 |
// assertEquals("Result is 59 USD"); |
jaroslav@1 | 57 |
} |
jaroslav@1 | 58 |
|
jaroslav@1 | 59 |
/** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions |
jaroslav@1 | 60 |
* with it. |
jaroslav@1 | 61 |
*/ |
jaroslav@1 | 62 |
public void testCurrencySKKCZK() throws Exception { |
jaroslav@1 | 63 |
Convertor c = createSKKtoCZK(); |
jaroslav@1 | 64 |
// convert 16CZK using c: |
jaroslav@1 | 65 |
// assertEquals("Result is 20 SKK"); |
jaroslav@1 | 66 |
|
jaroslav@1 | 67 |
// convert 500SKK to CZK |
jaroslav@1 | 68 |
// assertEquals("Result is 400 CZK"); |
jtulach@0 | 69 |
} |
jtulach@0 | 70 |
} |
jaroslav@1 | 71 |