Ejemplo n.º 1
0
        public void WithMissingYearForMake_ThenReturnsValidationResult()
        {
            var vehicleForm = new VehicleFormModel
            {
                Name     = "vehicle",
                MakeName = "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("make", actual[0].Message, StringComparison.CurrentCultureIgnoreCase);
        }
Ejemplo n.º 2
0
        public void WithInvalidYear_ThenReturnsValidationResult()
        {
            var vehicleForm = new VehicleFormModel
            {
                Name = "vehicle",
                Year = 2100,
            };

            SetupManufacturerRepo(isYearValid: 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("year", actual[0].Message, StringComparison.CurrentCultureIgnoreCase);
        }