public static void GetValidationResult_returns_DefaultErrorMessage_if_ErrorMessage_is_not_set() { var attribute = new UrlAttribute(); var toBeTested = new UrlClassToBeTested(); var validationContext = new ValidationContext(toBeTested); validationContext.MemberName = "UrlPropertyToBeTested"; AssertEx.DoesNotThrow(() => attribute.GetValidationResult(toBeTested, validationContext)); }
public static void GetValidationResult_returns_ErrorMessage_if_ErrorMessage_overrides_default() { var attribute = new UrlAttribute(); attribute.ErrorMessage = "SomeErrorMessage"; var toBeTested = new UrlClassToBeTested(); var validationContext = new ValidationContext(toBeTested); validationContext.MemberName = "UrlPropertyToBeTested"; var validationResult = attribute.GetValidationResult(toBeTested, validationContext); Assert.Equal("SomeErrorMessage", validationResult.ErrorMessage); }
public static void GetValidationResult_returns_ErrorMessage_if_ErrorMessage_overrides_default() { var attribute = new UrlAttribute(); attribute.ErrorMessage = "SomeErrorMessage"; var toBeTested = new UrlClassToBeTested(); var validationContext = new ValidationContext(toBeTested); validationContext.MemberName = "UrlPropertyToBeTested"; var validationResult = attribute.GetValidationResult(toBeTested, validationContext); Assert.Equal("SomeErrorMessage", validationResult.ErrorMessage); }
public static void GetValidationResultWithErrorMessageResourceNameAndType() { var attribute = new UrlAttribute(); attribute.ErrorMessageResourceName = "InternalErrorMessageTestProperty"; attribute.ErrorMessageResourceType = typeof(ErrorMessageResources); var toBeTested = new UrlClassToBeTested(); var validationContext = new ValidationContext(toBeTested); validationContext.MemberName = "UrlPropertyToBeTested"; var validationResult = attribute.GetValidationResult(toBeTested, validationContext); Assert.Equal( "Error Message from ErrorMessageResources.InternalErrorMessageTestProperty", validationResult.ErrorMessage); }
public static void GetValidationResultWithErrorMessageResourceNameAndType() { var attribute = new UrlAttribute(); attribute.ErrorMessageResourceName = "InternalErrorMessageTestProperty"; attribute.ErrorMessageResourceType = typeof(ErrorMessageResources); var toBeTested = new UrlClassToBeTested(); var validationContext = new ValidationContext(toBeTested); validationContext.MemberName = "UrlPropertyToBeTested"; var validationResult = attribute.GetValidationResult(toBeTested, validationContext); Assert.Equal( "Error Message from ErrorMessageResources.InternalErrorMessageTestProperty", validationResult.ErrorMessage); }
public static void GetValidationResult_returns_DefaultErrorMessage_if_ErrorMessage_is_not_set() { var attribute = new UrlAttribute(); var toBeTested = new UrlClassToBeTested(); var validationContext = new ValidationContext(toBeTested); validationContext.MemberName = "UrlPropertyToBeTested"; AssertEx.DoesNotThrow(() => attribute.GetValidationResult(toBeTested, validationContext)); }