Exemple #1
0
        public void GivenAnArea_Validate_ShouldNotHaveAValidationError()
        {
            // Arrange.
            var landDetails = new LandDetails
            {
                Area = new UnitOfMeasure
                {
                    Type  = "a",
                    Value = 1m
                }
            };

            // Act.
            _landDetailsValidator.ShouldHaveChildValidator(land => land.Area, typeof(UnitOfMeasureValidator));
            var result = _landDetailsValidator.Validate(landDetails);

            //validator.ShouldHaveValidationErrorFor(land => land.Area, area);

            // Assert.
            result.Errors.Count.ShouldBe(0);
        }
        public void GivenAnAreaWithNoType_Validate_ShouldHaveAValidationError()
        {
            // Arrange.
            var validator = new LandDetailsValidator();
            var landDetails = new LandDetails
            {
                Area = new UnitOfMeasure
                {
                    Type = null,
                    Value = 1m
                }
            };

            // Act.
            validator.ShouldHaveChildValidator(land => land.Area, typeof (UnitOfMeasureValidator));
            var result = validator.Validate(landDetails);
            //validator.ShouldHaveValidationErrorFor(land => land.Area, area);

            // Assert.
            result.Errors.ShouldContain(x => x.PropertyName == "Area.Type");
        }
        public void GivenAnArea_Validate_ShouldNotHaveAValidationError()
        {
            // Arrange.
            var validator = new LandDetailsValidator();
            var landDetails = new LandDetails
            {
                Area = new UnitOfMeasure
                {
                    Type = "a",
                    Value = 1m
                }
            };

            // Act.
            validator.ShouldHaveChildValidator(land => land.Area, typeof (UnitOfMeasureValidator));
            var result = validator.Validate(landDetails);
            //validator.ShouldHaveValidationErrorFor(land => land.Area, area);

            // Assert.
            result.Errors.Count.ShouldBe(0);
        }
        public void GivenAnAreaWithNoType_Validate_ShouldHaveAValidationError()
        {
            // Arrange.
            var validator   = new LandDetailsValidator();
            var landDetails = new LandDetails
            {
                Area = new UnitOfMeasure
                {
                    Type  = null,
                    Value = 1m
                }
            };

            // Act.
            validator.ShouldHaveChildValidator(land => land.Area, typeof(UnitOfMeasureValidator));
            var result = validator.Validate(landDetails);

            //validator.ShouldHaveValidationErrorFor(land => land.Area, area);

            // Assert.
            result.Errors.ShouldContain(x => x.PropertyName == "Area.Type");
        }