UnitTest1.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using ConsoleApp2;
  2. namespace TestProject1
  3. {
  4. [TestClass]
  5. public class UnitTest1
  6. {
  7. [TestMethod]
  8. public void Sum_AreEqale()
  9. {
  10. double x = 0.7;
  11. double y = 1.3;
  12. double except = 2;
  13. double actual = Calculation.Sum(x, y);
  14. Assert.AreEqual(except, actual);
  15. }
  16. [TestMethod]
  17. public void Sum_IsNotInstanceOfType()
  18. {
  19. double x = 0.7;
  20. double y = 1.3;
  21. double actual = Calculation.Sum(x, y);
  22. Assert.IsNotInstanceOfType(actual, typeof(int));
  23. }
  24. [TestMethod]
  25. public void Difference_AreEqale()
  26. {
  27. double x = 0.7;
  28. double y = 1.3;
  29. double except = -0.6;
  30. double actual = Calculation.Difference(x, y);
  31. Assert.AreEqual(except, actual);
  32. }
  33. [TestMethod]
  34. public void Difference_AreNotEqale()
  35. {
  36. double x = 0.71;
  37. double y = 1.345;
  38. double except = -0.635;
  39. double actual = Calculation.Difference(x, y);
  40. Assert.AreNotEqual(except, actual);
  41. }
  42. [TestMethod]
  43. public void Increase_AreEqual()
  44. {
  45. double x = 0.7;
  46. double y = 1.3;
  47. double except = 0.91;
  48. double actual = Calculation.Increase(x, y);
  49. Assert.AreEqual(except, actual);
  50. }
  51. [TestMethod]
  52. public void Increase_AreNotEqual()
  53. {
  54. double x = 0.71;
  55. double y = 1.345;
  56. double except = 0.95495;
  57. double actual = Calculation.Increase(x, y);
  58. Assert.AreNotEqual(except, actual);
  59. }
  60. [TestMethod]
  61. public void Division_AreEqual()
  62. {
  63. double x = 0.7;
  64. double y = 1.3;
  65. double except = 0.538;
  66. double actual = Calculation.Division(x, y);
  67. Assert.AreEqual(except, actual);
  68. }
  69. [TestMethod]
  70. public void Division_AreNotEqual()
  71. {
  72. double x = 0.71;
  73. double y = 0;
  74. double except = 0.71;
  75. double actual = Calculation.Division(x, y); //âåðíåò 0
  76. Assert.AreNotEqual(except, actual);
  77. }
  78. [TestMethod]
  79. public void Extent_AreEqual()
  80. {
  81. int x = 7;
  82. int y = 2;
  83. int except = 49;
  84. int actual = Calculation.Extent(x, y);
  85. Assert.AreEqual(except, actual);
  86. }
  87. [TestMethod]
  88. public void Extent_AreNotEqual()
  89. {
  90. int x = 7;
  91. int y = 0;
  92. int except = 7;
  93. int actual = Calculation.Extent(x, y);
  94. Assert.AreNotEqual(except, actual);
  95. }
  96. }
  97. }