UnitTest.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using REG_MARK_LIB;
  4. namespace REG_MARK_TEST
  5. {
  6. [TestClass]
  7. public class UnitTest
  8. {
  9. [TestMethod]
  10. public void CheckMark_CorrectMark_True()
  11. {
  12. string mark = "a001aa52";
  13. bool result = RegMark.CheckMark(mark);
  14. Assert.IsTrue(result);
  15. }
  16. [TestMethod]
  17. public void CheckMark_UNCorrectMark_False()
  18. {
  19. string mark = "a001aa";
  20. bool result = RegMark.CheckMark(mark);
  21. Assert.IsFalse(result);
  22. }
  23. [TestMethod]
  24. public void GetNextMarkAfter_NextMark_Equel()
  25. {
  26. string mark = "x999ax52";
  27. string expected = "x001bx52";
  28. string result = RegMark.GetNextMarkAfter(mark);
  29. Assert.AreEqual(expected, result);
  30. }
  31. [TestMethod]
  32. public void GetNextMarkAfter_NextMark_NotEquel()
  33. {
  34. string mark = "x998bx52";
  35. string expected = "x001bx52";
  36. string result = RegMark.GetNextMarkAfter(mark);
  37. Assert.AreNotEqual(expected, result);
  38. }
  39. [TestMethod]
  40. public void GetCombinationsCountInRange_1001Range_IsTrue()
  41. {
  42. int expected = 1001;
  43. int result = RegMark.GetCombinationsCountInRange("a001aa52","b001aa52");
  44. Assert.IsTrue(expected == result);
  45. }
  46. [TestMethod]
  47. public void GetCombinationsCountInRange_ZeroRange_IsTrue()
  48. {
  49. int expected = 1;
  50. int result = RegMark.GetCombinationsCountInRange("a001aa52", "a001aa52");
  51. Assert.IsTrue(expected == result);
  52. }
  53. [TestMethod]
  54. public void GetNextMarkAfterInRange_ZeroRange_IsTrue()
  55. {
  56. string expected = "out of stock";
  57. string result = RegMark.GetNextMarkAfterInRange("a555xx52", "a545xx52", "a550xx52");
  58. Assert.IsTrue(result == expected);
  59. }
  60. [TestMethod]
  61. public void GetNextMarkAfterInRange_NextPrevMark_IsTrue()
  62. {
  63. string expected = "a556xx52";
  64. string result = RegMark.GetNextMarkAfterInRange("a555xx52", "a545xx52", "a570xx52");
  65. Assert.IsTrue(result == expected);
  66. }
  67. [TestMethod]
  68. public void GetNextMarkAfterInRange_NextRangeMark_IsTrue()
  69. {
  70. string expected = "a545xx52";
  71. string result = RegMark.GetNextMarkAfterInRange("a530xx52", "a545xx52", "a570xx52");
  72. Assert.IsTrue(result == expected);
  73. }
  74. [TestMethod]
  75. public void GetNextMarkAfterInRange_TypeIsString()
  76. {
  77. Assert.IsInstanceOfType(RegMark.GetNextMarkAfterInRange("a530xa52", "a545xx52", "a570xx52"), typeof(string));
  78. }
  79. [TestMethod]
  80. public void GetNextMarkAfter_LastNextNumber()
  81. {
  82. Assert.ThrowsException<System.Exception>(() => RegMark.GetNextMarkAfter("x999xx72"));
  83. }
  84. [TestMethod]
  85. public void GetNextMarkAfterInRange_UNCorrectRange()
  86. {
  87. Assert.ThrowsException<System.Exception>(() => RegMark.GetNextMarkAfterInRange("a909aa72", "a999aa72", "a009aa72"));
  88. }
  89. [TestMethod]
  90. public void GetCombinationsCountInRange_UNCorrectRange()
  91. {
  92. Assert.ThrowsException<System.Exception>(() => RegMark.GetCombinationsCountInRange("a999aa72", "a909aa72"));
  93. }
  94. [TestMethod]
  95. public void GetCombinationsCountInRange_UNCorrectMark()
  96. {
  97. Assert.ThrowsException<System.Exception>(() => RegMark.GetCombinationsCountInRange("a909al72", "a909ka72"));
  98. }
  99. [TestMethod]
  100. public void GetNextMarkAfter_UNCorrectMark()
  101. {
  102. Assert.ThrowsException<System.Exception>(() => RegMark.GetNextMarkAfter("a909al72"));
  103. }
  104. }
  105. }