Пример #1
0
        public void shouldGenerateValidUnformattedCPF()
        {
            CPFValidator cpfValidator = new CPFValidator();
            string       generated    = cpfValidator.GenerateRandomValid();

            cpfValidator.AssertValid(generated);
        }
        public void NaoDeveValidarCPFComDigitosRepetidos()
        {
            string[] cpfs = new string[]
            {
                "11111111111",
                "22222222222",
                "33333333333",
                "44444444444",
                "55555555555",
                "66666666666",
                "77777777777",
                "88888888888",
                "99999999999"
            };

            CPFValidator validator = new CPFValidator();

            foreach (var cpf in cpfs)
            {
                try
                {
                    validator.AssertValid("22222222222");
                    Assert.Fail();
                }
                catch (InvalidStateException e)
                {
                    Assert.IsTrue(e.GetErrors().Count == 1);
                    AssertMessage(e, DocumentError.RepeatedDigits);
                }
            }
        }
Пример #3
0
        public void shouldValidateCPFWithAllRepeatedDigitsWhenIgnoringIt()
        {
            CPFValidator validator = new CPFValidator(false, true);
            string       value     = "44444444444";

            validator.AssertValid(value);
        }
Пример #4
0
        public void shouldValidateValidFormattedCPF()
        {
            CPFValidator validator = new CPFValidator(true);
            // VALID CPF = 356.296.825-63
            string value = "356.296.825-63";

            validator.AssertValid(value);
        }
        public void NaoDeveValidarCPFValidoNaoFormatado()
        {
            CPFValidator validator = new CPFValidator(true);

            // VALID CPF = 332.375.322-40
            try
            {
                validator.AssertValid("33237532240");
                Assert.Fail();
            }
            catch (InvalidStateException e)
            {
                Assert.IsTrue(e.GetErrors().Count == 1);
                AssertMessage(e, DocumentError.InvalidFormat);
            }
        }
Пример #6
0
        public void shouldNotValidateCPFWithAllRepeatedDigitsWhenNotIgnoringIt()
        {
            CPFValidator validator = new CPFValidator(false, false);

            try
            {
                string value = "44444444444";
                validator.AssertValid(value);
                Assert.Fail();
            }
            catch (InvalidStateException e)
            {
                Assert.IsTrue(e.GetInvalidMessages().Count == 1);
                assertMessage(e, REPEATED_DIGITS);
            }
        }
Пример #7
0
        public void shouldNotValidateValidUnformattedCPF()
        {
            CPFValidator validator = new CPFValidator(true);

            // VALID CPF = 332.375.322-40
            try
            {
                string value = "33237532240";
                validator.AssertValid(value);
                Assert.Fail();
            }
            catch (InvalidStateException e)
            {
                Assert.IsTrue(e.GetInvalidMessages().Count == 1);
                assertMessage(e, INVALID_FORMAT);
            }
        }
 public void DeveValidarCPFValido()
 {
     cpfValidator.AssertValid("11144477735");
     cpfValidator.AssertValid("88641577947");
     cpfValidator.AssertValid("34608514300");
     cpfValidator.AssertValid("47393545608");
 }
        public void DeveValidarCPFValidoFormatado()
        {
            CPFValidator cpfValidator = new CPFValidator(true);

            cpfValidator.AssertValid("356.296.825-63");
        }
Пример #10
0
 public void shouldNotValidateCPFWithInvalidCharacter()
 {
     try
     {
         validator.AssertValid("1111111a111");
         Assert.Fail();
     }
     catch (InvalidStateException e)
     {
         Assert.IsTrue(e.GetInvalidMessages().Count == 1);
         assertMessage(e, INVALID_DIGITS);
     }
 }