public void InvokesVehicleRepository()
        {
            var vehicleForm = new VehicleFormModel { Name = "vehicle" };

            var handler = new CreateVehicle(_vehicleRepo.Object, _photoRepo.Object);
            handler.Execute(UserId, vehicleForm, null);

            _vehicleRepo
                .Verify(r => r.Create(UserId, It.IsAny<Vehicle>()), Times.Once());
        }
        public void AndVehicleRepositoryThrows_ThenWrapsException()
        {
            _vehicleRepo
                .Setup(v => v.Create(It.IsAny<int>(), It.IsAny<Vehicle>()))
                .Throws<InvalidOperationException>();

            var vehicleForm = new VehicleFormModel { Name = "vehicle" };

            var handler = new CreateVehicle(_vehicleRepo.Object, _photoRepo.Object);

            var ex = Assert.Throws<BusinessServicesException>(() => handler.Execute(UserId, vehicleForm, null));
            Assert.IsType<InvalidOperationException>(ex.InnerException);
        }
        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 PostVehiclesController(CreateVehicle createVehicle)
 {
     this.createVehicle = createVehicle;
 }