1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- import org.junit.Assert;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
-
- public class CurrencyConverterTest {
- CurrencyConverter cc;
- @Before
- public void setup() {
- cc = new CurrencyConverter();
- }
-
- @Test
- public void dollarToEuroTest() {
- double expected = 0.94;
- double actual = cc.convertCurrency(Currency.usdollar, Currency.euro, 1);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void euroToDollarTest() {
- double expected = 1;
- double actual = cc.convertCurrency(Currency.euro, Currency.usdollar, 0.94);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void euroToBritishPoundTest() {
- double expected = 0.87;
- double actual = cc.convertCurrency(Currency.euro, Currency.bpound, 1);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void britishPoundToIndianRupeeTest() {
- double expected = 83.32;
- double actual = cc.convertCurrency(Currency.bpound, Currency.irupee, 1);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void rupeeToCanadianDollarTest() {
- double expected = 0.02;
- double actual = cc.convertCurrency(Currency.irupee, Currency.candollar, 1);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void canadianDollarToSingaporeDollarTest() {
- double expected = 1.08;
- double actual = cc.convertCurrency(Currency.candollar, Currency.singdollar, 1);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void singaporeDollarToSwissFrancTest() {
- double expected = 0.71;
- double actual = cc.convertCurrency(Currency.singdollar, Currency.swissfranc, 1);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void swissFrancToMalaysianRinggitTest() {
- double expected = 4.43;
- double actual = cc.convertCurrency(Currency.swissfranc, Currency.malringgit, 1);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void malaysianRinggitToJapaneseYenTest() {
- double expected = 25.91;
- double actual = cc.convertCurrency(Currency.malringgit, Currency.japyen, 1);
- Assert.assertEquals(expected, actual, 0);
- }
- @Test
- public void JapaneseYenToChineseYuanRenminbiTest() {
- double expected = 5.97;
- double actual = cc.convertCurrency(Currency.japyen, Currency.yuanrenminbi, 100);
- Assert.assertEquals(expected, actual, 0);
- }
- }
|