UnitTest1.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. namespace Tests
  2. {
  3. [TestClass]
  4. public class UnitTest1
  5. {
  6. //Positive
  7. [TestMethod]
  8. public void Sum21_and51_return72()
  9. {
  10. int a = 21;
  11. int b = 51;
  12. int except = 72;
  13. var calculator = new Calculator.Calculator();
  14. var actual = calculator.Add(a, b);
  15. Assert.AreEqual(actual, except);
  16. }
  17. [TestMethod]
  18. public void Sub2345_from7645_return5300()
  19. {
  20. int a = 7645;
  21. int b = 2345;
  22. int except = 5300;
  23. var calculator = new Calculator.Calculator();
  24. var actual = calculator.Subtract(a, b);
  25. Assert.AreEqual(actual, except);
  26. }
  27. [TestMethod]
  28. public void Mul44_by66_return2904()
  29. {
  30. int a = 44;
  31. int b = 66;
  32. int except = 2904;
  33. var calculator = new Calculator.Calculator();
  34. var actual = calculator.Multiply(a, b);
  35. Assert.AreEqual(actual, except);
  36. }
  37. [TestMethod]
  38. public void Div9_by2_return4_5()
  39. {
  40. int a = 9;
  41. int b = 2;
  42. float except = 4.5f;
  43. var calculator = new Calculator.Calculator();
  44. var actual = calculator.Divide(a, b);
  45. Assert.AreEqual(actual, except);
  46. }
  47. [TestMethod]
  48. public void Pow999_by0_return1()
  49. {
  50. int a = 999;
  51. int b = 0;
  52. int except = 1;
  53. var calculator = new Calculator.Calculator();
  54. var actual = calculator.Power(a, b);
  55. Assert.AreEqual(actual, except);
  56. }
  57. //Negative
  58. [TestMethod]
  59. public void Sum3_and4_notreturn8()
  60. {
  61. int a = 3;
  62. int b = 4;
  63. int except = 8;
  64. var calculator = new Calculator.Calculator();
  65. var actual = calculator.Add(a, b);
  66. Assert.AreNotEqual(actual, except);
  67. }
  68. [TestMethod]
  69. public void Sub4_from12_notreturn9()
  70. {
  71. int a = 12;
  72. int b = 4;
  73. int except = 9;
  74. var calculator = new Calculator.Calculator();
  75. var actual = calculator.Subtract(a, b);
  76. Assert.AreNotEqual(actual, except);
  77. }
  78. [TestMethod]
  79. public void Mul5_by66_notreturn331()
  80. {
  81. int a = 5;
  82. int b = 66;
  83. int except = 331;
  84. var calculator = new Calculator.Calculator();
  85. var actual = calculator.Multiply(a, b);
  86. Assert.AreNotEqual(actual, except);
  87. }
  88. [TestMethod]
  89. public void Div9_by3_notreturn4()
  90. {
  91. int a = 9;
  92. int b = 3;
  93. float except = 4;
  94. var calculator = new Calculator.Calculator();
  95. var actual = calculator.Divide(a, b);
  96. Assert.AreNotEqual(actual, except);
  97. }
  98. [TestMethod]
  99. public void Pow5_by5_notreturn625()
  100. {
  101. int a = 5;
  102. int b = 5;
  103. int except = 625;
  104. var calculator = new Calculator.Calculator();
  105. var actual = calculator.Power(a, b);
  106. Assert.AreNotEqual(actual, except);
  107. }
  108. }
  109. }