Parcourir la source

comments changed to English

Alexandra Schekaleva il y a 5 mois
Parent
commit
c1c306b184

BIN
EducationDepartment/.vs/EducationDepartment/DesignTimeBuild/.dtbcache.v2


BIN
EducationDepartment/.vs/EducationDepartment/FileContentIndex/0945a724-f89c-4e7d-858e-ddb144e191e8.vsidx


BIN
EducationDepartment/.vs/EducationDepartment/FileContentIndex/25b71480-8039-4227-87c8-c39a840190b3.vsidx


BIN
EducationDepartment/.vs/EducationDepartment/v17/.futdcache.v2


BIN
EducationDepartment/.vs/EducationDepartment/v17/.suo


BIN
EducationDepartment/.vs/EducationDepartment/v17/TestStore/0/001.testlog → EducationDepartment/.vs/EducationDepartment/v17/TestStore/0/003.testlog


BIN
EducationDepartment/.vs/EducationDepartment/v17/TestStore/0/testlog.manifest


BIN
EducationDepartment/.vs/ProjectEvaluation/educationdepartment.metadata.v7.bin


BIN
EducationDepartment/.vs/ProjectEvaluation/educationdepartment.projects.v7.bin


+ 73 - 81
EducationDepartment/EducationDepartment.test/UnitTest.cs

@@ -1,6 +1,7 @@
 using EducationDepartament.Views;
 using EducationDepartment.Models;
 using EducationDepartment.ViewModels;
+using Microsoft.EntityFrameworkCore;
 using Moq;
 using UnitTestHelpers;
 
@@ -9,16 +10,14 @@ namespace EducationDepartment.test
     [TestClass]
     public class UnitTest
     {
-        
         [TestMethod]
         public void TestOnPropertyChanged_UpdatesValues()
         {
             // Arrange
-            var dbContextMock = new Mock<Schekaleva31pContext>();
-            var viewModel = new AttendanceViewModel(dbContextMock.Object);
-            bool eventRaised = false;
-
-
+            var dbContextMock = new Mock<Schekaleva31pContext>(); // Creating a mock of the database context
+            var viewModel = new AttendanceViewModel(dbContextMock.Object); // Creating an instance of the AttendanceViewModel
+            bool eventRaised = false; // Flag to track if the PropertyChanged event was raised
+            // Subscribing to the PropertyChanged event to check for changes in the 'Values' property
             viewModel.PropertyChanged += (sender, e) =>
             {
                 if (e.PropertyName == nameof(viewModel.Values))
@@ -26,21 +25,18 @@ namespace EducationDepartment.test
                     eventRaised = true;
                 }
             };
-
             // Act
-            viewModel.SecondSelectedOption = "SomeGroup"; 
-
+            viewModel.SecondSelectedOption = "SomeGroup"; // Triggering a property change
             // Assert
-            Assert.IsTrue(eventRaised);
+            Assert.IsTrue(eventRaised); // Verifying that the PropertyChanged event was raised for the 'Values' property
         }
-
         [TestMethod]
         public void TestAuthorizationViewModel_LoginPropertyChange()
         {
             // Arrange
-            var viewModel = new AuthorizationViewModel();
-            bool eventRaised = false;
-
+            var viewModel = new AuthorizationViewModel(); // Creating an instance of the AuthorizationViewModel
+            bool eventRaised = false; // Flag to track if the PropertyChanged event was raised
+            // Subscribing to the PropertyChanged event to check for changes in the 'Login' property
             viewModel.PropertyChanged += (sender, e) =>
             {
                 if (e.PropertyName == nameof(viewModel.Login))
@@ -48,132 +44,128 @@ namespace EducationDepartment.test
                     eventRaised = true;
                 }
             };
-
             // Act
-            viewModel.Login = "newlogin@example.com";
-
+            viewModel.Login = "newlogin@example.com"; // Triggering a property change
             // Assert
-            Assert.IsTrue(eventRaised);
+            Assert.IsTrue(eventRaised); // Verifying that the PropertyChanged event was raised for the 'Login' property
         }
         [TestMethod]
         public void AttendanceViewModel_GetNewAttendance_SetsCorrectParameterForDisciplineFilter()
         {
             // Arrange
-            var dbConnect = new Schekaleva31pContext(); // Ñîçäàíèå ôåéêîâîãî êîíòåêñòà áàçû äàííûõ
-            var attendanceViewModel = new AttendanceViewModel(dbConnect);
-            attendanceViewModel.SelectedOption = "Äèñöèïëèíà";
-            attendanceViewModel.OptionValue = "Âñå ãðóïïû";
-
+            var dbConnect = new Schekaleva31pContext();  // Creating a mock of the database context
+            var attendanceViewModel = new AttendanceViewModel(dbConnect); // Creating an instance of the AttendanceViewModel
+            attendanceViewModel.SelectedOption = "Äèñöèïëèíà"; // Setting the SelectedOption
+            attendanceViewModel.OptionValue = "Âñå ãðóïïû"; // Setting the OptionValue
             // Act
-            attendanceViewModel.GetNewAttendance();
-
+            attendanceViewModel.GetNewAttendance(); // Invoking the GetNewAttendance method
             // Assert
-            Assert.AreEqual("Ãðóïïû íà äèñöèïëèíå ", attendanceViewModel.ParameterName); // Ïðîâåðÿåì, ÷òî ïàðàìåòð óñòàíîâëåí êàê "Ãðóïïà" äëÿ âûáðàííîé äèñöèïëèíû è âñåõ ãðóïï
+            Assert.AreEqual("Ãðóïïû íà äèñöèïëèíå ", attendanceViewModel.ParameterName); // Verifying that the ParameterName is set correctly
         }
         [TestMethod]
         public void AttendanceViewModel_NewOption_ReturnsCorrectOptionsForGroupFilter()
         {
             // Arrange
-            var dbConnect = new Schekaleva31pContext(); // Ñîçäàíèå ôåéêîâîãî êîíòåêñòà áàçû äàííûõ
-            var attendanceViewModel = new AttendanceViewModel(dbConnect);
-            attendanceViewModel.SelectedOption = "Ãðóïïà";
-
+            var dbConnect = new Schekaleva31pContext();  // Creating a mock of the database context
+            var attendanceViewModel = new AttendanceViewModel(dbConnect); // Creating an instance of the AttendanceViewModel
+            attendanceViewModel.SelectedOption = "Ãðóïïà";// Setting the SelectedOption
             // Act
-            var options = attendanceViewModel.NewOption();
-
+            var options = attendanceViewModel.NewOption(); // Invoking the NewOption method
             // Assert
-            Assert.IsNotNull(options);
-            Assert.IsTrue(options.Count > 0); // Ïðîâåðÿåì, ÷òî ñïèñîê îïöèé íå ïóñòîé
+            Assert.IsNotNull(options); // Verifying that the options are not null
+            Assert.IsTrue(options.Count > 0); // Verifying that the options list has at least one item
         }
         [TestMethod]
         public void TimetableViewModel_NewValues_ForGroup_ReturnsExpectedValues()
         {
             // Arrange
-            var dbContext = new Schekaleva31pContext(); // Ñîçäàíèå ôåéêîâîãî êîíòåêñòà áàçû äàííûõ
-            var timetableViewModel = new TimetableViewModel(dbContext);
-            timetableViewModel.SelectedOption = "Ãðóïïà";
-            var expectedValuesCount = 40; // Çàìåíèòå íà îæèäàåìîå êîëè÷åñòâî çíà÷åíèé äëÿ âûáîðà ãðóïïû
-
+            var dbContext = new Schekaleva31pContext(); // Creating a mock of the database context
+            var timetableViewModel = new TimetableViewModel(dbContext); // Creating an instance of the TimetableViewModel
+            timetableViewModel.SelectedOption = "Ãðóïïà"; // Setting the SelectedOption
+            var expectedValuesCount = 40; // Defining the expected number of values
             // Act
-            var values = timetableViewModel.NewValues("Ãðóïïà");
-
+            var values = timetableViewModel.NewValues("Ãðóïïà"); // Invoking the NewValues method with a specific group
             // Assert
-            Assert.AreEqual(expectedValuesCount, values.Count);
+            Assert.AreEqual(expectedValuesCount, values.Count); // Verifying that the count of values matches the expected count
         }
         [TestMethod]
         public void TimetableViewModel_NewTimetable_ForTeacher_ReturnsExpectedTimetable()
         {
-            // Arrange
-            var dbContext = new Schekaleva31pContext(); // Ñîçäàíèå ôåéêîâîãî êîíòåêñòà áàçû äàííûõ
+            // Arrange: Create a mock object for Schekaleva31pContext
+            var dbContext = new Schekaleva31pContext();
+            // Create an instance of TimetableViewModel with the mock context
             var timetableViewModel = new TimetableViewModel(dbContext);
+            // Set the SelectedOption to "Teacher" (Ïðåïîäàâàòåëü in Russian)
             timetableViewModel.SelectedOption = "Ïðåïîäàâàòåëü";
-            var expectedTimetableCount = 0; // Çàìåíèòå íà îæèäàåìîå êîëè÷åñòâî çàíÿòèé äëÿ âûáðàííîãî ïðåïîäàâàòåëÿ
-            timetableViewModel.OptionValue = "John Doe"; // Çàìåíèòå íà èìÿ ïðåïîäàâàòåëÿ â âàøåé òåñòîâîé áàçå äàííûõ
-
-            // Act
+            // Define the expected count of timetable entries
+            var expectedTimetableCount = 0;
+            // Set the OptionValue to a specific teacher's name
+            timetableViewModel.OptionValue = "John Doe";
+            // Act: Call the NewTimetable method to populate the Timetable property
             timetableViewModel.NewTimetable();
-
-            // Assert
+            // Assert: Verify that the count of timetable entries matches the expected count
             Assert.AreEqual(expectedTimetableCount, timetableViewModel.Timetable?.Count);
         }
         [TestMethod]
         public void DisciplineViewModel_NewValues_ForGroup_ReturnsExpectedValues()
         {
-            // Arrange
-            var dbContext = new Schekaleva31pContext(); // Ñîçäàíèå ôåéêîâîãî êîíòåêñòà áàçû äàííûõ
+            // Arrange: Create a mock object for Schekaleva31pContext
+            var dbContext = new Schekaleva31pContext();
+            // Create an instance of DisciplineViewModel with the mock context
             var disciplineViewModel = new DisciplineViewModel(dbContext);
+            // Set the SelectedOption to "Group" (Ãðóïïà in Russian)
             disciplineViewModel.SelectedOption = "Ãðóïïà";
-            var expectedValuesCount = 40; // Çàìåíèòå íà îæèäàåìîå êîëè÷åñòâî çíà÷åíèé äëÿ âûáîðà ãðóïïû
-
-            // Act
+            // Define the expected count of values
+            var expectedValuesCount = 40;
+            // Act: Call the NewValues method with the "Group" parameter and set the Values property
             disciplineViewModel.Values = disciplineViewModel.NewValues("Ãðóïïà");
-
-            // Assert
+            // Assert: Verify that the count of values matches the expected count
             Assert.AreEqual(expectedValuesCount, disciplineViewModel.Values.Count);
         }
         [TestMethod]
         public void DisciplineViewModel_NewDisciplines_ForTeacher_ReturnsExpectedDisciplines()
         {
-            // Arrange
-            var dbContext = new Schekaleva31pContext(); // Ñîçäàíèå ôåéêîâîãî êîíòåêñòà áàçû äàííûõ
+            // Arrange: Create a mock object for Schekaleva31pContext
+            var dbContext = new Schekaleva31pContext();
+            // Create an instance of DisciplineViewModel with the mock context
             var disciplineViewModel = new DisciplineViewModel(dbContext);
+            // Set the SelectedOption to "Teacher" (Ïðåïîäàâàòåëü in Russian)
             disciplineViewModel.SelectedOption = "Ïðåïîäàâàòåëü";
-            var expectedDisciplinesCount = 0; // Çàìåíèòå íà îæèäàåìîå êîëè÷åñòâî äèñöèïëèí äëÿ âûáðàííîãî ïðåïîäàâàòåëÿ
-            disciplineViewModel.OptionValue = "John Doe"; // Çàìåíèòå íà èìÿ ïðåïîäàâàòåëÿ â âàøåé òåñòîâîé áàçå äàííûõ
-
-            // Act
+            // Define the expected count of disciplines
+            var expectedDisciplinesCount = 0;
+            // Set the OptionValue to a specific teacher's name
+            disciplineViewModel.OptionValue = "John Doe";
+            // Act: Call the NewDisciplines method to populate the Disciplines property
             disciplineViewModel.NewDisciplines();
-
-            // Assert
+            // Assert: Verify that the count of disciplines matches the expected count
             Assert.AreEqual(expectedDisciplinesCount, disciplineViewModel.Disciplines?.Count);
         }
         [TestMethod]
         public void UserProfileViewModel_GetDisciplines_ReturnsExpectedDisciplines()
         {
-            // Arrange
-            var dbContext = new Schekaleva31pContext(); // Ñîçäàíèå ôåéêîâîãî êîíòåêñòà áàçû äàííûõ
-            var userEmail = "alex.ivanov@example.com"; // Çàìåíèòå íà ñóùåñòâóþùèé àäðåñ ýëåêòðîííîé ïî÷òû â âàøåé òåñòîâîé áàçå äàííûõ
-            var expectedDisciplinesCount = 4; // Çàìåíèòå íà îæèäàåìîå êîëè÷åñòâî äèñöèïëèí äëÿ äàííîãî ïîëüçîâàòåëÿ
-
-            // Act
+            // Arrange: Create a mock object for Schekaleva31pContext
+            var dbContext = new Schekaleva31pContext();
+            // Define the email of the user
+            var userEmail = "alex.ivanov@example.com";
+            // Define the expected count of disciplines
+            var expectedDisciplinesCount = 4;
+            // Act: Create an instance of UserProfileViewModel with the mock context and user email
             var userProfileViewModel = new UserProfileViewModel(dbContext, userEmail);
+            // Get the list of disciplines
             var disciplines = userProfileViewModel.Disciplines;
-
-            // Assert
+            // Assert: Verify that the count of disciplines matches the expected count
             Assert.AreEqual(expectedDisciplinesCount, disciplines.Count);
         }
-
         [TestMethod]
         public void UserProfileViewModel_Initialization_UserIsNotNull()
         {
-            // Arrange
-            var dbContext = new Schekaleva31pContext(); // Ñîçäàíèå ôåéêîâîãî êîíòåêñòà áàçû äàííûõ
-            var userEmail = "alex.ivanov@example.com"; // Çàìåíèòå íà ñóùåñòâóþùèé àäðåñ ýëåêòðîííîé ïî÷òû â âàøåé òåñòîâîé áàçå äàííûõ
-
-            // Act
+            // Arrange: Create a mock object for Schekaleva31pContext
+            var dbContext = new Schekaleva31pContext();
+            // Define the email of the user
+            var userEmail = "alex.ivanov@example.com";
+            // Act: Create an instance of UserProfileViewModel with the mock context and user email
             var userProfileViewModel = new UserProfileViewModel(dbContext, userEmail);
-
-            // Assert
+            // Assert: Verify that the User property is not null
             Assert.IsNotNull(userProfileViewModel.User);
         }
     }

BIN
EducationDepartment/EducationDepartment.test/bin/Debug/net7.0/EducationDepartment.test.dll


BIN
EducationDepartment/EducationDepartment.test/bin/Debug/net7.0/EducationDepartment.test.pdb


BIN
EducationDepartment/EducationDepartment.test/obj/Debug/net7.0/EducationDepartment.test.dll


BIN
EducationDepartment/EducationDepartment.test/obj/Debug/net7.0/EducationDepartment.test.pdb