Пример #1
0
        public void CPFValidator_Validate_ShouldFailWhenInvalidLength(string cpf)
        {
            // Arrange
            var validator = new PersonValidator();
            var person    = new Person(cpf);

            // Act & Asset
            validator.Validate(person).IsValid.Should().BeFalse();
        }
Пример #2
0
        public void CNPJValidator_Validate_ShouldFailWhenInvalidValue(string cnpj)
        {
            // Arrange
            var validator = new PersonValidator();
            var person    = new Person(cnpj: cnpj);

            // Act & Asset
            validator.Validate(person).IsValid.Should().BeFalse();
        }
Пример #3
0
        public void CNPJValidator_Validate_ShouldFailWhenIsNullOrEmpty()
        {
            // Arrange
            var validator       = new PersonValidator();
            var personCnpjEmpty = new Person(cnpj: "");
            var personCnpjNull  = new Person(cnpj: null);

            // Act & Assert
            validator.Validate(personCnpjEmpty).IsValid.Should().BeFalse();
            validator.Validate(personCnpjNull).IsValid.Should().BeFalse();
        }
Пример #4
0
        public void CNPJValidator_Validate_ShouldFailWhenAllDigitsEqualsAsync()
        {
            // Arrange
            var validator = new PersonValidator();

            // Act
            var cnpjList = _documentsFixture.GetCNPJDigitsEquals();

            // Assert
            cnpjList.ToList().ForEach(async cnpj => (await validator.ValidateAsync(new Person(cnpj: cnpj))).IsValid.Should().BeFalse());
        }
Пример #5
0
        public void CPFValidator_Validate_ShouldFailWhenAllDigitsEquals()
        {
            // Arrange
            var validator = new PersonValidator();

            // Act
            var cpfList = _documentsFixture.GetCPFDigitsEquals();

            // Assert
            cpfList.ToList().ForEach(cpf => validator.Validate(new Person(cpf)).IsValid.Should().BeFalse());
        }
Пример #6
0
        public async Task CNPJValidator_Validate_ShouldFailWhenInvalidValueAsync(string cnpj)
        {
            // Arrange
            var validator = new PersonValidator();
            var person    = new Person(cnpj: cnpj);

            // Act
            var result = await validator.ValidateAsync(person);

            // Assert
            result.IsValid.Should().BeFalse();
        }
Пример #7
0
        public async Task CPFValidator_Validate_ShouldFailWhenInvalidLengthAsync(string cpf)
        {
            // Arrange
            var validator = new PersonValidator();
            var person    = new Person(cpf);

            // Act
            var result = await validator.ValidateAsync(person);

            // Assert
            result.IsValid.Should().BeFalse();
        }
		public void Setup() {
			validator = new PersonValidator();
			person = new Person {
				Address = new Address {
					Country = new Country()
				},
				Orders = new List<Order> {
					new Order() { Amount = 5 },
                    new Order() { ProductName = "Foo" }    	
                }
			};
		}
Пример #9
0
        public async Task CNPJValidator_Validate_ShouldFailWhenCustomMessageAsync()
        {
            // Arrange
            var validator = new PersonValidator("{PropertyName} invalid!", "{PropertyName} invalid!");
            var person    = new Person("516734260B0147");

            // Act
            var result = await validator.ValidateAsync(person);

            // Assert
            result.IsValid.Should().BeFalse();
            result.Errors[0].ErrorMessage.Should().Equals("CNPJ invalid!");
        }
Пример #10
0
        public void CNPJValidator_Validate_CNPJIsValidAsync()
        {
            // Arrange
            var validator = new PersonValidator();

            // Act
            var cnpjList = _documentsFixture.GetValidCNPJ(10, true);

            cnpjList.AddRange(_documentsFixture.GetValidCNPJ(10, false));

            // Assert
            cnpjList.ToList().ForEach(async cnpj => (await validator.ValidateAsync(new Person(cnpj: cnpj))).IsValid.Should().BeTrue());
        }
Пример #11
0
        public void CPFValidator_Validate_CPFIsValidAsync()
        {
            // Arrange
            var validator = new PersonValidator();

            // Act
            var cpfList = _documentsFixture.GetValidCPF(10, true);

            cpfList.AddRange(_documentsFixture.GetValidCPF(10, false));

            // Assert
            cpfList.ToList().ForEach(async cpf => (await validator.ValidateAsync(new Person(cpf))).IsValid.Should().BeTrue());
        }
Пример #12
0
        public void CPFValidator_Validate_ShouldFailWhenCustomMessage()
        {
            // Arrange
            var validator = new PersonValidator("{PropertyName} invalid!", "{PropertyName} invalid!");
            var person    = new Person("1231231C387");

            // Act
            var result = validator.Validate(person);

            // Assert
            // Assert
            result.IsValid.Should().BeFalse();
            result.Errors[0].ErrorMessage.Should().Equals("CPF invalid!");
        }
Пример #13
0
        public void Test1()
        {
            var validator = new PersonValidator();
            var person    = new Person
            {
                Name = "A",
                Age  = 12,
            };

            var result = validator.Validate(person);

            Assert.False(result.IsValid);

            Assert.False(result.Errors.Count == 0);
        }
Пример #14
0
        public async Task CNPJValidator_Validate_ShouldFailWhenIsNullOrEmptyAsync()
        {
            // Arrange
            var validator       = new PersonValidator();
            var personCnpjEmpty = new Person(cnpj: "");
            var personCnpjNull  = new Person(cnpj: null);

            // Act
            var resultIsEmpty = await validator.ValidateAsync(personCnpjEmpty);

            var resultIsNull = await validator.ValidateAsync(personCnpjNull);

            // Assert
            resultIsEmpty.IsValid.Should().BeFalse();
            resultIsNull.IsValid.Should().BeFalse();
        }
 public void Setup()
 {
     validator = new PersonValidator();
     person    = new Person()
     {
         Orders = new List <Order>()
         {
             new Order {
                 Amount = 5
             },
             new Order {
                 ProductName = "Foo"
             }
         }
     };
 }
Пример #16
0
 public ChainedValidationTester()
 {
     validator = new PersonValidator();
     person    = new Person {
         Address = new Address {
             Country = new Country()
         },
         Orders = new List <Order> {
             new Order()
             {
                 Amount = 5
             },
             new Order()
             {
                 ProductName = "Foo"
             }
         }
     };
 }