123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import org.junit.Test;
  2. import org.junit.Assert;
  3. public class CurrencyConverterTest {
  4. CurrencyConverter cc = new CurrencyConverter();
  5. @Test
  6. public void dollarToEuroTest(){
  7. //When
  8. double dollar = 10;
  9. //Expected
  10. double expected = 9.40;
  11. //Actual
  12. double actual = cc.dollarToEuro(dollar);
  13. Assert.assertEquals(expected, actual, 0.01);
  14. }
  15. @Test
  16. public void euroToDollarTest(){
  17. //When
  18. double euro = 4.7;
  19. //Expected
  20. double expected = 4.1;
  21. //Actual
  22. double actual = cc.euroToDollar(euro);
  23. Assert.assertEquals(expected, actual, 1);
  24. }
  25. @Test
  26. public void euroToBritishPoundTest(){
  27. //When
  28. double euro = 4.7;
  29. //Expected
  30. double expected = 4.1;
  31. //Actual
  32. double actual = cc.euroToBritishPound(euro);
  33. Assert.assertEquals(expected, actual, 1);
  34. }
  35. @Test
  36. public void britishPoundToIndianRupeeTest(){
  37. //When
  38. double britishPound = .82;
  39. //Expected
  40. double expected = 56.02;
  41. //Actual
  42. double actual = cc.britishPoundToIndianRupee(britishPound);
  43. Assert.assertEquals(expected, actual, 0.01);
  44. }
  45. @Test
  46. public void rupeeToCanadianDollarTest(){
  47. //When
  48. double rupee = 68.32;
  49. //Expected
  50. double expected = 90.18;
  51. //Actual
  52. double actual = cc.rupeeToCanadianDollar(rupee);
  53. Assert.assertEquals(expected, actual, 0.01);
  54. }
  55. @Test
  56. public void canadianDollarToSingaporeDollarTest(){
  57. //When
  58. double canadianDollar = 1.32;
  59. //Expected
  60. double expected = 1.88;
  61. //Actual
  62. double actual = cc.canadianDollarToSingaporeDollar(canadianDollar);
  63. Assert.assertEquals(expected, actual, 0.01);
  64. }
  65. @Test
  66. public void singaporeDollarToSwissFrancTest(){
  67. //When
  68. double singaporeDollar = 1.32;
  69. //Expected
  70. double expected = 1.44;
  71. //Actual
  72. double actual = cc.singaporeDollarToSwissFranc(singaporeDollar);
  73. Assert.assertEquals(expected, actual, 1);
  74. }
  75. @Test
  76. public void swissFrancToMalaysianRinggitTest(){
  77. //When
  78. double swissFranc = 1.01;
  79. //Expected
  80. double expected = 4.51;
  81. //Actual
  82. double actual = cc.swissFrancToMalaysianRinggit(swissFranc);
  83. Assert.assertEquals(expected, actual, 1);
  84. }
  85. @Test
  86. public void malaysianRinggitToJapaneseYenTest(){
  87. //When
  88. double malaysianRinggit = 4.47;
  89. //Expected
  90. double expected = 517.80;
  91. //Actual
  92. double actual = cc.malaysianRinggitToJapaneseYen(malaysianRinggit);
  93. Assert.assertEquals(expected, actual, 1);
  94. }
  95. @Test
  96. public void japaneseYenToChineseYuanRenminbiTest(){
  97. //When
  98. double japaneseYen = 115.84;
  99. //Expected
  100. double expected = 1078.41;
  101. //Actual
  102. double actual = cc.japaneseYenToChineseYuanRenminbi(japaneseYen);
  103. Assert.assertEquals(expected, actual, 300);
  104. }
  105. }