123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- import org.junit.Test;
- import org.junit.Assert;
-
- public class CurrencyConverterTest {
- CurrencyConverter cc = new CurrencyConverter();
- @Test
- public void dollarToEuroTest(){
-
- //When
- double dollar = 10;
- //Expected
- double expected = 9.40;
- //Actual
- double actual = cc.dollarToEuro(dollar);
- Assert.assertEquals(expected, actual, 0.01);
- }
-
- @Test
- public void euroToDollarTest(){
- //When
- double euro = 4.7;
- //Expected
- double expected = 4.1;
- //Actual
- double actual = cc.euroToDollar(euro);
- Assert.assertEquals(expected, actual, 1);
- }
-
- @Test
- public void euroToBritishPoundTest(){
- //When
- double euro = 4.7;
- //Expected
- double expected = 4.1;
- //Actual
- double actual = cc.euroToBritishPound(euro);
- Assert.assertEquals(expected, actual, 1);
- }
-
- @Test
- public void britishPoundToIndianRupeeTest(){
- //When
- double britishPound = .82;
- //Expected
- double expected = 56.02;
- //Actual
- double actual = cc.britishPoundToIndianRupee(britishPound);
- Assert.assertEquals(expected, actual, 0.01);
- }
-
- @Test
- public void rupeeToCanadianDollarTest(){
- //When
- double rupee = 68.32;
- //Expected
- double expected = 90.18;
- //Actual
- double actual = cc.rupeeToCanadianDollar(rupee);
- Assert.assertEquals(expected, actual, 0.01);
- }
-
- @Test
- public void canadianDollarToSingaporeDollarTest(){
- //When
- double canadianDollar = 1.32;
- //Expected
- double expected = 1.88;
- //Actual
- double actual = cc.canadianDollarToSingaporeDollar(canadianDollar);
- Assert.assertEquals(expected, actual, 0.01);
- }
-
- @Test
- public void singaporeDollarToSwissFrancTest(){
- //When
- double singaporeDollar = 1.32;
- //Expected
- double expected = 1.44;
- //Actual
- double actual = cc.singaporeDollarToSwissFranc(singaporeDollar);
- Assert.assertEquals(expected, actual, 1);
- }
-
- @Test
- public void swissFrancToMalaysianRinggitTest(){
- //When
- double swissFranc = 1.01;
- //Expected
- double expected = 4.51;
- //Actual
- double actual = cc.swissFrancToMalaysianRinggit(swissFranc);
- Assert.assertEquals(expected, actual, 1);
- }
-
- @Test
- public void malaysianRinggitToJapaneseYenTest(){
- //When
- double malaysianRinggit = 4.47;
- //Expected
- double expected = 517.80;
- //Actual
- double actual = cc.malaysianRinggitToJapaneseYen(malaysianRinggit);
- Assert.assertEquals(expected, actual, 1);
- }
-
- @Test
- public void japaneseYenToChineseYuanRenminbiTest(){
- //When
- double japaneseYen = 115.84;
- //Expected
- double expected = 1078.41;
- //Actual
- double actual = cc.japaneseYenToChineseYuanRenminbi(japaneseYen);
- Assert.assertEquals(expected, actual, 300);
- }
-
- }
|