1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import org.junit.Test;
  2. import static org.junit.Assert.*;
  3. import java.util.HashMap;
  4. public class CurrencyConverterTest {
  5. CurrencyConverter cc = new CurrencyConverter();
  6. @Test
  7. public void dollarToEuro() {
  8. double result = cc.convertTo("USD", "EUR", 2);
  9. assertEquals(result, 1.88, 0.02);
  10. }
  11. @Test
  12. public void euroToDollar() {
  13. double result = cc.convertTo("EUR", "USD", 2);
  14. assertEquals(result, 2.12, 0.02);
  15. }
  16. @Test
  17. public void euroToPound() {
  18. double result = cc.convertTo("EUR", "GBP", 2);
  19. assertEquals(result, 1.74, 0.02);
  20. }
  21. @Test
  22. public void poundToRupee() {
  23. double result = cc.convertTo("GBP", "INR", 2);
  24. assertEquals(result, 166.63, 0.02);
  25. }
  26. @Test
  27. public void rupeeToKanadia() {
  28. double result = cc.convertTo("INR", "CAN", 2);
  29. assertEquals(result, 180.36, 0.02);
  30. }
  31. @Test
  32. public void kanadiaToSingapore() {
  33. double result = cc.convertTo("CAN", "SGD", 2);
  34. assertEquals(result, 3.77, 0.02);
  35. }
  36. @Test
  37. public void singaporeToFranc() {
  38. double result = cc.convertTo("SGD", "CHF", 2);
  39. assertEquals(result, 2.88, 0.02);
  40. }
  41. @Test
  42. public void francToMeley() {
  43. double result = cc.convertTo("CHF", "MYR", 2);
  44. assertEquals(result, 2.04, 0.02);
  45. }
  46. @Test
  47. public void meleyToYen() {
  48. double result = cc.convertTo("MYR", "YEN", 2);
  49. assertEquals(result, 2.04, 0.02);
  50. }
  51. @Test
  52. public void yenToChina() {
  53. double result = cc.convertTo("YEN", "CNY", 2);
  54. assertEquals(result, 13.97, 0.02);
  55. }
  56. }