UnitTest.cs 6.0 KB

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