示例#1
0
        public void Init()
        {
            var expression = new ValidatorConfigurationExpression();

            expression.AddProfile <Profile1>();

            _subject = new ValidatorFactory(expression);
        }
        public void Passing_Good_Configuration_Will_Not_Throw_Any_Exceptions_On_Assert()
        {
            // arrange
            var expression = new ValidatorConfigurationExpression();

            expression.AddProfile <Profile2>();
            expression.AddProfile <Profile1>();

            _subject = new AutoValidation(expression);

            // act
            Action action = () => _subject.AssertExpressionsAreValid();

            // assert
            action.Should().NotThrow();
        }
        public void Passing_Bad_Configuration_Will_Throw()
        {
            // arrange
            var expression = new ValidatorConfigurationExpression();

            expression.AddProfile <DuplicateInvalidMappingProfile>();
            expression.AddProfile <MissingMappingProfile>();

            _subject = new AutoValidation(expression);

            try
            {
                _subject.AssertExpressionsAreValid();
            }
            catch (ConfigurationExpressionException ex)
            {
                ex.Errors.ToList().Count.Should().Be(2);
                ex.Errors.Should().Contain(e => e.ProfileType == typeof(DuplicateInvalidMappingProfile));
                ex.Errors.Should().Contain(e => e.ProfileType == typeof(MissingMappingProfile));
            }
        }
示例#4
0
 public void Init()
 {
     _subject = new ValidatorConfigurationExpression();
 }