1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/task1/solution02/test/org/apidesign/apifest08/test/ConvertorFactoryTest.java Sun Sep 28 14:12:38 2008 +0200
1.3 @@ -0,0 +1,46 @@
1.4 +package org.apidesign.apifest08.test;
1.5 +
1.6 +import static junit.framework.Assert.assertEquals;
1.7 +import static junit.framework.Assert.assertNotNull;
1.8 +import static org.apidesign.apifest08.test.Task1Test.CZK;
1.9 +import static org.apidesign.apifest08.test.Task1Test.USD;
1.10 +
1.11 +import java.util.Currency;
1.12 +
1.13 +import org.apidesign.apifest08.currency.ConvertorFactory;
1.14 +import org.apidesign.apifest08.currency.UnsupportedConversionException;
1.15 +import org.junit.Test;
1.16 +
1.17 +
1.18 +public class ConvertorFactoryTest {
1.19 + @Test(expected=NullPointerException.class)
1.20 + public void testNullSource()
1.21 + {
1.22 + ConvertorFactory.createConvertor(null, USD);
1.23 + }
1.24 + @Test(expected=NullPointerException.class)
1.25 + public void testNullDestination()
1.26 + {
1.27 + ConvertorFactory.createConvertor(CZK, null);
1.28 + }
1.29 + @Test(expected=IllegalArgumentException.class)
1.30 + public void testShortSource()
1.31 + {
1.32 + ConvertorFactory.createConvertor(Currency.getInstance("CZ"), USD);
1.33 + }
1.34 + @Test(expected=UnsupportedConversionException.class)
1.35 + public void testUnknownCombination()
1.36 + {
1.37 + ConvertorFactory.createConvertor(CZK, Currency.getInstance("ZAR"));
1.38 + }
1.39 + @Test
1.40 + public void testOk()
1.41 + {
1.42 + assertNotNull(ConvertorFactory.createConvertor(CZK, USD));
1.43 + }
1.44 + @Test
1.45 + public void testReverted()
1.46 + {
1.47 + assertEquals(ConvertorFactory.createConvertor(CZK, USD).revert(), ConvertorFactory.createConvertor(USD, CZK));
1.48 + }
1.49 +}