Пример #1
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();
        }
Пример #2
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());
        }
Пример #3
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();
        }
Пример #4
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();
        }
Пример #5
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!");
        }
Пример #6
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());
        }
Пример #7
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());
        }