1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/taskx/psmid/against-solution06/test/apifest/CurrencyTest.java Sat Oct 25 20:53:00 2008 +0200
1.3 @@ -0,0 +1,34 @@
1.4 +package apifest;
1.5 +
1.6 +import java.math.BigDecimal;
1.7 +import java.util.Currency;
1.8 +import junit.framework.TestCase;
1.9 +import org.apidesign.apifest08.currency.Amount;
1.10 +import org.apidesign.apifest08.currency.Convertor;
1.11 +import org.apidesign.apifest08.currency.UnsupportedConversionException;
1.12 +//import static org.apidesign.apifest08.test.Currencies.CZK;
1.13 +//import static org.apidesign.apifest08.test.Currencies.SKK;
1.14 +//import static org.apidesign.apifest08.test.Currencies.USD;
1.15 +
1.16 +/** Write a test that works with version from task A and fails with version B.
1.17 + */
1.18 +public class CurrencyTest extends TestCase {
1.19 + public CurrencyTest(String n) {
1.20 + super(n);
1.21 + }
1.22 +
1.23 + public void testCompatibility() throws Exception {
1.24 + Currency CZK = Currency.getInstance("CZK");
1.25 + Currency USD = Currency.getInstance("USD");
1.26 + Currency SKK = Currency.getInstance("SKK");
1.27 +
1.28 +
1.29 + Convertor c = new Convertor(new BigDecimal(17), USD, CZK);
1.30 + try {
1.31 + Amount a = c.convert(new BigDecimal("10"), USD, SKK);
1.32 + //fail();
1.33 + } catch (UnsupportedConversionException e) {
1.34 + assertEquals("Conversion from the currency USD to the currency SKK or vice versa in not supported.", e.getMessage());
1.35 + }
1.36 + }
1.37 +}