public void _03_Creer_une_classe_MockClockService_pour_controller_le_temps() { var dateTimeToReturn = DateTime.Now; MockClockService mockClockService = new MockClockService(dateTimeToReturn); Assert.NotNull(mockClockService); DateTime now = mockClockService.Now(); Assert.Equal(dateTimeToReturn, now); }
public void _06_Renvoyer_true_si_le_cours_a_debute_depuis_moins_de_1h30() { var lessonStartDateTime = DateTime.Now; Lesson lesson = new Lesson(lessonStartDateTime); var dateTimeToReturn = lessonStartDateTime.AddHours(1).AddMinutes(29); IClockService mockClockService = new MockClockService(dateTimeToReturn); bool isBreakTime = lesson.IsBreakTime(mockClockService); Assert.False(isBreakTime); }
public void _05_Creer_une_methode_isBreakTime_qui_utilise_IClockService_pour_renvoyer_false_si_le_cours_a_debute_depuis_plus_de_1h30() { var lessonStartDateTime = DateTime.Now; Lesson lesson = new Lesson(lessonStartDateTime); var dateTimeToReturn = lessonStartDateTime.AddHours(1).AddMinutes(31); IClockService mockClockService = new MockClockService(dateTimeToReturn); bool isBreakTime = lesson.IsBreakTime(mockClockService); Assert.True(isBreakTime); }
public void _04_Creer_une_interface_IClockService_pour_unifier_MockClockService_et_ClockService() { IClockService clockService; DateTime? now; clockService = new ClockService(); Assert.NotNull(clockService); now = clockService.Now(); Assert.NotNull(now); clockService = new MockClockService(DateTime.Now); Assert.NotNull(clockService); now = clockService.Now(); Assert.NotNull(now); }