public void EvaluateShouldUseCustomErrorMessage() { // arrange var expected = "Test"; var rule = new UrlRule( expected ); var property = new Property<string>( "Url", "tempuri.org" ); // act var actual = rule.Evaluate( property ); // assert Assert.Equal( expected, actual.ErrorMessage ); }
public void EvaluateShouldReturnExpectedResultForInvalidValue() { // arrange var rule = new UrlRule(); var property = new Property<string>( "Url", "foo" ); // act var actual = rule.Evaluate( property ); // assert Assert.Equal( "The Url field is not a valid fully-qualified http, https, or ftp URL.", actual.ErrorMessage ); Assert.Equal( 1, actual.MemberNames.Count() ); Assert.Equal( "Url", actual.MemberNames.Single() ); }
public void EvaluateShouldReturnSuccessForNullOrEmpty() { // arrange string value = null; var rule = new UrlRule(); var property = new Property<string>( "Url", value ); var expected = ValidationResult.Success; // act var actual = rule.Evaluate( property ); // assert Assert.Equal( expected, actual ); }
public void EvaluateWithKindShouldReturnExpectedResultForValidValue() { // arrange var rule = new UrlRule( UriKind.Relative ); var property = new Property<string>( "Url", "/api/helloworld" ); var expected = ValidationResult.Success; // act var actual = rule.Evaluate( property ); // assert Assert.Equal( expected, actual ); }
public void EvaluateShouldReturnExpectedResultForValidValue() { // arrange var rule = new UrlRule(); var property = new Property<string>( "Url", "http://tempuri.org" ); var expected = ValidationResult.Success; // act var actual = rule.Evaluate( property ); // assert Assert.Equal( expected, actual ); }