ShortCalculatorTest.java 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import org.junit.Assert;
  2. import org.junit.Before;
  3. import org.junit.Test;
  4. public class ShortCalculatorTest
  5. {
  6. private ShortCalculator shortCalculator;
  7. @Before
  8. public void setUp(){
  9. shortCalculator = new ShortCalculator();
  10. }
  11. @Test
  12. public void sumTest(){
  13. // :Given
  14. short expected = 12;
  15. // :When
  16. short actual = shortCalculator.sum((short) 10, (short)2);
  17. // :Then
  18. Assert.assertEquals("The values equal 12", expected, actual);
  19. }
  20. @Test
  21. public void differenctTest(){
  22. // :Given
  23. short expected = 8;
  24. // :When
  25. short actual = shortCalculator.difference((short)10, (short)2);
  26. // :Then
  27. Assert.assertEquals("The values equal 8", expected, actual);
  28. }
  29. @Test
  30. public void productTest(){
  31. // :Given
  32. short expected = 20;
  33. // :When
  34. short actual = shortCalculator.product((short)10, (short)2);
  35. // :Then
  36. Assert.assertEquals("The values equal 20", expected, actual);
  37. }
  38. @Test
  39. public void quotientTest(){
  40. // :Given
  41. short expected = 10;
  42. // :When
  43. short actual = shortCalculator.quotient((short)20, (short)2);
  44. // :Then
  45. Assert.assertEquals("The values equal 10", expected, actual);
  46. }
  47. @Test
  48. public void remainderTest(){
  49. // :Given
  50. short expected = 1;
  51. // :When
  52. short actual = shortCalculator.remainder ((short)5, (short)2);
  53. // :Then
  54. Assert.assertEquals("The values equal 1", expected, actual);
  55. }
  56. }