Пример #1
0
        public void WithInvalidMake_ThenReturnsValidationResult()
        {
            var vehicleForm = new VehicleFormModel
                                  {
                                      Name = "vehicle",
                                      Year = 1,
                                      MakeName = "Test",
                                      ModelName = "Test"
                                  };

            SetupManufacturerRepo(isMakeValid: false);

            var handler = new CanValidateVehicleYearMakeAndModel(_manufacturerRepo.Object);
            var actual = handler.Execute(vehicleForm).ToList();

            Assert.Equal(1, actual.Count);
            Assert.Contains("not valid", actual[0].Message, StringComparison.CurrentCultureIgnoreCase);
            Assert.Contains("make", actual[0].Message, StringComparison.CurrentCultureIgnoreCase);
        }
Пример #2
0
 public CanAddVehicle(IVehicleRepository vehicleRepository, CanValidateVehicleYearMakeAndModel validateVehicleYearMakeAndModel)
 {
     _vehicleRepository = vehicleRepository;
     _validateVehicleYearMakeAndModel = validateVehicleYearMakeAndModel;
 }
Пример #3
0
        public void WithMissingYearForModel_ThenReturnsValidationResult()
        {
            var vehicleForm = new VehicleFormModel
                                  {
                                      Name = "vehicle",
                                      ModelName = "Test"
                                  };

            _manufacturerRepo
                .Setup(x => x.IsValidYear(It.IsAny<int>()))
                .Returns(true);

            _manufacturerRepo
                .Setup(x => x.IsValidMake(It.IsAny<int>(), It.IsAny<string>()))
                .Returns(true);

            _manufacturerRepo
                .Setup(x => x.IsValidModel(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<string>()))
                .Returns(true);

            var handler = new CanValidateVehicleYearMakeAndModel(_manufacturerRepo.Object);
            var actual = handler.Execute(vehicleForm).ToList();

            Assert.Equal(1, actual.Count);
            Assert.Contains("missing", actual[0].Message, StringComparison.CurrentCultureIgnoreCase);
            Assert.Contains("year", actual[0].Message, StringComparison.CurrentCultureIgnoreCase);
            Assert.Contains("model", actual[0].Message, StringComparison.CurrentCultureIgnoreCase);
        }
Пример #4
0
 public CanAddVehicle(IVehicleRepository vehicleRepository, CanValidateVehicleYearMakeAndModel validateVehicleYearMakeAndModel)
 {
     _vehicleRepository = vehicleRepository;
     _validateVehicleYearMakeAndModel = validateVehicleYearMakeAndModel;
 }