コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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());
        }