1 package org.apidesign.apifest08.test;
3 import junit.framework.TestCase;
4 import org.apidesign.apifest08.currency.Convertor;
6 /** Finish the Convertor API, and then write bodies of methods inside
7 * of this class to match the given tasks.
9 public class Task1Test extends TestCase {
11 // your code shall run without any permissions
14 public Task1Test(String testName) {
19 protected void setUp() throws Exception {
23 protected void tearDown() throws Exception {
26 /** Create convertor that understands two currencies, CZK and
27 * USD. Make 1 USD == 17 CZK.
29 * @return prepared convertor ready for converting USD to CZK and CZK to USD
31 public static Convertor createCZKtoUSD() {
35 /** Create convertor that understands two currencies, CZK and
36 * SKK. Make 100 SKK == 80 CZK.
38 * @return prepared convertor ready for converting SKK to CZK and CZK to SKK
40 public static Convertor createSKKtoCZK() {
44 /** Use the convertor from <code>createCZKtoUSD</code> method and do few conversions
47 public void testCurrencyCZKUSD() throws Exception {
48 Convertor c = createCZKtoUSD();
49 // convert $5 to CZK using c:
50 // assertEquals("Result is 85 CZK");
53 // assertEquals("Result is 136 CZK");
55 // convert 1003CZK to USD
56 // assertEquals("Result is 59 USD");
59 /** Use the convertor from <code>createSKKtoCZK</code> method and do few conversions
62 public void testCurrencySKKCZK() throws Exception {
63 Convertor c = createSKKtoCZK();
64 // convert 16CZK using c:
65 // assertEquals("Result is 20 SKK");
67 // convert 500SKK to CZK
68 // assertEquals("Result is 400 CZK");