FluentValidation 의 Validator를 생성합니다.
Наследование: ValidatorFactoryBase
Пример #1
0
        public void InValidCustomerTest()
        {
            var customer = new Customer()
            {
                Name        = "",
                Company     = "",
                HasDiscount = true,
            };

            var factory           = new ValidatorFactory();
            var customerValidator = factory.GetValidator(typeof(Customer));

            var result = customerValidator.Validate(customer);

            result.IsValid.Should().Be.False();
            result.Errors.Count.Should().Be.GreaterThan(0);

            result.Errors.RunEach(err => Console.WriteLine(err.ErrorMessage));
        }
Пример #2
0
        public void InValidCustomerTest() {
            var customer = new Customer()
                           {
                               Name = "",
                               Company = "",
                               HasDiscount = true,
                           };

            var factory = new ValidatorFactory();
            var customerValidator = factory.GetValidator(typeof(Customer));

            var result = customerValidator.Validate(customer);
            result.IsValid.Should().Be.False();
            result.Errors.Count.Should().Be.GreaterThan(0);

            result.Errors.RunEach(err => Console.WriteLine(err.ErrorMessage));
        }
Пример #3
0
        public void ValidCustomerTest() {
            var customer = new Customer()
                           {
                               Name = "배성혁",
                               Company = "리얼웹",
                               Discount = 12.5m,
                               ZipCode = "135-010"
                           };

            var factory = new ValidatorFactory();
            var customerValidator = factory.GetValidator(typeof(Customer));

            var result = customerValidator.Validate(customer);
            result.IsValid.Should().Be.True();
            result.Errors.Count.Should().Be(0);
        }
Пример #4
0
        public void GetValidatorTest() {
            var factory = new ValidatorFactory();
            var validator = factory.GetValidator(typeof(Customer));

            typeof(CustomerValidator).IsInstanceOfType(validator).Should().Be.True();
        }