UnitTests.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using REG_MARK_LIB;
  2. namespace UnitTests
  3. {
  4. /// <summary>
  5. /// Êëàññ òåñòîâ íèçêîé ñëîæíîñòè
  6. /// </summary>
  7. public class TestsOfLowDifficult
  8. {
  9. // Òåñò ôóíêöèè GetNextMarkAfter, ïðîâåðêà íà èçìåíåíèå ÷èñëà â ñîñòàâå íîìåðà
  10. [Fact]
  11. public void TestGetNextMarkAfterWithCorrectData()
  12. {
  13. Assert.Equal("T357CK42", REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfter("T356CK42"));
  14. }
  15. // Òåñò ôóíêöèè GetNextMarkAfter, ïðîâåðêà íà èçìåíåíèå ïåðâîé áóêâû â ñîñòàâå íîìåðà
  16. [Fact]
  17. public void TestGetNextMarkAfterWithCorrectDataOnFirstLetter()
  18. {
  19. Assert.Equal("Y001OK52", REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfter("T999OK52"));
  20. }
  21. // Òåñò ôóíêöèè CheckMark, ñ ïðàâèëüíûì íîìåðîì
  22. [Fact]
  23. public void TestMarkWithCorrectDataCheck()
  24. {
  25. Assert.True(REG_MARK_LIB.REG_MARK_LIB.CheckMark("a999aa99"));
  26. }
  27. // Òåñò ôóíêöèè GetNextMarkAfterInRange, ïðè èçíà÷àëüíîì íîìåðå íå âõîäÿùåì â äèàïàçîí (áîëüøå)
  28. [Fact]
  29. public void TestGetNextMarkAfterInRangeWithIncorrectDataBiggerThanEnd()
  30. {
  31. Assert.Equal("out of stock", REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfterInRange("X999YX52", "A001AA52", "X999OX52"));
  32. }
  33. // Òåñò ôóíêöèè GetNextMarkAfterInRange, ïðè íåêîððåêòíîì äèàïàçîíå
  34. [Fact]
  35. public void TestGetNextMarkAfterInRangeWithIncorrectDataIncorrectBounds()
  36. {
  37. Assert.Equal("out of stock", REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfterInRange("X999YX52", "X999OX52", "A001AA52"));
  38. }
  39. // Òåñò ôóíêöèè CheckMark, ñ íåïðàâèëüíûì íîìåðîì
  40. [Fact]
  41. public void TestMarkWithIncorrectDataCheckOnSecondNumber()
  42. {
  43. Assert.False(REG_MARK_LIB.REG_MARK_LIB.CheckMark("a999aa999"));
  44. }
  45. // Òåñò ôóíêöèè GetNextMarkAfter, ïðîâåðêà íà èçìåíåíèå òðåòåé áóêâû â ñîñòàâå íîìåðà
  46. [Fact]
  47. public void TestGetNextMarkAfterWithCorrectDataOnThirdLetter()
  48. {
  49. Assert.Equal("A001OM42", REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfter("X999OK42"));
  50. }
  51. // Òåñò ôóíêöèè GetNextMarkAfterInRange, ïðè èçíà÷àëüíîì íîìåðå íå âõîäÿùåì â äèàïàçîí (ìåíüøå)
  52. [Fact]
  53. public void TestGetNextMarkAfterInRangeWithIncorrectDataSmallerThanStart()
  54. {
  55. Assert.Equal("out of stock", REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfterInRange("A003OM42", "X999OX52", "X999XX52"));
  56. }
  57. // Òåñò ôóíêöèè GetCombinationsCountInRange, ñ îáû÷íûìè äàííûìè
  58. [Fact]
  59. public void TestGetCombinationsCountInRangeWithCorrectData()
  60. {
  61. Assert.Equal(2, REG_MARK_LIB.REG_MARK_LIB.GetCombinationsCountInRange("M356OK52", "M357OK52"));
  62. }
  63. // Òåñò ôóíêöèè GetCombinationsCountInRange, ñ ïåðåâåðíóòûìè ãðàíèöàìè
  64. [Fact]
  65. public void TestGetCombinationsCountInRangeWithCorrectDataReverse()
  66. {
  67. Assert.Equal(2, REG_MARK_LIB.REG_MARK_LIB.GetCombinationsCountInRange("M357OK52", "M356OK52"));
  68. }
  69. // Òåñò ôóíêöèè GetCombinationsCountInRange, ñ îäèíàêîâûìè ãðàíèöàìè
  70. [Fact]
  71. public void TestGetCombinationsCountInRangeWithCorrectDataEqualsBounds()
  72. {
  73. Assert.Equal(1, REG_MARK_LIB.REG_MARK_LIB.GetCombinationsCountInRange("M356OK52", "M356OK52"));
  74. }
  75. // Òåñò ôóíêöèè GetNextMarkAfter, ïðîâåðêà íà èçìåíåíèå âòîðîé áóêâû â ñîñòàâå íîìåðà
  76. [Fact]
  77. public void TestGetNextMarkAfterWithCorrectDataOnSecondLetter()
  78. {
  79. Assert.Equal("A001OM42", REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfter("X999OK42"));
  80. }
  81. // Òåñò ôóíêöèè GetNextMarkAfterInRange, ñ êîððåêòíûìè äàííûìè
  82. [Fact]
  83. public void TestGetNextMarkAfterInRangeWithCorrectData()
  84. {
  85. Assert.Equal("A001PA42", REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfterInRange("X999OX42", "A001AA42", "X999XX42"));
  86. }
  87. }
  88. /// <summary>
  89. /// Êëàññ òåñòîâ âûñîêîé ñëîæíîñòè
  90. /// </summary>
  91. public class TestsOfHighDifficult
  92. {
  93. // Òåñò ôóíêöèè CheckMark, ïðè ïåðåäà÷å null
  94. [Fact]
  95. public void TestCheckMarkOnNull()
  96. {
  97. Assert.Throws<ArgumentNullException>(() => REG_MARK_LIB.REG_MARK_LIB.CheckMark(null));
  98. }
  99. // Òåñò ôóíêöèè GetNextMarkAfterInRange, ïðè ïåðåäà÷å íå íîìåðà
  100. [Fact]
  101. public void TestGetNextMarkAfterInRangeOnNotMark()
  102. {
  103. Assert.Throws<ArgumentException>(() => REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfterInRange("Hello world!", "a999aa42", "a999aa42"));
  104. }
  105. // Òåñò ôóíêöèè GetNextMarkAfter, ïðè ïåðåäà÷å íîìåðà, äëÿ êîòîðîãî íåò ñëåäóþùåãî íîìåðà
  106. [Fact]
  107. public void TestGetNextMarkAfterOnNotNextMark()
  108. {
  109. Assert.Throws<Exception>(() => REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfter("x999xx42"));
  110. }
  111. // Òåñò ôóíêöèè GetNextMarkAfter, ïðè ïåðåäà÷å íå íîìåðà
  112. [Fact]
  113. public void TestGetNextMarkAfterOnNotMark()
  114. {
  115. Assert.Throws<ArgumentException>(() => REG_MARK_LIB.REG_MARK_LIB.GetNextMarkAfter("Hello world!"));
  116. }
  117. // Òåñò ôóíêöèè GetCombinationsCountInRange, ïðè ïåðåäà÷å íå íîìåðà
  118. [Fact]
  119. public void TestGetCombinationsCountInRangeOnNotMark()
  120. {
  121. Assert.Throws<ArgumentException>(() => REG_MARK_LIB.REG_MARK_LIB.GetCombinationsCountInRange("Hello world!", "a999aa42"));
  122. }
  123. }
  124. }