public void givenNoAppointmentsForADayOneGettingAppointmentsForThatDayThenReturnEmptyArray() { // Arrange ApplicationDbContext dbContext = Shared.GetDatabaseContext(); DoctorService doctorService = new DoctorService(dbContext); Doctor doctor = new Doctor { Id = 1, }; var appointments = new[] { new Appointment // 3:45-4:15 appointment on 2019-11-28 { Id = 4, Date = new DateTime(2019, 11, 28), StartSlot = 15, EndSlot = 17, Doctor = doctor, } }; dbContext.Doctors.Add(doctor); dbContext.Appointments.AddRange(appointments); dbContext.SaveChanges(); // Act Appointment[] sampledAppointments = doctorService.GetAppointmentsForDay(doctor, new DateTime(2019, 11, 27)); // Assert Assert.Empty(sampledAppointments); }
public void givenMutlipleAppointmentsForOneDayOneGettingAppointmentsForThatDayThenReturnThem() { // Arrange ApplicationDbContext dbContext = Shared.GetDatabaseContext(); DoctorService doctorService = new DoctorService(dbContext); Doctor doctor = new Doctor { Id = 1, }; var appointments = new[] { new Appointment // 3:45-4:30 appointment on 2019-11-20 (week before 27) { Id = 1, Date = new DateTime(2019, 11, 20), StartSlot = 15, EndSlot = 17, Doctor = doctor, }, new Appointment // 2:30-3:00 appointment on 2019-11-27 { Id = 2, Date = new DateTime(2019, 11, 27), StartSlot = 10, EndSlot = 11, Doctor = doctor, }, new Appointment // 3:00-3:30 appointment on 2019-11-27 { Id = 3, Date = new DateTime(2019, 11, 27), StartSlot = 12, EndSlot = 13, Doctor = doctor, }, new Appointment // 3:45-4:15 appointment on 2019-11-28 { Id = 4, Date = new DateTime(2019, 11, 28), StartSlot = 15, EndSlot = 17, Doctor = doctor, } }; dbContext.Doctors.Add(doctor); dbContext.Appointments.AddRange(appointments); dbContext.SaveChanges(); // Act Appointment[] sampledAppointments = doctorService.GetAppointmentsForDay(doctor, new DateTime(2019, 11, 27)); // Assert Assert.Equal(2, sampledAppointments.Length); Assert.Collection(sampledAppointments, appointment => Assert.Equal(2, appointment.Id), appointment => Assert.Equal(3, appointment.Id) ); }