UnitTest.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using TestSessionLib;
  3. namespace TestProject
  4. {
  5. /*Ãîâîðèëè, ÷òî íóæíî 5 ïðîñòûõ è 5 ñëîæíûõ òåñòîâ*/
  6. [TestClass]
  7. public class UnitTest
  8. {
  9. /*Òåñòû íèçêîé ñëîæíîñòè*/
  10. /// <summary>
  11. /// Ïðîâåðêà, ÷òî ìåòîä CheckMark âîçâðàùàåò true ïðè êîððåêòíîì íîìåðå
  12. /// </summary>
  13. [TestMethod]
  14. public void CheckMark_IsTrue()
  15. {
  16. Assert.IsTrue(REG_MARK_LIB.CheckMark("a999aa052"));
  17. }
  18. /// <summary>
  19. /// Ïðîâåðêà, ÷òî ìåòîä CheckMark âîçâðàùàåò äàííûå ôîðìàòà boolean.
  20. /// </summary>
  21. [TestMethod]
  22. public void CheckMark_IsBoolean()
  23. {
  24. Assert.IsInstanceOfType(REG_MARK_LIB.CheckMark("a999aa052"), typeof(Boolean));
  25. }
  26. /// <summary>
  27. /// Ïðîâåðêà, ÷òî ïðè êîððåêòíûõ äàííûõ ìåòîä GetNextMarkAfter âîçâðàùàåò
  28. /// ïðàâèëüíûé ðåãèñòðàöèîííûé çíàê.
  29. /// </summary>
  30. [TestMethod]
  31. public void NextMarkAfter_AreEqual()
  32. {
  33. Assert.AreEqual(REG_MARK_LIB.GetNextMarkAfter("a125aa052"), "a126aa052");
  34. }
  35. /// <summary>
  36. /// Ïðîâåðêà, ÷òî ïðè êîððåêòíûõ äàííûõ ìåòîä GetNextMarkAfterInRange âîçâðàùàåò
  37. /// ïðàâèëüíûé ðåãèñòðàöèîííûé çíàê.
  38. /// </summary>
  39. [TestMethod]
  40. public void NextMarkAfterInRange_AreEqual()
  41. {
  42. Assert.AreEqual(REG_MARK_LIB.GetNextMarkAfterInRange("a125aa052", "a000aa052", "a999aa052"), "a126aa052");
  43. }
  44. /// <summary>
  45. /// Ïðîâåðêà, ÷òî ïðè êîððåêòíûõ äàííûõ ìåòîä GetCombinationsCountInRange âîçâðàùàåò
  46. /// ïðàâèëüíûé ðåãèñòðàöèîííûé çíàê.
  47. /// </summary>
  48. [TestMethod]
  49. public void CombinationsCountInRange_AreEqual()
  50. {
  51. Assert.AreEqual(REG_MARK_LIB.GetCombinationsCountInRange("a000aa053", "a003aa053"), 4);
  52. }
  53. /*Òåñòû âûñîêîé ñëîæíîñòè*/
  54. /// <summary>
  55. /// Ïðîâåðêà, ÷òî åñëè â ìåòîäå GetNextMarkAfterInRange óêàçàòü äèàïîçîí
  56. /// ðåãèñòðàöèîííûõ çíàêîâ â óáûâàþùåì ïîðÿäêå, âîçíèêàåò èñêëþ÷åíèå.
  57. /// </summary>
  58. [TestMethod]
  59. public void GetNextMarkAfterInRange_RangeNotOrder()
  60. {
  61. Assert.ThrowsException<System.ArgumentException>(() => REG_MARK_LIB.GetNextMarkAfterInRange("à123àà052", "a999aa052", "a000aa052"));
  62. }
  63. /// <summary>
  64. /// Ïðîâåðêà, ÷òî åñëè â ìåòîäå GetCombinationsCountInRange óêàçàòü äèàïîçîí
  65. /// ðåãèñòðàöèîííûõ çíàêîâ â óáûâàþùåì ïîðÿäêå, âîçíèêàåò èñêëþ÷åíèå.
  66. /// </summary>
  67. [TestMethod]
  68. public void CombinationsCountInRange_RangeNotBy()
  69. {
  70. Assert.ThrowsException<System.ArgumentOutOfRangeException>(() => REG_MARK_LIB.GetCombinationsCountInRange("a010aa799", "a003aa799"));
  71. }
  72. /// <summary>
  73. /// Ïðîâåðêà, ÷òî ìåòîä GetNextMarkAfter ïðèíèìàåò òîëüêî âåðíûå ïàðàìåòðû.
  74. /// </summary>
  75. [TestMethod]
  76. public void GetNextMarkAfter_InvalidParametr()
  77. {
  78. Assert.ThrowsException<System.ArgumentException>(() => REG_MARK_LIB.GetNextMarkAfter("a999aa999"));
  79. }
  80. /// <summary>
  81. /// Ïðîâåðêà, ÷òî ìåòîä GetNextMarkAfter ïðèíèìàåò òîëüêî âåðíûå ïàðàìåòðû.
  82. /// </summary>
  83. [TestMethod]
  84. public void GetNextMarkAfterInRange_InvalidParametr()
  85. {
  86. Assert.ThrowsException<System.ArgumentException>(() => REG_MARK_LIB.GetNextMarkAfterInRange("ö123öó052", "a000aa052", "a999aa052"));
  87. }
  88. /// <summary>
  89. /// Ïðîâåðêà, ÷òî ìåòîä GetNextMarkAfter ïðèíèìàåò òîëüêî âåðíûå ïàðàìåòðû.
  90. /// </summary>
  91. [TestMethod]
  92. public void GetCombinationsCountInRange_InvalidParametr()
  93. {
  94. Assert.ThrowsException<System.ArgumentException>(() => REG_MARK_LIB.GetCombinationsCountInRange("12345678", "a003aa053"));
  95. }
  96. }
  97. }