Test.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Курсовой_проект_3._1
  7. {
  8. public static class Test
  9. {
  10. // for test only
  11. public static bool PlayerInfoOutput()
  12. {
  13. MyTeamContext _context = new MyTeamContext();
  14. return true;
  15. }
  16. // for test only
  17. public static bool CreateTeamApp(int teamId, string title, string text)
  18. {
  19. int teamIdWithApp = 1;
  20. if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(text))
  21. {
  22. return false;
  23. }
  24. if (teamId == teamIdWithApp)
  25. {
  26. return false;
  27. }
  28. if (title.Length > 20)
  29. {
  30. return false;
  31. }
  32. if (text.Length > 255)
  33. {
  34. return false;
  35. }
  36. return true;
  37. }
  38. // for test only
  39. public static bool CreatePlayerApp(int userId, string title, string text)
  40. {
  41. int userIdWithApp = 1;
  42. if (string.IsNullOrWhiteSpace(title) || string.IsNullOrWhiteSpace(text))
  43. {
  44. return false;
  45. }
  46. if (userId == userIdWithApp)
  47. {
  48. return false;
  49. }
  50. if (title.Length > 20)
  51. {
  52. return false;
  53. }
  54. if (text.Length > 255)
  55. {
  56. return false;
  57. }
  58. return true;
  59. }
  60. // for test only
  61. public static bool ChangeSettingsTest(int userId, string email, string phoneNumber, string about)
  62. {
  63. phoneNumber = phoneNumber.TrimStart('+');
  64. string existEmail, existPhoneNumber;
  65. existEmail = "nikich4523@mail.ru";
  66. existPhoneNumber = "79641166987";
  67. string nowUserEmail, nowUserPhoneNumber;
  68. nowUserEmail = "alen.20.plo@mail.ru";
  69. nowUserPhoneNumber = "79132818850";
  70. // проверка на корректность введенной почты
  71. if (!string.IsNullOrWhiteSpace(email))
  72. {
  73. if (email != nowUserEmail)
  74. {
  75. if (email != existEmail)
  76. {
  77. if (Func.IsValidEmail(email))
  78. {
  79. //
  80. }
  81. else
  82. {
  83. return false;
  84. }
  85. }
  86. else
  87. {
  88. return false;
  89. }
  90. }
  91. }
  92. else
  93. {
  94. return false;
  95. }
  96. // проверка на корректность введенного номера телефона
  97. if (!string.IsNullOrWhiteSpace(phoneNumber))
  98. {
  99. if (phoneNumber != nowUserPhoneNumber)
  100. {
  101. if (phoneNumber != existPhoneNumber)
  102. {
  103. if (Func.IsValidPhoneNumber(phoneNumber))
  104. {
  105. //
  106. }
  107. else
  108. {
  109. return false;
  110. }
  111. }
  112. else
  113. {
  114. return false;
  115. }
  116. }
  117. }
  118. else
  119. {
  120. return false;
  121. }
  122. return true;
  123. }
  124. // for test only
  125. public static bool AuthorizationTest(string login, string password)
  126. {
  127. if (Func.IsValidLogAndPass(login, password))
  128. {
  129. if (login == "nikich4523" && password == "123qaz")
  130. {
  131. return true;
  132. }
  133. else
  134. {
  135. return false;
  136. }
  137. }
  138. else
  139. {
  140. return false;
  141. }
  142. }
  143. // for test only
  144. public static bool RegistrationTest(string login, string pass, string fname, string lname, string mname, string nickname, string email, string phoneNumber, string birthday)
  145. {
  146. phoneNumber = phoneNumber.TrimStart('+');
  147. string existLogin, existEmail, existPhoneNumber, existNickname;
  148. existLogin = "nikich4523";
  149. existEmail = "nikich4523@mail.ru";
  150. existNickname = "Arxont";
  151. existPhoneNumber = "+79132818850";
  152. // проверка на заполненость всех полей
  153. if (Func.IsNullOrWhiteSpace(new string[] { login, pass, nickname, fname, lname, mname, birthday }))
  154. {
  155. return false;
  156. }
  157. // проверка на уникальность полей
  158. if (login == existLogin || email == existEmail || existNickname == nickname || existPhoneNumber == phoneNumber)
  159. {
  160. return false;
  161. }
  162. // проверка на корректность
  163. if (!Func.IsValidPhoneNumber(phoneNumber))
  164. {
  165. return false;
  166. }
  167. if (!Func.IsValidEmail(email))
  168. {
  169. return false;
  170. }
  171. return true;
  172. }
  173. }
  174. }