UnitTest1.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using WSUniversalLib;
  4. namespace WSUniversalLibUnitTest
  5. {
  6. [TestClass]
  7. public class UnitTest1
  8. {
  9. //Тесты низкой сложности
  10. [TestMethod]
  11. public void GetQuantityForProductTest_IsInstanceOfType()
  12. {
  13. int answer = Calculation.GetQuantityForProduct(3, 1, 15, 20, 45);
  14. Assert.IsInstanceOfType(answer, typeof(int));
  15. }
  16. [TestMethod]
  17. public void GetQuantityForProductTest_IsNotInstanceOfType()
  18. {
  19. int answer = Calculation.GetQuantityForProduct(3, 1, 15, 20, 45);
  20. Assert.IsNotInstanceOfType(answer, typeof(double));
  21. }
  22. [TestMethod]
  23. public void GetQuantityForProductTest_IsNotNull()
  24. {
  25. int answer = Calculation.GetQuantityForProduct(3, 1, 15, 20, 45);
  26. Assert.IsNotNull(answer);
  27. }
  28. [TestMethod]
  29. public void GetQuantityForProductTest_AreEqual()
  30. {
  31. int answer = Calculation.GetQuantityForProduct(3, 1, 15, 20, 45);
  32. Assert.AreEqual(114146, answer);
  33. }
  34. [TestMethod]
  35. public void GetQuantityForProductTest_AreNotEqual()
  36. {
  37. int answer = Calculation.GetQuantityForProduct(3, 1, 15, 20, 45);
  38. Assert.AreNotEqual(12, answer);
  39. }
  40. //Тесты высокой сложности
  41. [TestMethod]
  42. public void GetQuantityForProductTest_ProductDoesNotExist()
  43. {
  44. int answer = Calculation.GetQuantityForProduct(21, 1, 15, 20, 45);
  45. Assert.AreEqual(-1, answer);
  46. }
  47. [TestMethod]
  48. public void GetQuantityForProductTest_MaterialDoesNotExist()
  49. {
  50. int answer = Calculation.GetQuantityForProduct(3, 21, 15, 20, 45);
  51. Assert.AreEqual(-1, answer);
  52. }
  53. [TestMethod]
  54. public void GetQuantityForProductTest_WidthDoesNotExist()
  55. {
  56. int answer = Calculation.GetQuantityForProduct(3, 1, 15, 0, 45);
  57. Assert.AreEqual(-1, answer);
  58. }
  59. [TestMethod]
  60. public void GetQuantityForProductTest_CountDoesNotExist()
  61. {
  62. int answer = Calculation.GetQuantityForProduct(3, 1, 0, 20, 45);
  63. Assert.AreEqual(-1, answer);
  64. }
  65. [TestMethod]
  66. public void GetQuantityForProductTest_LenghtDoesNotExist()
  67. {
  68. int answer = Calculation.GetQuantityForProduct(3, 1, 15, 20, 0);
  69. Assert.AreEqual(-1, answer);
  70. }
  71. }
  72. }