UnitTest1.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using WSUniversalLib;
  4. namespace WSUniversalTest
  5. {
  6. [TestClass]
  7. public class UnitTest1
  8. {
  9. [TestMethod]
  10. public void GetQuantityForProduct_IsTrue()
  11. {
  12. int result = Calculation.GetQuantityForProduct(2, 1, 10, 20f, 45f);
  13. Assert.IsTrue(result > 0);
  14. }
  15. [TestMethod]
  16. public void GetQuantityForProduct_IsTrue2()
  17. {
  18. int result = Calculation.GetQuantityForProduct(2, 2, 10, 20f, 45f);
  19. Assert.IsTrue(result == 22527);
  20. }
  21. [TestMethod]
  22. public void GetQuantityForProduct_IsTrue3()
  23. {
  24. int result = Calculation.GetQuantityForProduct(1, 2, 10, 20f, 45f);
  25. Assert.IsTrue(result == 9912);
  26. }
  27. [TestMethod]
  28. public void GetQuantityForProduct_IsTrue4()
  29. {
  30. int result = Calculation.GetQuantityForProduct(1, 1, 10, 20f, 45f);
  31. Assert.IsTrue(result == 9930);
  32. }
  33. [TestMethod]
  34. public void GetQuantityForProduct_IsFalse()
  35. {
  36. int result = Calculation.GetQuantityForProduct(1, 1, 10, 20f, 45f);
  37. Assert.IsFalse(result == 114146);
  38. }
  39. [TestMethod]
  40. public void GetQuantityForProduct_TypeOfResultIsInt()
  41. {
  42. Assert.IsInstanceOfType(Calculation.GetQuantityForProduct(1, 2, 1, 15f, 13f), typeof(int));
  43. }
  44. [TestMethod]
  45. public void GetQuantityForProduct_AreEquel()
  46. {
  47. int result = Calculation.GetQuantityForProduct(3, 1, 15, 20f, 45f);
  48. Assert.AreEqual(Convert.ToString(result), "114147");
  49. }
  50. [TestMethod]
  51. public void GetQuantityForProduct_AreEquel2()
  52. {
  53. int result = Calculation.GetQuantityForProduct(2, 2, 10, 20f, 45f);
  54. Assert.AreEqual(Convert.ToString(result), "22527");
  55. }
  56. [TestMethod]
  57. public void GetQuantityForProduct_AreNotEquel()
  58. {
  59. int result = Calculation.GetQuantityForProduct(3, 1, 15, 20f, 45f);
  60. Assert.AreNotEqual(Convert.ToString(result), "114146");
  61. }
  62. [TestMethod]
  63. public void GetQuantityForProduct_IsNotNULL()
  64. {
  65. Assert.IsNotNull(Calculation.GetQuantityForProduct(2, 1, 10, 20f, 45f));
  66. }
  67. [TestMethod]
  68. public void GetQuantityForProduct_UNCorrectProductType_IsTrue()
  69. {
  70. int result = Calculation.GetQuantityForProduct(0, 2, 1, 15f, 13f);
  71. Assert.IsTrue(result == -1);
  72. }
  73. [TestMethod]
  74. public void GetQuantityForProduct_UNCorrectMaterialType_IsTrue()
  75. {
  76. int result = Calculation.GetQuantityForProduct(1, 0, 1, 15f, 13f);
  77. Assert.IsTrue(result == -1);
  78. }
  79. [TestMethod]
  80. public void GetQuantityForProduct_UNCorrectCount_IsTrue()
  81. {
  82. int result = Calculation.GetQuantityForProduct(1, 2, 0, 15f, 13f);
  83. Assert.IsTrue(result == -1);
  84. }
  85. [TestMethod]
  86. public void GetQuantityForProduct_UNCorrectWidth_IsTrue()
  87. {
  88. int result = Calculation.GetQuantityForProduct(1, 2, 1, 0f, 13f);
  89. Assert.IsTrue(result == -1);
  90. }
  91. [TestMethod]
  92. public void GetQuantityForProduct_UNCorrectLength_IsTrue()
  93. {
  94. int result = Calculation.GetQuantityForProduct(1, 2, 0, 15f, 0f);
  95. Assert.IsTrue(result == -1);
  96. }
  97. }
  98. }