public void WithAPhoto_ThenInvokesVehicleRepositoryToUpdatePhotoInfo() { var vehicleForm = new VehicleFormModel { Name = "vehicle" }; var photoStream = Mock.MockPhotoStream(); var handler = new CreateVehicle(_vehicleRepo.Object, _photoRepo.Object); handler.Execute(UserId, vehicleForm, photoStream.Object); _vehicleRepo .Verify(r => r.Create(UserId, It.IsAny <Vehicle>()), Times.Once()); _vehicleRepo .Verify(r => r.Update(It.IsAny <Vehicle>()), Times.Once()); }
public void WihtNewPhoto_ThenDelegatesToPhotoRepositoryAddNewPhoto() { var vehicleForm = new VehicleFormModel { VehicleId = DefaultVehicleId }; _vehicleRepo .Setup(r => r.GetVehicle(UserId, DefaultVehicleId)) .Returns(new Model.Vehicle { VehicleId = DefaultVehicleId }); var newPhotoFile = Mock.MockPhotoStream().Object; var handler = new UpdateVehicle(_vehicleRepo.Object, _photoRepo.Object); handler.Execute(UserId, vehicleForm, newPhotoFile); _photoRepo.Verify(r => r.Create(DefaultVehicleId, It.IsAny <Model.VehiclePhoto>()), Times.Once()); }
public void WithExistingPhoto_ThenDelegatesToPhotoRepositoryToDeleteOldPhoto() { const int vehiclePhotoId = 300; var vehicleForm = new VehicleFormModel { VehicleId = DefaultVehicleId }; _vehicleRepo .Setup(vr => vr.GetVehicle(UserId, DefaultVehicleId)) .Returns(new Model.Vehicle { VehicleId = DefaultVehicleId, PhotoId = vehiclePhotoId }); var newPhotoFile = Mock.MockPhotoStream().Object; var handler = new UpdateVehicle(_vehicleRepo.Object, _photoRepo.Object); handler.Execute(UserId, vehicleForm, newPhotoFile); _photoRepo.Verify(r => r.Delete(vehiclePhotoId), Times.Once()); }