UnitTest.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. using UnitTestingCalculator;
  2. namespace UnitTests
  3. {
  4. [TestClass]
  5. public class UnitTest
  6. {
  7. /// <summary>
  8. /// Ïîëîæèòåëüíîå òåñòèðîâàíèå ìåòîäà Cëîæåíèÿ
  9. /// </summary>
  10. [TestMethod]
  11. public void Addition_15plus2_Return17()
  12. {
  13. double firstNum = 15;
  14. double secondNum = 2.1;
  15. double except = 17.1;
  16. Calculator example = new Calculator(firstNum, secondNum);
  17. double result = example.Addition();
  18. Assert.AreEqual(except, result);
  19. }
  20. /// <summary>
  21. /// Íåãàòèâíîå òåñòèðîâàíèå ìåòîäà Cëîæåíèÿ
  22. /// </summary>
  23. [TestMethod]
  24. public void Addition_15plus2_Notreturn10()
  25. {
  26. double firstNum = 15;
  27. double secondNum = 2.1;
  28. double except = 10;
  29. Calculator example = new Calculator(firstNum, secondNum);
  30. double result = example.Addition();
  31. Assert.AreNotEqual(except, result);
  32. }
  33. /// <summary>
  34. /// Ïîëîæèòåëüíîå òåñòèðîâàíèå ìåòîäà Âû÷èòàíèÿ
  35. /// </summary>
  36. [TestMethod]
  37. public void Subtraction_15minus5_Return10()
  38. {
  39. double firstNum = 15;
  40. double secondNum = 5;
  41. double except = 10;
  42. Calculator example = new Calculator(firstNum, secondNum);
  43. double result = example.Subtraction();
  44. Assert.AreEqual(except, result);
  45. }
  46. /// <summary>
  47. /// Íåãàòèâíîå òåñòèðîâàíèå ìåòîäà Âû÷èòàíèÿ
  48. /// </summary>
  49. [TestMethod]
  50. public void Subtraction_15minus5_Notreturn20()
  51. {
  52. double firstNum = 15;
  53. double secondNum = 5;
  54. double except = 20;
  55. Calculator example = new Calculator(firstNum, secondNum);
  56. double result = example.Subtraction();
  57. Assert.AreNotEqual(except, result);
  58. }
  59. /// <summary>
  60. /// Ïîëîæèòåëüíîå òåñòèðîâàíèå ìåòîäà Óìíîæåíèÿ
  61. /// </summary>
  62. [TestMethod]
  63. public void Multiplication_Multiply20And2_Return40()
  64. {
  65. double firstNum = 20;
  66. double secondNum = 2;
  67. double except = 40;
  68. Calculator example = new Calculator(firstNum, secondNum);
  69. double result = example.Multiplication();
  70. Assert.AreEqual(except, result);
  71. }
  72. /// <summary>
  73. /// Íåãàòèâíîå òåñòèðîâàíèå ìåòîäà Óìíîæåíèÿ
  74. /// </summary>
  75. [TestMethod]
  76. public void Multiplication_MultiplyMinus10And2_Notreturn20()
  77. {
  78. double firstNum = -10;
  79. double secondNum = 2;
  80. double except = 20;
  81. Calculator example = new Calculator(firstNum, secondNum);
  82. double result = example.Multiplication();
  83. Assert.AreNotEqual(except, result);
  84. }
  85. /// <summary>
  86. /// Ïîëîæèòåëüíîå òåñòèðîâàíèå ìåòîäà Äåëåíèÿ
  87. /// </summary>
  88. [TestMethod]
  89. public void Division_Divide14And2_Return7()
  90. {
  91. double firstNum = 14;
  92. double secondNum = 2;
  93. double except = 7;
  94. Calculator example = new Calculator(firstNum, secondNum);
  95. double result = example.Division();
  96. Assert.AreEqual(except, result);
  97. }
  98. /// <summary>
  99. /// Íåãàòèâíîå òåñòèðîâàíèå ìåòîäà Äåëåíèÿ
  100. /// </summary>
  101. [TestMethod]
  102. public void Division_Divide14And0_Notreturn14()
  103. {
  104. double firstNum = 14;
  105. double secondNum = 0;
  106. double except = 14;
  107. Calculator example = new Calculator(firstNum, secondNum);
  108. double result = example.Division();
  109. Assert.AreNotEqual(except, result);
  110. }
  111. /// <summary>
  112. /// Ïîëîæèòåëüíîå òåñòèðîâàíèå ìåòîäà Ñòåïåíè
  113. /// </summary>
  114. [TestMethod]
  115. public void Exponentiation_5power3_Return125()
  116. {
  117. double firstNum = 5;
  118. double secondNum = 3;
  119. double except = 125;
  120. Calculator example = new Calculator(firstNum, secondNum);
  121. double result = example.Exponentiation();
  122. Assert.AreEqual(except, result);
  123. }
  124. /// <summary>
  125. /// Íåãàòèâíîå òåñòèðîâàíèå ìåòîäà Ñòåïåíè
  126. /// </summary>
  127. [TestMethod]
  128. public void Exponentiation_10power0_Notreturn10()
  129. {
  130. double firstNum = 10;
  131. double secondNum = 0;
  132. double except = 10;
  133. Calculator example = new Calculator(firstNum, secondNum);
  134. double result = example.Exponentiation();
  135. Assert.AreNotEqual(except, result);
  136. }
  137. }
  138. }