CurrencyConverterTest.java 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import org.junit.Test;
  2. import org.junit.Assert;
  3. public class CurrencyConverterTest {
  4. @Test
  5. public void ConvertDollarToEuro(){
  6. //when
  7. double dolla = 10;
  8. //expected
  9. double expected = 9.40;
  10. //actual
  11. double actual = CurrencyConverter.ConvertDollarToEuro(dolla);
  12. Assert.assertEquals(expected, actual, 0);
  13. }
  14. @Test
  15. public void EuroToDollar(){
  16. double euro = 0.94;
  17. double expected = 0.94;
  18. double actual = CurrencyConverter.EuroToDollar(euro);
  19. Assert.assertEquals(expected, actual, 0);
  20. }
  21. @Test
  22. public void EuroToBritishPound(){
  23. //when
  24. double euro = 50;
  25. //expected
  26. double expected = 41;
  27. //actual
  28. double actual = CurrencyConverter.EuroToBritishPound(euro);
  29. Assert.assertEquals(expected, actual, 0);
  30. }
  31. @Test
  32. public void BritishPoundToRupee(){
  33. double britishPound = 100;
  34. double expected = 6832;
  35. double actual = CurrencyConverter.BritishPoundToRupee(britishPound);
  36. Assert.assertEquals(expected, actual, 0);
  37. }
  38. @Test
  39. public void RuppeeToCanadianDolla(){
  40. double ruppee = 20;
  41. double expected = 26.4;
  42. double actual = CurrencyConverter.RupeeToCanadianDollar(ruppee);
  43. Assert.assertEquals(expected, actual, 0);
  44. }
  45. @Test
  46. public void CanadianDollarToSingapore(){
  47. double canadianDollar = 30;
  48. double expected = 42.9;
  49. double actual = CurrencyConverter.canadianToSingapore(canadianDollar);
  50. Assert.assertEquals(expected, actual, 0);
  51. }
  52. @Test
  53. public void SingaporeToSwiss(){
  54. double singapore = 30;
  55. double expected = 30.3;
  56. double actual = CurrencyConverter.SingaporeToSwiss(singapore);
  57. Assert.assertEquals(expected, actual, 0);
  58. }
  59. @Test
  60. public void SwissToMalaysian(){
  61. double Swiss = 50;
  62. double expected = 223.5;
  63. double actual = CurrencyConverter.SwissToMalaysian(Swiss);
  64. Assert.assertEquals(expected, actual, 0);
  65. }
  66. @Test
  67. public void MalaysianToJapaneseYen(){
  68. double malaysian = 50;
  69. double expected = 5792;
  70. double actual = CurrencyConverter.MalaysianToJapaneseYen(malaysian);
  71. Assert.assertEquals(expected, actual, 0);
  72. }
  73. @Test
  74. public void JapaneseYenToChinese(){
  75. double japan = 50;
  76. double expected = 346;
  77. double actual = CurrencyConverter.JapaneseYenToChinese(japan);
  78. Assert.assertEquals(expected, actual, 0);
  79. }
  80. }