public void WhenCanAddReminderWithInvalidDueDistance_ThenReturnsValidationResult() { var vehicle1 = new Vehicle { VehicleId = DefaultVehicleId, Name = "vehicle1", Fillups = new[] { new FillupEntry { Odometer = 7000 } } }; _vehicleRepositoryMock .Setup(vr => vr.GetVehicle(DefaultUserId, DefaultVehicleId)) .Returns(vehicle1); var handler = new CanAddReminder(_vehicleRepositoryMock.Object); var formModel = new ReminderFormModel { VehicleId = DefaultVehicleId, Title = "Test", DueDistance = 5000 }; var result = handler.Execute(DefaultUserId, formModel); Assert.NotEmpty(result); }
public void WhenCanAddReminderWithInvalidVehicleId_ThenReturnsValidationResult() { const int nonExistentVehicleId = -1; _vehicleRepositoryMock .Setup(vr => vr.GetVehicle(DefaultUserId, nonExistentVehicleId)) .Returns((Vehicle)null); var handler = new CanAddReminder(_vehicleRepositoryMock.Object); var formModel = new ReminderFormModel { VehicleId = nonExistentVehicleId, Title = "Test", DueDistance = 20000 }; var result = handler.Execute(DefaultUserId, formModel); Assert.NotEmpty(result); }
public void WhenCanAddReminder_ThenReturnsEmptyCollection() { var vehicle1 = new Vehicle { VehicleId = DefaultVehicleId, Name = "vehicle1" }; _vehicleRepositoryMock .Setup(r => r.GetVehicle(DefaultUserId, DefaultVehicleId)) .Returns(vehicle1); var handler = new CanAddReminder(_vehicleRepositoryMock.Object); var formModel = new ReminderFormModel { VehicleId = DefaultVehicleId, Title = "Test", DueDistance = 20000 }; var result = handler.Execute(DefaultUserId, formModel); Assert.Empty(result); }
public PostRemindersController(CanAddReminder canAddReminder, AddReminderToVehicle addReminderToVehicle) { this.addReminderToVehicle = addReminderToVehicle; this.canAddReminder = canAddReminder; }