UnitTest.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using MathModelingSimulator.Function;
  2. namespace UnitTestsSimMM
  3. {
  4. [TestClass]
  5. public class UnitTest
  6. {
  7. [TestMethod]
  8. public void GetHashPassword_Password11_Hashreturned()
  9. {
  10. string password = "11";
  11. string expected = "BrbeSdYMT//FOJwkU1AXSjKfOwkhepBWTx+P/IgBqRA=";
  12. Security obj = new Security();
  13. string result = obj.GetHashPassword(password);
  14. Assert.AreEqual(expected, result);
  15. }
  16. [TestMethod]
  17. public void GetMinSimplexMetod_Matrix_Expected15()
  18. {
  19. int[,] matrix = { { 0, 1, 2, 3, 4, 5, 6, 7 }, { 4, 2, -1, 1, 1, 0, 0, 1 }, { 5, -4, 2, -1, 0, 1, 0, 2 }, { 6, 3, 0, 1, 0, 0, 1, 5 }, { 0, -1, 1, 3, 0, 0, 0, 0 } };
  20. int expected = -15;
  21. SimplexMetod obj = new SimplexMetod();
  22. int result = obj.MainSimplexMetod(matrix, false);
  23. Assert.AreEqual(expected, result);
  24. }
  25. [TestMethod]
  26. public void GetTravelingSalesmanProblem_Matrix_Expected41()
  27. {
  28. int[,] matrix = { { 0, 20,18,12,8}, {5,0,14,7,11},{12,18,0,6,11},{11,17,11,0,12},{5,5,5,5,0}};
  29. int expected = 41;
  30. TravelingSalesmanProblem obj = new TravelingSalesmanProblem();
  31. int result = obj.MainTravelingSalesmanProblem(matrix);
  32. Assert.AreEqual(expected, result);
  33. }
  34. [TestMethod]
  35. public void GetMaxSimplexMetod_Matrix_Expected11()
  36. {
  37. int[,] matrix = { { 0,1,2,3,4,5,6 }, { 3,1,2,1,0,0,4 }, { 4,1,1,0,1,0,3 }, {5,2,1,0,0,1,8 }, {0,-3,-4,0,0,0,0} };
  38. int expected = 11;
  39. SimplexMetod obj = new SimplexMetod();
  40. int result = obj.MainSimplexMetod(matrix, true);
  41. Assert.AreEqual(expected, result);
  42. }
  43. [TestMethod]
  44. public void GetRegularTelephone_Telephone_ExpectedTrue()
  45. {
  46. string Telephone = "+7 985 678 23 43";
  47. bool expected = true;
  48. Regular obj = new Regular();
  49. (bool isTrueField, string message) result = obj.GetRegularTelephone(Telephone);
  50. Assert.AreEqual(expected, result.isTrueField);
  51. }
  52. [TestMethod]
  53. public void GetRegularTelephone_Telephone_ExpectedFalse()
  54. {
  55. string Telephone = "999 999 99 99";
  56. bool expected = false;
  57. Regular obj = new Regular();
  58. (bool isTrueField, string message) result = obj.GetRegularTelephone(Telephone);
  59. Assert.AreEqual(expected, result.isTrueField);
  60. }
  61. [TestMethod]
  62. public void GetRegularPassword_Password123_ExpectedFalse()
  63. {
  64. string Password = "123";
  65. bool expected = false;
  66. Regular obj = new Regular();
  67. (bool isTrueField, string message) result = obj.GetRegularPassword(Password);
  68. Assert.AreEqual(expected, result.isTrueField);
  69. }
  70. [TestMethod]
  71. public void GetRegularPassword_PasswordAbcd1234_ExpectedTrue()
  72. {
  73. string Password = "Abcd1234";
  74. bool expected = true;
  75. Regular obj = new Regular();
  76. (bool isTrueField, string message) result = obj.GetRegularPassword(Password);
  77. Assert.AreEqual(expected, result.isTrueField);
  78. }
  79. [TestMethod]
  80. public void GetRegularSurname_Surname_ExpectedTrue()
  81. {
  82. string Surname = "Àáðàìîâà";
  83. bool expected = true;
  84. Regular obj = new Regular();
  85. (bool isTrueField, string message) result = obj.GetRegularSurname(Surname);
  86. Assert.AreEqual(expected, result.isTrueField);
  87. }
  88. [TestMethod]
  89. public void GetRegularSurname_Surname_ExpectedFalse()
  90. {
  91. string Surname = "Abramova";
  92. bool expected = false;
  93. Regular obj = new Regular();
  94. (bool isTrueField, string message) result = obj.GetRegularSurname(Surname);
  95. Assert.AreEqual(expected, result.isTrueField);
  96. }
  97. [TestMethod]
  98. public void GetRegularName_Name_ExpectedTrue()
  99. {
  100. string Name = "Åâãåíèÿ";
  101. bool expected = true;
  102. Regular obj = new Regular();
  103. (bool isTrueField, string message) result = obj.GetRegularName(Name);
  104. Assert.AreEqual(expected, result.isTrueField);
  105. }
  106. [TestMethod]
  107. public void GetRegularName_Surname_ExpectedFalse()
  108. {
  109. string Name = "Evgenia";
  110. bool expected = false;
  111. Regular obj = new Regular();
  112. (bool isTrueField, string message) result = obj.GetRegularName(Name);
  113. Assert.AreEqual(expected, result.isTrueField);
  114. }
  115. [TestMethod]
  116. public void GetRegularEmail_Email_ExpectedTrue()
  117. {
  118. string Email = "abcd@mail.ru";
  119. bool expected = true;
  120. Regular obj = new Regular();
  121. (bool isTrueField, string message) result = obj.GetRegularEmail(Email);
  122. Assert.AreEqual(expected, result.isTrueField);
  123. }
  124. [TestMethod]
  125. public void GetRegularEmail_Email_ExpectedFalse()
  126. {
  127. string Email = "1@mail";
  128. bool expected = false;
  129. Regular obj = new Regular();
  130. (bool isTrueField, string message) result = obj.GetRegularEmail(Email);
  131. Assert.AreEqual(expected, result.isTrueField);
  132. }
  133. }
  134. }