Advertisement
Guest User

CurrencyTreatmentTest.java

a guest
May 29th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. //CurrencyTreatmentTest.java - For JUnit test
  2.  
  3. package il.ac.hit.currencies;
  4.  
  5. import org.junit.*;
  6. import static org.junit.Assert.*;
  7.  
  8. /**
  9.  * Created by Yossi and Lior on 20/05/2015.
  10.  */
  11.  
  12. public class CurrencyTreatmentTest {
  13.  
  14.     private static CurrencyTreatment ct;
  15.     private String[] curreciesNames = { "USD", "GBP", "JPY", "EUR", "AUD", "CAD", "DKK"
  16.             , "NOK","ZAR", "SEK","CHF", "JOD", "LBP", "EGP" };
  17.     private double[] curreciesRate = { 3.467, 5.7844, 3.38, 4.6363, 3.2329, 3.1813, 0.6219,
  18.             0.5631, 0.3288, 0.5057, 3.8266, 4.8989, 0.0230, 0.4848 };
  19.  
  20.     @Before
  21.     public void setUp() throws Exception {
  22.  
  23.     }
  24.  
  25.     @After
  26.     public void tearDown() throws Exception {
  27.  
  28.     }
  29.  
  30.  
  31.     @BeforeClass
  32.     public static void setUpBeforeClass() throws Exception {
  33.         ct = new CurrencyTreatment();
  34.     }
  35.  
  36.  
  37.  
  38.     @AfterClass
  39.     public static void tearDownAfterClass() throws Exception {
  40.         ct = null;
  41.     }
  42.  
  43.  
  44.     @Test
  45.     public void testConvert() throws Exception {
  46.  
  47.        double expected = 2.400230769230769;
  48.         double actual = ct.convert("2.34", 0, 2, curreciesRate);
  49.         double delta = 0.05;
  50.  
  51.             assertEquals(expected, actual, delta);       // first check
  52.             expected = 11.168492796134931;                  // second check
  53.             actual = ct.convert("15.32", 2, 3, curreciesRate);
  54.             assertEquals(expected, actual, delta);
  55.     }
  56.  
  57. }
  58.  
  59. //end of CurrencyTreatmentTest
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement