Beispiel #1
0
        public void CanInvalidateSimple()
        {
            var simple = new Simple();

            MappingConfigurationLoader.LoadConfigurations();
            IValidate <Simple> valid = new SimpleValidator(new AutoMapperMappingService());
            var result = valid.Check(simple);

            Assert.False(result.IsValid);
        }
Beispiel #2
0
        public void CanValidateSimple()
        {
            var simple = new Simple {
                Name = "Fozzy", EmailAddress = "*****@*****.**"
            };

            MappingConfigurationLoader.LoadConfigurations();
            IValidate <Simple> valid = new SimpleValidator(new AutoMapperMappingService());
            var result = valid.Check(simple);

            Assert.True(result.IsValid);
        }
Beispiel #3
0
        public void ValidationMessagesAreCorrectlyTransformed()
        {
            var simple = new Simple();

            MappingConfigurationLoader.LoadConfigurations();
            var validator = new SimpleValidator(new AutoMapperMappingService());

            var fluentResults = validator.Validate(simple);
            var myResults     = validator.Check(simple);

            Assert.Equal(fluentResults.IsValid, myResults.IsValid);

            foreach (var thing in fluentResults.Errors)
            {
                Assert.True(myResults.FailureMessages.Any(fm => fm.Message == thing.ErrorMessage));
            }
        }