UnitTest1.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using WSUniversalLib;
  4. namespace UnitTestorWSULib
  5. {
  6. [TestClass]
  7. public class UnitTest1
  8. {
  9. #region Простые
  10. [TestMethod]
  11. public void ResultEqualCorrect()
  12. {
  13. Assert.AreEqual(114147,Calculation.GetQuantityForProduct(3,1,15,20,45));
  14. }
  15. [TestMethod]
  16. public void ResultEqualNotCorrect()
  17. {
  18. Assert.AreNotEqual(114148, Calculation.GetQuantityForProduct(3, 1, 20, 21, 46));
  19. }
  20. [TestMethod]
  21. public void ResultIsNotNull()
  22. {
  23. Assert.IsNotNull(Calculation.GetQuantityForProduct(3, 1, 15, 45, 13));
  24. }
  25. [TestMethod]
  26. public void BadResultProductEqualCorrect()
  27. {
  28. Assert.AreEqual(-1, Calculation.GetQuantityForProduct(4, 1, 20, 21, 46));
  29. }
  30. [TestMethod]
  31. public void BadResultMaterialEqualCorrect()
  32. {
  33. Assert.AreEqual(-1, Calculation.GetQuantityForProduct(3, 5, 20, 21, 46));
  34. }
  35. [TestMethod]
  36. public void IsCorrectType()
  37. {
  38. Assert.IsInstanceOfType(Calculation.GetQuantityForProduct(3, 5, 20, 21, 46), typeof(int));
  39. }
  40. [TestMethod]
  41. public void IsIncorrectType()
  42. {
  43. Assert.IsNotInstanceOfType(Calculation.GetQuantityForProduct(3, 5, 20, 21, 46), typeof(double));
  44. }
  45. [TestMethod]
  46. public void ResultNotEqualIncorrect()
  47. {
  48. Assert.AreNotEqual(-1, Calculation.GetQuantityForProduct(3, 1, 20, 21, 46));
  49. }
  50. [TestMethod]
  51. public void ResultEqualIncorrect()
  52. {
  53. Assert.AreEqual(-1, Calculation.GetQuantityForProduct(4, 4, 20, 21, 46));
  54. }
  55. [TestMethod]
  56. public void BadResultIsType()
  57. {
  58. Assert.IsInstanceOfType(Calculation.GetQuantityForProduct(4, 4, 20, 21, 46), typeof(int));
  59. }
  60. #endregion
  61. #region Сложные
  62. [TestMethod]
  63. public void ThrowThirdArgException()
  64. {
  65. Assert.ThrowsException<ArgumentException>(()=>Calculation.GetQuantityForProduct(1, 1, -1, 1, 1));
  66. }
  67. [TestMethod]
  68. public void ThrowFourthArgException()
  69. {
  70. Assert.ThrowsException<ArgumentException>(() => Calculation.GetQuantityForProduct(1, 1, 1, -1, 1));
  71. }
  72. [TestMethod]
  73. public void ThrowFifthArgException()
  74. {
  75. Assert.ThrowsException<ArgumentException>(() => Calculation.GetQuantityForProduct(1, 1, 1, 1, -11));
  76. }
  77. [TestMethod]
  78. public void ThrowTwoArgException()
  79. {
  80. Assert.ThrowsException<ArgumentException>(() => Calculation.GetQuantityForProduct(1, 1, 1, -1, -11));
  81. }
  82. [TestMethod]
  83. public void ThrowThreeArgException()
  84. {
  85. Assert.ThrowsException<ArgumentException>(() => Calculation.GetQuantityForProduct(1, 1, -1, -1, -11));
  86. }
  87. #endregion
  88. }
  89. }