public void ValidatesTextMatchingRegexTest() { var validator = new RegexValidationRule(); validator.RegexText = ".B."; var validationResult = validator.Validate("ABC", CultureInfo.CurrentCulture); Assert.IsTrue(validationResult.IsValid); }
public void Validate_empty_property_type_of_string_with_empty_expression_should_be_invalid() { var propertyName = "StringProperty"; var target = new RegexValidationRule(propertyName, ""); var businessObject = new TestEntity() { StringProperty = "" }; Assert.IsFalse(target.Validate(businessObject)); }
public void Validate_property_type_of_string_with_any_value_should_be_valid() { var propertyName = "StringProperty"; var target = new RegexValidationRule(propertyName, @"."); var businessObject = new TestEntity() { StringProperty = "Test text" }; Assert.IsTrue(target.Validate(businessObject)); }
public void InValidatesTextNotMatchingRegexTest() { var validator = new RegexValidationRule(); validator.RegexText = ".B."; validator.ErrorMessage = ErrorMessage; var validationResult = validator.Validate("AXC", CultureInfo.CurrentCulture); Assert.IsFalse(validationResult.IsValid); Assert.AreEqual(ErrorMessage, validationResult.ErrorContent.ToString()); }
public void Validate_ForValidValue(string pattern, bool nullIsValid, bool invert, bool expected) { // Arrange var sut = new RegexValidationRule(_ERROR_MESSAGE, pattern, nullIsValid, invert); // Act var result = sut.Validate("321"); // Assert result.Should().Be(expected); }