UnitTest1.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using Kusach;
  4. namespace UnitTests
  5. {
  6. [TestClass]
  7. public class UnitTest1
  8. {
  9. [TestMethod]
  10. public void IsValidPhoneNumber()
  11. {
  12. string phoneNum = "9999194949";
  13. Assert.IsTrue(Functions.IsValidPhoneNumber(phoneNum));
  14. }
  15. [TestMethod]
  16. public void IsValidEmail()
  17. {
  18. string email = "lalka@gmail.com";
  19. Assert.IsTrue(Functions.IsValidEmail(email));
  20. }
  21. [TestMethod]
  22. public void PasswordEncryptTest()
  23. {
  24. string password = "lalka";
  25. string expected = "55B6F08EFCE1438F38323E02C7C451FBD1E1AA12";
  26. Assert.AreEqual(Encrypt.GetHash(password), expected);
  27. }
  28. [TestMethod]
  29. public void LoginTest()
  30. {
  31. string login = "qq";
  32. string password = "qq";
  33. Assert.IsTrue(Functions.LoginCheck(login, password));
  34. }
  35. [TestMethod]
  36. public void IsValidLoginAndPassword()
  37. {
  38. Assert.IsTrue(Functions.IsValidLogAndPass("qq", "ww"));
  39. Assert.IsTrue(Functions.IsValidLogAndPass("laq", "wwadsw"));
  40. Assert.IsFalse(Functions.IsValidLogAndPass("", ""));
  41. Assert.IsFalse(Functions.IsValidLogAndPass("", "SimplePass"));
  42. Assert.IsFalse(Functions.IsValidLogAndPass("SimpleLogin", ""));
  43. }
  44. [TestMethod]
  45. public void IsLoginAlreadyTaken()
  46. {
  47. Assert.IsTrue(Functions.IsLoginAlreadyTaken("qq"));
  48. }
  49. [TestMethod]
  50. public void GetNameOfTransportUsingId()
  51. {
  52. int transportId = 1;
  53. string expected = "Avtobus";
  54. Assert.AreEqual(Functions.GetNameOfTransport(transportId), expected);
  55. }
  56. [TestMethod]
  57. public void GetNumberPlateUsingId()
  58. {
  59. int transportId = 1;
  60. string expected = "AA333AA78";
  61. Assert.AreEqual(Functions.GetNumberPlate(transportId), expected);
  62. }
  63. [TestMethod]
  64. public void GetRouteNameUsingId()
  65. {
  66. int routeId = 1;
  67. string expected = "Маршрут #1";
  68. Assert.AreEqual(Functions.GetRouteName(routeId), expected);
  69. }
  70. [TestMethod]
  71. public void GetNameOfPointUsingId()
  72. {
  73. int pointId = 1;
  74. string expected = "Томская";
  75. Assert.AreEqual(Functions.GetNameOfPoint(pointId), expected);
  76. }
  77. [TestMethod]
  78. public void GetLocationOfPointUsingId()
  79. {
  80. int pointId = 1;
  81. string expected = "Томская, 21";
  82. Assert.AreEqual(Functions.GetLocationOfPoint(pointId), expected);
  83. }
  84. [TestMethod]
  85. public void IsValidNameAndLocationOfPoint()
  86. {
  87. string Name = "Томская";
  88. string Location = "Томская, 21";
  89. Assert.IsTrue(Functions.IsValidNameAndLocationOfPoint(Name, Location));
  90. }
  91. [TestMethod]
  92. public void IsValidInfoAboutDriver()
  93. {
  94. string IdTransport = "1";
  95. string name = "Петр";
  96. string surname = "Некрасов";
  97. string patronymic = "Антонович";
  98. Assert.IsTrue(Functions.IsValidInfoAboutDriver(IdTransport, name, surname, patronymic));
  99. }
  100. [TestMethod]
  101. public void IsIdOnlyDigits()
  102. {
  103. string IdTransport = "123";
  104. Assert.IsTrue(Functions.IsOnlyDigits(IdTransport));
  105. }
  106. }
  107. }