public void ReturnsErrorWhenPropertyIsRelativeUrl() { var objectToValidate = new ClassWithStringAttribute { Property = "docs/intro.html" }; var validationContext = new ValidationContext(objectToValidate) { MemberName = nameof(ClassWithIntegerAttribute.Property) }; var validationResults = new List <ValidationResult>(); var validationResult = Validator.TryValidateObject(objectToValidate, validationContext, validationResults, true); Assert.False(validationResult); Assert.True(validationResults.Any()); }
public void ReturnsOkWhenPropertyIsAbsoluteWithProtocol() { var objectToValidate = new ClassWithStringAttribute { Property = "https://www.example.com/docs/intro.html" }; var validationContext = new ValidationContext(objectToValidate) { MemberName = nameof(ClassWithIntegerAttribute.Property) }; var validationResults = new List <ValidationResult>(); var validationResult = Validator.TryValidateObject(objectToValidate, validationContext, validationResults, true); Assert.True(validationResult); Assert.False(validationResults.Any()); }