Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 3
0
        public void shouldValidateCPFWithAllRepeatedDigitsWhenIgnoringIt()
        {
            CPFValidator validator = new CPFValidator(false, true);
            string       value     = "44444444444";

            validator.AssertValid(value);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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");
        }
Ejemplo n.º 10
0
 public void shouldNotValidateCPFWithInvalidCharacter()
 {
     try
     {
         validator.AssertValid("1111111a111");
         Assert.Fail();
     }
     catch (InvalidStateException e)
     {
         Assert.IsTrue(e.GetInvalidMessages().Count == 1);
         assertMessage(e, INVALID_DIGITS);
     }
 }