Imagara 2 年 前
コミット
051481bb40

+ 6 - 0
RaspisKusach.sln

@@ -5,6 +5,8 @@ VisualStudioVersion = 16.0.31911.196
 MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RaspisKusach", "RaspisKusach\RaspisKusach.csproj", "{2CCDB4F0-6D9E-42A0-8346-C91B96E793B4}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTestProject", "UnitTestProject\UnitTestProject.csproj", "{0FDBEAF4-52FA-4A28-A8D9-C2B1437CEF76}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
 		{2CCDB4F0-6D9E-42A0-8346-C91B96E793B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{2CCDB4F0-6D9E-42A0-8346-C91B96E793B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{2CCDB4F0-6D9E-42A0-8346-C91B96E793B4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{0FDBEAF4-52FA-4A28-A8D9-C2B1437CEF76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0FDBEAF4-52FA-4A28-A8D9-C2B1437CEF76}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0FDBEAF4-52FA-4A28-A8D9-C2B1437CEF76}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0FDBEAF4-52FA-4A28-A8D9-C2B1437CEF76}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 14 - 11
RaspisKusach/Functions.cs

@@ -42,12 +42,12 @@ namespace RaspisKusach
         // Получение станции отправления (первой)
         public static string GetDepartureStationLocation(Routes route)
         {
-            return cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute).OrderByDescending(item => item.IdRouteStation).Select(item => item.Stations.Location).FirstOrDefault();
+            return cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute).Select(item => item.Stations.Location).FirstOrDefault();
         }
         // Получение станции прибытия (последней)
         public static string GetArrivalStationLocation(Routes route)
         {
-            return cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute).Select(item => item.Stations.Location).FirstOrDefault();
+            return cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute).OrderByDescending(item => item.IdRouteStation).Select(item => item.Stations.Location).FirstOrDefault();
         }
         // Получение количества свободных мест в вагоне
         public static int GetCountAvailableSeats(Carriages carriage)
@@ -116,15 +116,18 @@ namespace RaspisKusach
         }
 
         // Проверка формата ввода TimeSpan из строки
-        public static bool IsHHMMTimeSpanFromString(string str)
+        public static bool IsHHMMTimeSpanFromStringCorrect(string str)
         {
-            for(int i = 0;i<str.Length;i++)
+            if (str.Length != 5)
+                return false;
+            for (int i = 0;i<str.Length;i++)
                 if (!char.IsDigit(str[i]) && i != 2)
                     return false;
-            if(str.Length != 5)
-                return false;
             if(str[3] != ' ' || str[3] != ':')
                 return false;
+            if (Convert.ToInt32(str[0] * 10) + Convert.ToInt32(str[1]) > 24 ||
+                Convert.ToInt32(str[3] * 10) + Convert.ToInt32(str[4]) > 59)
+                return false;
             return true;
         }
 
@@ -141,10 +144,10 @@ namespace RaspisKusach
         // Валидация логина и пароля при входе
         public static bool IsLogAndPassCorrect(string login, string password)
         {
-            return login != "" && password != "";
+            return login.Trim() != "" && password.Trim() != "";
         }
         // Валидация логина и пароля
-        public static bool IsLogEqualPass(string login, string password)
+        public static bool IsLogNotEqualPass(string login, string password)
         {
             return login != password;
         }
@@ -166,14 +169,14 @@ namespace RaspisKusach
         // Преобразует из "string" в "String"
         public static string ToUlower(string str)
         {
-            return str.Substring(0, 1).ToUpper() + str.Substring(1, str.Length);
+            return str.Substring(0, 1).ToUpper() + str.Substring(1, str.Length-1);
         }
         // Получение всех станций в маршруте в виде строки
-        public static string GetDirection(Routes route)
+        public static string GetAllStations(Routes route)
         {
             string stationsList = "";
             foreach (RoutesStations rs in cnt.db.RoutesStations.Where(item => item.IdRoute == route.IdRoute))
-                stationsList += rs.Stations.Location == GetDepartureStationLocation(route) ? rs.Stations.Name : $"{rs.Stations.Name} → ";
+                stationsList += rs.Stations.Location == GetArrivalStationLocation(route) ? rs.Stations.Name : $"{rs.Stations.Name} → ";
             return stationsList;
         }
 

+ 7 - 1
RaspisKusach/MainWindow.xaml

@@ -70,7 +70,13 @@
         <Frame Name="MainFrame"
                Grid.Row="1"
                NavigationUIVisibility="Hidden" 
-               Source="/Pages/MenuPage.xaml">
+               Source="/Pages/MenuPage.xaml"
+               Visibility="Collapsed">
         </Frame>
+        <TextBox Name="temp"
+                 Grid.Row="1"
+                 Visibility="Visible">
+            
+        </TextBox>
     </Grid>
 </Window>

+ 3 - 0
RaspisKusach/MainWindow.xaml.cs

@@ -9,6 +9,9 @@ namespace RaspisKusach
         public MainWindow()
         {
             InitializeComponent();
+            //test
+            Routes route = cnt.db.Routes.Where(item => item.IdRoute == 1).FirstOrDefault();
+            temp.Text = Functions.GetAllStations(route).ToString();
         }
         private void Border_MouseDown(object sender, MouseButtonEventArgs e)
         {

+ 2 - 12
RaspisKusach/Pages/AdministrationPage.xaml.cs

@@ -1,18 +1,8 @@
 using System;
-using System.Collections.Generic;
-using System.Data.Entity;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
 using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
 
 namespace RaspisKusach.Pages
 {
@@ -146,12 +136,12 @@ namespace RaspisKusach.Pages
                     return;
                 }
 
-                if(Functions.IsHHMMTimeSpanFromString(RoutesStationsStopTimeBox.Text))
+                if(Functions.IsHHMMTimeSpanFromStringCorrect(RoutesStationsStopTimeBox.Text))
                 {
                     new ErrorWindow("Строка с временем остановки имела неверный формат").ShowDialog();
                     return;
                 }
-                if(Functions.IsHHMMTimeSpanFromString(RoutesStationsTravelTimeBox.Text))
+                if(Functions.IsHHMMTimeSpanFromStringCorrect(RoutesStationsTravelTimeBox.Text))
                 {
                     new ErrorWindow("Строка с временем пути имела неверный формат").ShowDialog();
                     return;

+ 22 - 9
RaspisKusach/Pages/RegisterPage.xaml.cs

@@ -21,6 +21,7 @@ namespace RaspisKusach.Pages
         private void RegisterButton_Click(object sender, RoutedEventArgs e)
         {
             string[] fio = new string[3];
+            fio = FIOBox.Text.Split(' ');
 
             switch (registerStage)
             {
@@ -29,7 +30,7 @@ namespace RaspisKusach.Pages
                         new ErrorWindow("Поле «Логин» должно содержать не менее 5 символов.").Show();
                     else if (!Functions.IsMinLengthCorrect(PassBox.Password, 5))
                         new ErrorWindow("Поле «Пароль» должно содержать не менее 5 символов.").Show();
-                    else if (!Functions.IsLogEqualPass(LogBox.Text, PassBox.Password))
+                    else if (!Functions.IsLogNotEqualPass(LogBox.Text, PassBox.Password))
                         new ErrorWindow("Поля «Логин» и «Пароль» не должны быть равны.").Show();
                     else if (Functions.IsLoginAlreadyTaken(LogBox.Text))
                         new ErrorWindow("Данный логин уже занят").Show();
@@ -42,7 +43,6 @@ namespace RaspisKusach.Pages
                     }
                     break;
                 case 2:
-                    fio = FIOBox.Text.Split(' ');
                     if (!Functions.IsEmailCorrect(EmailBox.Text))
                         new ErrorWindow("Email введен неверно.").Show();
                     else if (Functions.IsEmailAlreadyTaken(EmailBox.Text))
@@ -62,35 +62,48 @@ namespace RaspisKusach.Pages
                     break;
                 case 3:
                     if (!Functions.IsOnlyDigitsAndLengthCorrect(PhoneBox.Text, 11))
-                        new ErrorWindow("Номер телефона введен неверно.").Show();
-                    else if (!Functions.IsPhoneNumberAlreadyTaken(PhoneBox.Text))
+                        new ErrorWindow("Номер телефона введен неверно. Номер должен содержать 11 символов").Show();
+                    else if (Functions.IsPhoneNumberAlreadyTaken(PhoneBox.Text))
                         new ErrorWindow("Номер телефона уже используется.").Show();
-                    else if (!Functions.IsOnlyDigitsAndLengthCorrect(PassportBox.Text, 10))
+                    else if (!Functions.IsOnlyDigitsAndLengthCorrect(PassportBox.Text.Trim(), 10))
                         new ErrorWindow("Паспорт введен неверно.").Show();
                     else
                     {
+                            new ErrorWindow($"{cnt.db.Users.Select(p => p.IdUser).DefaultIfEmpty(0).Max() + 1}\n" +
+                                $"{LogBox.Text}\n" +
+                                $"{PassportBox.Text.Trim()}\n" +
+                                $"{Encrypt.GetHash(PassBox.Password)}\n" +
+                                $"{Functions.ToUlower(fio[0])}\n" +
+                                $"{Functions.ToUlower(fio[1])}\n" +
+                                $"{Functions.ToUlower(fio[2])}\n" +
+                                $"{(cnt.db.Users.Count() == 0 ? 1 : 0)}\n" +
+                                $"{EmailBox.Text}\n" +
+                                $"{PhoneBox.Text}\n").ShowDialog();
                         try
                         {
+                            int userId = cnt.db.Users.Select(p => p.IdUser).DefaultIfEmpty(0).Max() + 1;
                             Users newUser = new Users()
                             {
-                                IdUser = cnt.db.Users.Select(p => p.IdUser).DefaultIfEmpty(0).Max() + 1,
+                                IdUser = userId,
                                 Login = LogBox.Text,
+                                Passport = PassportBox.Text.Trim(),
                                 Password = Encrypt.GetHash(PassBox.Password),
-                                Email = EmailBox.Text,
                                 Surname = Functions.ToUlower(fio[0]),
                                 Name = Functions.ToUlower(fio[1]),
                                 Patronymic = Functions.ToUlower(fio[2]),
                                 Permissions = cnt.db.Users.Count() == 0 ? 1 : 0,
+                                Email = EmailBox.Text,
+                                PhoneNum = PhoneBox.Text
                             };
                             cnt.db.Users.Add(newUser);
                             cnt.db.SaveChanges();
                             new ErrorWindow("Успешная регистрация").ShowDialog();
-                            Session.User = cnt.db.Users.Max();
-                            NavigationService.Navigate(new ProfilePage());
+                            NavigationService.Navigate(new LoginPage());
                         }
                         catch
                         {
                             new ErrorWindow("Ошибка.").ShowDialog();
+                            NavigationService.Navigate(new LoginPage());
                         }
                     }
                     break;

+ 1 - 1
RaspisKusach/Pages/TripInfoPage.xaml.cs

@@ -14,7 +14,7 @@ namespace RaspisKusach.Pages
             InitializeComponent();
             trip = _trip;
 
-            Direction.Content = Functions.GetDirection(trip.Routes);
+            Direction.Content = Functions.GetAllStations(trip.Routes);
 
             CarriageListBox.Items.Clear();
             UpdateCarriagesList();

+ 13 - 0
UnitTestProject/App.config

@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <configSections>
+    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
+    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
+  </configSections>
+  <entityFramework>
+    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
+    <providers>
+      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
+    </providers>
+  </entityFramework>
+</configuration>

+ 20 - 0
UnitTestProject/Properties/AssemblyInfo.cs

@@ -0,0 +1,20 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+[assembly: AssemblyTitle("UnitTestProject")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("UnitTestProject")]
+[assembly: AssemblyCopyright("Copyright ©  2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+[assembly: ComVisible(false)]
+
+[assembly: Guid("0fdbeaf4-52fa-4a28-a8d9-c2b1437cef76")]
+
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 262 - 0
UnitTestProject/UnitTest1.cs

@@ -0,0 +1,262 @@
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using System;
+using System.Linq;
+using RaspisKusach;
+
+namespace UnitTestProject
+{
+    [TestClass]
+    public class UnitTest1
+    {
+        [TestMethod]
+        public void GetRouteDirectionTest()
+        {
+            Trips trip1 = cnt.db.Trips.Where(item => item.IdTrip == 1).FirstOrDefault();
+            string expected1 = "TOMSK - OMSK";
+            Assert.AreEqual(Functions.GetRouteDirection(trip1), expected1);
+
+            Trips trip2 = cnt.db.Trips.Where(item => item.IdTrip == 2).FirstOrDefault();
+            string expected2 = "Novosibirsk - Anapa";
+            Assert.AreEqual(Functions.GetRouteDirection(trip2), expected2);
+        }
+        [TestMethod]
+        public void GetArrivalTimeTest()
+        {
+
+            Trips trip1 = cnt.db.Trips.Where(item => item.IdTrip == 1).FirstOrDefault();
+            Stations station1 = cnt.db.Stations.Where(item => item.IdStation == 1).FirstOrDefault();
+            DateTime expected1 = new DateTime(23, 08, 2022, 0, 0, 0);
+            Assert.AreEqual(Functions.GetArrivalTime(station1, trip1), expected1);
+
+            Trips trip2 = cnt.db.Trips.Where(item => item.IdTrip == 2).FirstOrDefault();
+            Stations station2 = cnt.db.Stations.Where(item => item.IdStation == 5).FirstOrDefault();
+            DateTime expected2 = new DateTime(23, 08, 2022, 5, 00, 00);
+            Assert.AreEqual(Functions.GetArrivalTime(station2, trip2), expected2);
+        }
+        [TestMethod]
+        public void GetDepartureTimeTest()
+        {
+
+            Trips trip1 = cnt.db.Trips.Where(item => item.IdTrip == 1).FirstOrDefault();
+            Stations station1 = cnt.db.Stations.Where(item => item.IdStation == 1).FirstOrDefault();
+            DateTime expected1 = new DateTime(23, 08, 2022, 0, 30, 0);
+            Assert.AreEqual(Functions.GetDepartureTime(station1, trip1), expected1);
+
+            Trips trip2 = cnt.db.Trips.Where(item => item.IdTrip == 2).FirstOrDefault();
+            Stations station2 = cnt.db.Stations.Where(item => item.IdStation == 5).FirstOrDefault();
+            DateTime expected2 = new DateTime(23, 08, 2022, 5, 20, 00);
+            Assert.AreEqual(Functions.GetDepartureTime(station2, trip2), expected2);
+        }
+        [TestMethod]
+        public void GetDepartureStationLocationTest()
+        {
+
+            Routes route1 = cnt.db.Routes.Where(item => item.IdRoute == 1).FirstOrDefault();
+            string expected1 = "TOMSK";
+            Assert.AreEqual(Functions.GetDepartureStationLocation(route1), expected1);
+
+            Routes route2 = cnt.db.Routes.Where(item => item.IdRoute == 2).FirstOrDefault();
+            string expected2 = "Novosibirsk";
+            Assert.AreEqual(Functions.GetDepartureStationLocation(route2), expected2);
+        }
+        [TestMethod]
+        public void GetArrivalStationLocationTest()
+        {
+
+            Routes route1 = cnt.db.Routes.Where(item => item.IdRoute == 1).FirstOrDefault();
+            string expected1 = "OMSK";
+            Assert.AreEqual(Functions.GetArrivalStationLocation(route1), expected1);
+
+            Routes route2 = cnt.db.Routes.Where(item => item.IdRoute == 2).FirstOrDefault();
+            string expected2 = "Anapa";
+            Assert.AreEqual(Functions.GetArrivalStationLocation(route2), expected2);
+        }
+        [TestMethod]
+        public void GetCountAvailableSeatsTest()
+        {
+            Carriages carriage1 = cnt.db.Carriages.Where(item => item.IdCarriage == 1).FirstOrDefault();
+            int expected1 = 5;
+            Assert.AreEqual(Functions.GetCountAvailableSeats(carriage1), expected1);
+
+            Carriages carriage2 = cnt.db.Carriages.Where(item => item.IdCarriage == 2).FirstOrDefault();
+            int expected2 = 0;
+            Assert.AreEqual(Functions.GetCountAvailableSeats(carriage2), expected2);
+        }
+        [TestMethod]
+        public void GetAvailableSeatTest()
+        {
+            Carriages carriage1 = cnt.db.Carriages.Where(item => item.IdCarriage == 1).FirstOrDefault();
+            int expected1 = 11;
+            Assert.AreEqual(Functions.GetAvailableSeat(carriage1), expected1);
+
+            Carriages carriage2 = cnt.db.Carriages.Where(item => item.IdCarriage == 2).FirstOrDefault();
+            int expected2 = -1;
+            Assert.AreEqual(Functions.GetAvailableSeat(carriage2), expected2);
+        }
+        [TestMethod]
+        public void GetCarriageNumTest()
+        {
+            Tickets ticket1 = cnt.db.Tickets.Where(item => item.IdTicket == 1).FirstOrDefault();
+            int expected1 = 2;
+            Assert.AreEqual(Functions.GetCarriageNum(ticket1), expected1);
+
+            Tickets ticket2 = cnt.db.Tickets.Where(item => item.IdTicket == 25).FirstOrDefault();
+            int expected2 = 3;
+            Assert.AreEqual(Functions.GetCarriageNum(ticket2), expected2);
+        }
+        [TestMethod]
+        public void IsOnlyDigitsAndLengthCorrectTest()
+        {
+            string str1 = "123asq312as123 321";
+            Assert.IsFalse(Functions.IsOnlyDigitsAndLengthCorrect(str1, 5));
+
+            string str2 = "123";
+            Assert.IsFalse(Functions.IsOnlyDigitsAndLengthCorrect(str2, 5));
+
+            string str3 = "12323523";
+            Assert.IsTrue(Functions.IsOnlyDigitsAndLengthCorrect(str3, 5));
+        }
+        [TestMethod]
+        public void IsOnlyDigitsTest()
+        {
+            string str1 = "123asq312as123 321";
+            Assert.IsFalse(Functions.IsOnlyDigits(str1));
+
+            string str2 = "123";
+            Assert.IsTrue(Functions.IsOnlyDigits(str2));
+
+            string str3 = "12323523";
+            Assert.IsTrue(Functions.IsOnlyDigits(str3));
+        }
+        [TestMethod]
+        public void IsEmailCorrectTest()
+        {
+            string email1 = "imagaragmail.com";
+            Assert.IsFalse(Functions.IsEmailCorrect(email1));
+
+            string email2 = "imagara@gmail";
+            Assert.IsFalse(Functions.IsEmailCorrect(email2));
+
+            string email3 = "imagara@gmail.com";
+            Assert.IsTrue(Functions.IsEmailCorrect(email3));
+        }
+
+        [TestMethod]
+        public void IsHHMMTimeSpanFromStringCorrectTest()
+        {
+            string str1 = "10 2";
+            Assert.IsFalse(Functions.IsHHMMTimeSpanFromStringCorrect(str1));
+
+            string str2 = "10";
+            Assert.IsFalse(Functions.IsHHMMTimeSpanFromStringCorrect(str2));
+
+            string str3 = "10:20";
+            Assert.IsTrue(Functions.IsHHMMTimeSpanFromStringCorrect(str3));
+
+            string str4 = "10 20";
+            Assert.IsTrue(Functions.IsHHMMTimeSpanFromStringCorrect(str4));
+        }
+
+        [TestMethod]
+        public void IsEmailAlreadyTakenTest()
+        {
+            string email1 = "imagara@mail.ru";
+            Assert.IsFalse(Functions.IsEmailAlreadyTaken(email1));
+
+            string email2 = "testmail@gmail.com";
+            Assert.IsFalse(Functions.IsEmailAlreadyTaken(email2));
+
+            string email3 = "imagara@gmail.com";
+            Assert.IsTrue(Functions.IsEmailAlreadyTaken(email3));
+        }
+        [TestMethod]
+        public void IsLogAndPassCorrectTest()
+        {
+            string login1 = " ";
+            string password1 = "Imagara";
+            Assert.IsFalse(Functions.IsLogAndPassCorrect(login1, password1));
+
+            string login2 = "Imagara";
+            string password2 = "";
+            Assert.IsFalse(Functions.IsLogAndPassCorrect(login2, password2));
+
+            string login3 = "Imagara";
+            string password3 = "strongPassword";
+            Assert.IsTrue(Functions.IsLogAndPassCorrect(login3, password3));
+        }
+        [TestMethod]
+        public void IsLogNotEqualPassTest()
+        {
+            string login1 = "Imagara";
+            string password1 = "Imagara";
+            Assert.IsFalse(Functions.IsLogNotEqualPass(login1, password1));
+
+            string login2 = "Imagara";
+            string password2 = "strongPassword";
+            Assert.IsTrue(Functions.IsLogNotEqualPass(login2, password2));
+        }
+        [TestMethod]
+        public void IsMinLengthCorrectTest()
+        {
+            string str1 = "qwe";
+            Assert.IsFalse(Functions.IsMinLengthCorrect(str1, 5));
+
+            string str2 = "";
+            Assert.IsFalse(Functions.IsMinLengthCorrect(str2, 5));
+
+            string str3 = "string";
+            Assert.IsTrue(Functions.IsMinLengthCorrect(str3, 5));
+        }
+        [TestMethod]
+        public void LoginCheckTest()
+        {
+            string login1 = "Imagara";
+            string password1 = "Imagara";
+            Assert.IsFalse(Functions.LoginCheck(login1, password1));
+
+            string login2 = "Imagara";
+            string password2 = "strongPassword";
+            Assert.IsTrue(Functions.LoginCheck(login2, password2));
+        }
+        [TestMethod]
+        public void IsLoginAlreadyTakenTest()
+        {
+            string login1 = "User";
+            Assert.IsFalse(Functions.IsLoginAlreadyTaken(login1));
+
+            string login2 = "Imagara";
+            Assert.IsTrue(Functions.IsLoginAlreadyTaken(login2));
+        }
+        [TestMethod]
+        public void ToUlowerTest()
+        {
+            string str = "артем";
+            string expected = "Артем";
+            Assert.AreEqual(Functions.ToUlower(str), expected);
+        }
+        [TestMethod]
+        public void GetAllStationsTest()
+        {
+            Routes route = cnt.db.Routes.Where(item => item.IdRoute == 1).FirstOrDefault();
+            string expected = "TOMSK-1 → TOMSK-2 → Moscow-1 → Novosibirsk-1 → OMSK";
+            Assert.AreEqual(Functions.GetAllStations(route), expected);
+        }
+        [TestMethod]
+        public void IsPhoneNumberAlreadyTakenTest()
+        {
+            string phoneNumber1 = "89009222950";
+            Assert.IsFalse(Functions.IsPhoneNumberAlreadyTaken(phoneNumber1));
+
+            string phoneNumber2 = "89996194949";
+            Assert.IsTrue(Functions.IsPhoneNumberAlreadyTaken(phoneNumber2));
+        }
+
+        [TestMethod]
+        public void PasswordEncryptTest()
+        {
+            string password = "strongPassword";
+            string expected = "6EBD14D4B3ED346D6AE4CDBD41A30F8D65D58093";
+            Assert.AreEqual(Encrypt.GetHash(password), expected);
+        }
+    }
+}

+ 82 - 0
UnitTestProject/UnitTestProject.csproj

@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{0FDBEAF4-52FA-4A28-A8D9-C2B1437CEF76}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>UnitTestProject</RootNamespace>
+    <AssemblyName>UnitTestProject</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
+    <IsCodedUITest>False</IsCodedUITest>
+    <TestProjectType>UnitTest</TestProjectType>
+    <NuGetPackageImportStamp>
+    </NuGetPackageImportStamp>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
+      <HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.ComponentModel.DataAnnotations" />
+    <Reference Include="System.Core" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="UnitTest1.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\RaspisKusach\RaspisKusach.csproj">
+      <Project>{2ccdb4f0-6d9e-42a0-8346-c91b96e793b4}</Project>
+      <Name>RaspisKusach</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>Данный проект ссылается на пакеты NuGet, отсутствующие на этом компьютере. Используйте восстановление пакетов NuGet, чтобы скачать их.  Дополнительную информацию см. по адресу: http://go.microsoft.com/fwlink/?LinkID=322105. Отсутствует следующий файл: {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
+    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
+  </Target>
+  <Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
+</Project>

+ 7 - 0
UnitTestProject/packages.config

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="EntityFramework" version="6.2.0" targetFramework="net472" />
+  <package id="EntityFramework.ru" version="6.2.0" targetFramework="net472" />
+  <package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net472" />
+  <package id="MSTest.TestFramework" version="2.1.2" targetFramework="net472" />
+</packages>