Imagara 2 jaren geleden
bovenliggende
commit
bf67ea142f

+ 3 - 3
RaspisKusach/Functions.cs

@@ -123,10 +123,10 @@ namespace RaspisKusach
             for (int i = 0;i<str.Length;i++)
                 if (!char.IsDigit(str[i]) && i != 2)
                     return false;
-            if(str[3] != ' ' || str[3] != ':')
+            if (str[2] != ' ' && str[2] != ':')
                 return false;
-            if (Convert.ToInt32(str[0] * 10) + Convert.ToInt32(str[1]) > 24 ||
-                Convert.ToInt32(str[3] * 10) + Convert.ToInt32(str[4]) > 59)
+            if ((Convert.ToInt32(str[0].ToString()) * 10) + Convert.ToInt32(str[1].ToString()) > 23 ||
+                (Convert.ToInt32(str[3].ToString()) * 10) + Convert.ToInt32(str[4].ToString()) > 59)
                 return false;
             return true;
         }

+ 1 - 7
RaspisKusach/MainWindow.xaml

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

+ 1 - 4
RaspisKusach/MainWindow.xaml.cs

@@ -1,6 +1,6 @@
 using System.Windows;
-using System.Linq;
 using System.Windows.Input;
+using System;
 
 namespace RaspisKusach
 {
@@ -9,9 +9,6 @@ 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)
         {

+ 3 - 0
UnitTestProject/App.config

@@ -10,4 +10,7 @@
       <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
     </providers>
   </entityFramework>
+	<connectionStrings>
+		<add name="RouteScheduleDataBaseEntities" connectionString="metadata=res://*/EDM.csdl|res://*/EDM.ssdl|res://*/EDM.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=(localdb)\MSSQLLocalDB;initial catalog=RouteScheduleDataBase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+	</connectionStrings>
 </configuration>

+ 6 - 7
UnitTestProject/UnitTest1.cs

@@ -22,15 +22,14 @@ namespace UnitTestProject
         [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);
+            DateTime expected1 = new DateTime(2022, 08, 23, 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);
+            DateTime expected2 = new DateTime(2022, 08, 23, 5, 00, 00);
             Assert.AreEqual(Functions.GetArrivalTime(station2, trip2), expected2);
         }
         [TestMethod]
@@ -39,12 +38,12 @@ namespace UnitTestProject
 
             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);
+            DateTime expected1 = new DateTime(2022, 08, 23, 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);
+            DateTime expected2 = new DateTime(2022, 08, 23, 5, 20, 00);
             Assert.AreEqual(Functions.GetDepartureTime(station2, trip2), expected2);
         }
         [TestMethod]
@@ -113,8 +112,8 @@ namespace UnitTestProject
             string str2 = "123";
             Assert.IsFalse(Functions.IsOnlyDigitsAndLengthCorrect(str2, 5));
 
-            string str3 = "12323523";
-            Assert.IsTrue(Functions.IsOnlyDigitsAndLengthCorrect(str3, 5));
+            string str3 = "123123123";
+            Assert.IsTrue(Functions.IsOnlyDigitsAndLengthCorrect(str3, 9));
         }
         [TestMethod]
         public void IsOnlyDigitsTest()