public void Set_Model_DaysOfWeek_Property_Correctly() { var mockedView = new Mock<IManagingScheduleView>(); var mockedScheduleService = new Mock<IScheduleDataService>(); var mockedClassOfStudentsManagementService = new Mock<IClassOfStudentsManagementService>(); var mockedSubjectManagementService = new Mock<ISubjectManagementService>(); var model = new ManagingScheduleControlModel(); mockedView.SetupGet(x => x.Model).Returns(model); var presenter = new ManagingSchedulePresenter( mockedView.Object, mockedScheduleService.Object, mockedClassOfStudentsManagementService.Object, mockedSubjectManagementService.Object); var expected = new List<DaysOfWeek>(); mockedScheduleService .Setup(x => x.GetAllDaysOfWeek()) .Returns(expected); mockedView.Raise(x => x.EventBindDaysOfWeek += null, EventArgs.Empty); Assert.AreEqual(expected, mockedView.Object.Model.DaysOfWeek); }
public void Set_Model_CurrentSchedule_Property_Correctly() { var mockedView = new Mock <IManagingScheduleView>(); var mockedScheduleService = new Mock <IScheduleDataService>(); var mockedClassOfStudentsManagementService = new Mock <IClassOfStudentsManagementService>(); var mockedSubjectManagementService = new Mock <ISubjectManagementService>(); var model = new ManagingScheduleControlModel(); var args = new ManagingScheduleEventArgs() { ClassId = 1, DayOfWeekId = 2 }; mockedView.SetupGet(x => x.Model).Returns(model); var presenter = new ManagingSchedulePresenter( mockedView.Object, mockedScheduleService.Object, mockedClassOfStudentsManagementService.Object, mockedSubjectManagementService.Object); var expected = new List <ManagingScheduleModel>(); mockedScheduleService .Setup(x => x.GetClassScheduleForTheDay(It.IsAny <int>(), It.IsAny <int>())) .Returns(expected); mockedView.Raise(x => x.EventBindScheduleData += null, args); Assert.AreEqual(expected, mockedView.Object.Model.CurrentSchedule); }
public void Set_Model_IsInsertingSuccessFull_Property_Correctly() { var mockedView = new Mock <IManagingScheduleView>(); var mockedScheduleService = new Mock <IScheduleDataService>(); var mockedClassOfStudentsManagementService = new Mock <IClassOfStudentsManagementService>(); var mockedSubjectManagementService = new Mock <ISubjectManagementService>(); var model = new ManagingScheduleControlModel(); var args = new AddingSubjectToScheduleEventArgs(); mockedView.SetupGet(x => x.Model).Returns(model); var presenter = new ManagingSchedulePresenter( mockedView.Object, mockedScheduleService.Object, mockedClassOfStudentsManagementService.Object, mockedSubjectManagementService.Object); var expected = true; mockedScheduleService .Setup(x => x.AddSubjectToSchedule( It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <DateTime>(), It.IsAny <DateTime>())) .Returns(expected); mockedView.Raise(x => x.EventAddSubjectToSchedule += null, args); Assert.AreEqual(expected, mockedView.Object.Model.IsInsertingSuccessFull); }
public void Set_Mode_SubjectForCurrentClass_Property_Correctly() { var mockedView = new Mock <IManagingScheduleView>(); var mockedScheduleService = new Mock <IScheduleDataService>(); var mockedClassOfStudentsManagementService = new Mock <IClassOfStudentsManagementService>(); var mockedSubjectManagementService = new Mock <ISubjectManagementService>(); var model = new ManagingScheduleControlModel(); var args = new BindSubjectsForClassEventArgs(); mockedView.SetupGet(x => x.Model).Returns(model); var presenter = new ManagingSchedulePresenter( mockedView.Object, mockedScheduleService.Object, mockedClassOfStudentsManagementService.Object, mockedSubjectManagementService.Object); var expected = new List <Subject>(); mockedSubjectManagementService .Setup(x => x.GetAllSubjectsAlreadyAssignedToTheClass(It.IsAny <int>())) .Returns(expected); mockedView.Raise(x => x.EventBitSubjectForCurrentClass += null, args); Assert.AreEqual(expected, mockedView.Object.Model.SubjectForCurrentClass); }
public void Call_ScheduleService_RemoveSubjectFromSchedule_Method_Once() { var mockedView = new Mock <IManagingScheduleView>(); var mockedScheduleService = new Mock <IScheduleDataService>(); var mockedClassOfStudentsManagementService = new Mock <IClassOfStudentsManagementService>(); var mockedSubjectManagementService = new Mock <ISubjectManagementService>(); var model = new ManagingScheduleControlModel(); var args = new RemovingSubjectFromScheduleEventArgs(); mockedView.SetupGet(x => x.Model).Returns(model); mockedScheduleService.Setup(x => x.RemoveSubjectFromSchedule(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())); var presenter = new ManagingSchedulePresenter( mockedView.Object, mockedScheduleService.Object, mockedClassOfStudentsManagementService.Object, mockedSubjectManagementService.Object); mockedView.Raise(x => x.EventRemoveSubjectFromSchedule += null, args); mockedScheduleService.Verify(x => x.RemoveSubjectFromSchedule(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()), Times.Once()); }