TestClass 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. [TestClass]
  2. public class UnitTest1
  3. {
  4. [TestMethod]
  5. public void TestMethodIsNotNull()
  6. {
  7. Assert.IsNotNull(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45));
  8. }
  9. [TestMethod]
  10. public void TestMethodIsInstanceOfType()
  11. {
  12. Int32 f = 0;
  13. Assert.IsInstanceOfType(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45), f.GetType());
  14. }
  15. [TestMethod]
  16. public void TestMethodIsNotInstanceOfType()
  17. {
  18. string f = "a";
  19. Assert.IsNotInstanceOfType(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45), f.GetType());
  20. }
  21. [TestMethod]
  22. public void TestMethodIsNotInstanceOfType2()
  23. {
  24. bool f = true;
  25. Assert.IsNotInstanceOfType(Calculation.GetQuantityForProduct(3, 1, 15, 20, 45), f.GetType());
  26. }
  27. [TestMethod]
  28. public void TestMethodIsFalse()
  29. {
  30. bool fact = true;
  31. if (Calculation.GetQuantityForProduct(3, 55, 15, 20, 45) == -1)
  32. {
  33. fact = false;
  34. }
  35. Assert.IsFalse(fact);
  36. }
  37. [TestMethod]
  38. public void TestMethodIsTrue()
  39. {
  40. bool fact = true;
  41. if (Calculation.GetQuantityForProduct(1, 1, 15, 20, 45) == -1)
  42. {
  43. fact = false;
  44. }
  45. Assert.IsTrue(fact);
  46. }
  47. [TestMethod]
  48. public void TestMethodEqualResult()
  49. {
  50. int fact = 114146;
  51. int expected = Calculation.GetQuantityForProduct(3, 1, 15, 20, 45);
  52. Assert.AreEqual(fact, expected);
  53. }
  54. [TestMethod]
  55. public void TestMethodNotEqualResult()
  56. {
  57. int fact = 1;
  58. int expected = Calculation.GetQuantityForProduct(3, 1, 15, 20, 45);
  59. Assert.AreNotEqual(fact, expected);
  60. }
  61. [TestMethod]
  62. public void TestMethodEqualResultIncorrectMaterialType()
  63. {
  64. int fact = -1;
  65. int expected = Calculation.GetQuantityForProduct(10, 1, 15, 20, 45);
  66. Assert.AreEqual(fact, expected);
  67. }
  68. [TestMethod]
  69. public void TestMethodNotEqualResultIncorrectMaterialType()
  70. {
  71. int fact = 0;
  72. int expected = Calculation.GetQuantityForProduct(-1, 1, 15, 20, 45);
  73. Assert.AreNotEqual(fact, expected);
  74. }
  75. [TestMethod]
  76. public void TestMethodEqualResultIncorrectWidth()
  77. {
  78. int fact = 0;
  79. int expected = Calculation.GetQuantityForProduct(3, 1, 15, 0, 45);
  80. Assert.AreEqual(fact, expected);
  81. }
  82. [TestMethod]
  83. public void TestMethodEqualResultIncorrectLength()
  84. {
  85. int fact = 0;
  86. int expected = Calculation.GetQuantityForProduct(3, 1, 15, 20, 0);
  87. Assert.AreEqual(fact, expected);
  88. }
  89. }