1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
-
- import org.junit.jupiter.api.Test;
-
- import static org.junit.jupiter.api.Assertions.assertEquals;
-
- public class CurrencyConverterTest {
- CurrencyConverter cc = new CurrencyConverter();
- double delta = 0.01;
-
- @Test
- public void convertDollartoEuroTest(){
- double expected = 2.12;
- double actual = cc.convert(CurrencyEnum.US_DOLLAR.getRatio(), CurrencyEnum.EURO.getRatio(),2.00);
-
- assertEquals(expected,actual,delta);
- }
-
- @Test
- public void convertEurotoDollarTest(){
- double expected=4.70;
- double actual = cc.convert(CurrencyEnum.EURO.getRatio(),CurrencyEnum.US_DOLLAR.getRatio(),5);
- assertEquals(expected,actual,delta);
- }
-
- @Test
- public void convertEurotoBritishPoundTest(){
- double expected = 11.46;
- double actual = cc.convert(CurrencyEnum.EURO.getRatio(),CurrencyEnum.BRITISH_POUND.getRatio(),10);
- assertEquals(expected,actual,delta);
- }
-
- @Test
- public void convertBritishPoundtoIndianRupeeTest(){
- double expected = 12.00;
- double actual = cc.convert(CurrencyEnum.BRITISH_POUND.getRatio(),CurrencyEnum.INDIAN_RUPEE.getRatio(),1000);
- assertEquals(expected, actual, delta);
- }
-
- @Test
- public void convertRupeetoCanadianDollarTest(){
- double expected = 3157.21;
- double actual = cc.convert(CurrencyEnum.INDIAN_RUPEE.getRatio(),CurrencyEnum.CANADIAN_DOLLAR.getRatio(),61);
- assertEquals(expected,actual, delta);
- }
-
- @Test
- public void convertCanadianDollartoSingaporeDollarTest(){
- double expected = 72.00;
- double actual = cc.convert(CurrencyEnum.CANADIAN_DOLLAR.getRatio(), CurrencyEnum.SINGAPORE.getRatio(),78);
- assertEquals(expected,actual,delta);
- }
-
- @Test
- public void convertSingaporeDollartoSwissFrancTest(){
- double expected = 94.86;
- double actual = cc.convert(CurrencyEnum.SINGAPORE.getRatio(), CurrencyEnum.SWISS_FRANC.getRatio(),67);
- assertEquals(expected, actual, delta);
- }
-
- @Test
- public void convertSwissFranctoMalaysianRinggit(){
- double expected = 24.40;
- double actual = cc.convert(CurrencyEnum.SWISS_FRANC.getRatio(), CurrencyEnum.MALAYSIAN_RINGGIT.getRatio(),105);
- assertEquals(expected,actual,delta);
- }
-
- @Test
- public void convertMalaysianRinggittoJapaneseYenTest(){
- double expected = 192.93;
- double actual = cc.convert(CurrencyEnum.MALAYSIAN_RINGGIT.getRatio(),CurrencyEnum.JAPANESE_YEN.getRatio(),5000);
- assertEquals(expected, actual, delta);
- }
-
- @Test
- public void convertJapaneseYentoChineseYuanRenminbiTest(){
- double expected = 4184.97;
- double actual = cc.convert(CurrencyEnum.JAPANESE_YEN.getRatio(), CurrencyEnum.CHINESE_YUAN_RENMINBI.getRatio(), 250);
- assertEquals(expected, actual, delta);
- }
- }
-
-
|