public void ShouldValidateValidCNPJ() { CNPJValidator validator = new CNPJValidator(); validator.AssertValid("11222333000181"); validator.AssertValid("63025530002409"); validator.AssertValid("61519128000150"); validator.AssertValid("68745386000102"); }
public void ShouldGenerateValidUnformattedCPF() { CNPJValidator cnpjValidator = new CNPJValidator(); string generated = cnpjValidator.GenerateRandomValid(); cnpjValidator.AssertValid(generated); }
public void ShouldValidateValidFormattedCNPJ() { CNPJValidator validator = new CNPJValidator(true); string value = validString; validator.AssertValid(value); }
public void ShoulValidateNullCNPJ() { CNPJValidator validator = new CNPJValidator(); string value = null; validator.AssertValid(value); }
public void ShouldValidateValidCNPJ() { cnpjValidator.AssertValid("11222333000181"); cnpjValidator.AssertValid("63025530002409"); cnpjValidator.AssertValid("61519128000150"); cnpjValidator.AssertValid("68745386000102"); }
public void ShouldNotValidateCNPJWithInvalidCharacter() { CNPJValidator validator = new CNPJValidator(false); try { string value = "1111111a111111"; validator.AssertValid(value); Assert.Fail(); } catch (InvalidStateException e) { Assert.IsTrue(e.GetInvalidMessages().Count == 1); AssertMessage(e, INVALID_DIGITS); } }
public void ShouldNotValidateCNPJWithMoreDigitsThanAllowed() { CNPJValidator validator = new CNPJValidator(); try { string value = "123456789012345"; validator.AssertValid(value); Assert.Fail(); } catch (InvalidStateException e) { Assert.IsTrue(e.GetInvalidMessages().Count == 1); AssertMessage(e, INVALID_DIGITS); } }
public void ShouldNotValidateValidUnformattedCNPJWhenExplicity() { CNPJValidator validator = new CNPJValidator(true); // VALID CNPJ = 26.637.142/0001-58 try { string value = "26637142000158"; validator.AssertValid(value); Assert.Fail(); } catch (InvalidStateException e) { Assert.IsTrue(e.GetInvalidMessages().Count == 1); AssertMessage(e, INVALID_FORMAT); } }
public void ShouldNotValidateCNPJCheckDigitsWithSecondCheckDigitWrong() { CNPJValidator validator = new CNPJValidator(); // VALID CNPJ = 266371420001-58 try { string value = "26637142000154"; validator.AssertValid(value); Assert.Fail(); } catch (InvalidStateException e) { Assert.IsTrue(e.GetInvalidMessages().Count == 1); AssertMessage(e, INVALID_CHECK_DIGITS); } }
public void ShouldNotValidateCNPJCheckDigitsWithFirstCheckDigitWrong() { CNPJValidator validator = new CNPJValidator(); // VALID CNPJ = 742213250001-30 try { string value = "74221325000160"; validator.AssertValid(value); Assert.Fail(); } catch (InvalidStateException e) { Assert.IsTrue(e.GetInvalidMessages().Count == 1); AssertMessage(e, INVALID_CHECK_DIGITS); } }