diff -r 000000000000 -r 621462e58e22 taskx/ked/against-solution04/test/apifest/CurrencyTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/taskx/ked/against-solution04/test/apifest/CurrencyTest.java Sat Oct 25 20:30:54 2008 +0200 @@ -0,0 +1,33 @@ +package apifest; + +import java.math.BigDecimal; +import java.util.Currency; +import junit.framework.TestCase; +import org.apidesign.apifest08.currency.Convertor; +import org.apidesign.apifest08.currency.InvalidConversionException; + + +/** Write a test that works with version from task A and fails with version B. + */ +public class CurrencyTest extends TestCase { + public CurrencyTest(String n) { + super(n); + } + + public void testCompatibility() throws Exception { + Convertor myOwnImplementationOfConvertor = + new MyOwnImplementationOfConvertor(); + + BigDecimal result = myOwnImplementationOfConvertor.convert( + Currency.getInstance("CZK"), + Currency.getInstance("USD"), + new BigDecimal("1")); + assertEquals(1, result.intValue()); + } + + class MyOwnImplementationOfConvertor implements Convertor { + public BigDecimal convert(Currency from, Currency to, BigDecimal amount) throws InvalidConversionException { + return amount; // not very smart implementation + } + } +}