public void WhenRetrievingUpcomingReminders_ThenRemindersInDueDateRangeRetrieved() { DateTime dateStart = DateTime.UtcNow; DateTime dateEnd = DateTime.UtcNow.AddDays(5); int odometer = 1000; int warningThreshold = 500; int outsideOdometerRange = odometer + warningThreshold + 1; var repository = new ReminderRepository(this.GetUnitOfWork()); // reminders just inside range var inRangeReminder1 = new Reminder() { DueDate = dateStart.AddDays(1), DueDistance = outsideOdometerRange, Title = "UpcomingReminder" }; repository.Create(this.defaultVehicle.VehicleId, inRangeReminder1); var inRangeReminder2 = new Reminder() { DueDate = dateEnd.AddDays(-1), DueDistance = outsideOdometerRange, Title = "UpcomingReminder1" }; repository.Create(this.defaultVehicle.VehicleId, inRangeReminder2); // reminders just outside of range repository.Create(this.defaultVehicle.VehicleId, new Reminder() { DueDate = dateStart.AddDays(-1), DueDistance = outsideOdometerRange, Title = "OutsideRangeReminder1" }); repository.Create(this.defaultVehicle.VehicleId, new Reminder() { DueDate = dateEnd.AddDays(1), DueDistance = outsideOdometerRange, Title = "OutsideRangeReminder2" }); var reminders = repository.GetUpcomingReminders( this.defaultVehicle.VehicleId, dateStart, dateEnd, odometer, warningThreshold ); Assert.Equal(2, reminders.Count()); Assert.True(reminders.Any(r => r.ReminderId == inRangeReminder1.ReminderId)); Assert.True(reminders.Any(r => r.ReminderId == inRangeReminder2.ReminderId)); }
public void WhenRetrievingUpcomingReminders_ThenRemindersInDueDateRangeRetrieved() { DateTime dateStart = DateTime.UtcNow; DateTime dateEnd = DateTime.UtcNow.AddDays(5); int odometer = 1000; int warningThreshold = 500; int outsideOdometerRange = odometer + warningThreshold + 1; var repository = new ReminderRepository(); // reminders just inside range var inRangeReminder1 = new Reminder() { DueDate = dateStart.AddDays(1), DueDistance = outsideOdometerRange, Title = "UpcomingReminder" }; repository.Create(defaultVehicle.VehicleId, inRangeReminder1); var inRangeReminder2 = new Reminder() { DueDate = dateEnd.AddDays(-1), DueDistance = outsideOdometerRange, Title = "UpcomingReminder1" }; repository.Create(defaultVehicle.VehicleId, inRangeReminder2); // reminders just outside of range repository.Create(defaultVehicle.VehicleId, new Reminder() { DueDate = dateStart.AddDays(-1), DueDistance = outsideOdometerRange, Title = "OutsideRangeReminder1" }); repository.Create(defaultVehicle.VehicleId, new Reminder() { DueDate = dateEnd.AddDays(1), DueDistance = outsideOdometerRange, Title = "OutsideRangeReminder2" }); var reminders = repository.GetUpcomingReminders( defaultVehicle.VehicleId, dateStart, dateEnd, odometer, warningThreshold ); Assert.Equal(2, reminders.Count()); Assert.True(reminders.Any(r => r.ReminderId == inRangeReminder1.ReminderId)); Assert.True(reminders.Any(r => r.ReminderId == inRangeReminder2.ReminderId)); }