Example #1
0
        public void ShouldValidateFormattedValidRenavam()
        {
            RenavamValidator validator = new RenavamValidator(true);

            validator.AssertValid(validFormattedRenavam1);
            validator.AssertValid(validFormattedRenavam2);

            IList <IValidationMessage> errorMessages = validator.InvalidMessageFor(validFormattedRenavam1);

            Assert.IsTrue(errorMessages.Count == 0);
        }
Example #2
0
        public void ShouldGenerateValidUnformattedRenavam()
        {
            RenavamValidator renavamValidator = new RenavamValidator();
            string           generated        = renavamValidator.GenerateRandomValid();

            renavamValidator.AssertValid(generated);
        }
Example #3
0
        public void ShouldValidateValidRenavamWithNineDigits()
        {
            RenavamValidator validator = new RenavamValidator();

            validator.AssertValid(renavamWithNineDigits);

            IList <IValidationMessage> errorMessages = validator.InvalidMessageFor(renavamWithNineDigits);

            Assert.IsTrue(errorMessages.Count == 0);
        }
Example #4
0
        public void ShouldUseAnSimpleMessageProducerAsDefault()
        {
            RenavamValidator validator = new RenavamValidator();

            try
            {
                validator.AssertValid(renavamFormattedWithInvalidCheckDigit);
                Assert.Fail();
            }
            catch (InvalidStateException e)
            {
                IList <IValidationMessage> errors = e.GetInvalidMessages();
                Assert.IsTrue(errors.Count == 1);
                Assert.AreEqual("RenavamError : INVALID CHECK DIGIT", errors[0].GetMessage());
            }
        }
Example #5
0
        public void ShouldNotValidateARenavamWithLessThenElevenDigits()
        {
            RenavamValidator validator = new RenavamValidator();

            validator.AssertValid(renavamWithLessThenElevenDigits);
        }
Example #6
0
        public void ShouldNotValidadeFormattedRenavamWithInvalidCheckDigit()
        {
            RenavamValidator validator = new RenavamValidator(true);

            validator.AssertValid(renavamFormattedWithInvalidCheckDigit);
        }