public void EqualTo_FormatErrorMessageUsesErrorResource_ReturnsUsingErrorResource() { var model = new IsModel() { Value1 = "hello" }; var error = model.GetAttribute("Value4").FormatErrorMessage("Value4"); Assert.IsTrue(!string.IsNullOrEmpty(error)); }
public void EqualTo_FormatErrorMessageUsesErrorMessage_ReturnsUsingErrorMessage() { var model = new IsModel() { Value1 = "hello" }; var error = model.GetAttribute("Value3").FormatErrorMessage("Value3"); Assert.IsTrue(error == "My error."); }
public void EqualTo_GetClientValidationRules_ReturnsGetClientValidationRules() { var model = new IsModel(); System.Web.Mvc.ModelMetadataProviders.Current = new InfrastructureModelMetadataProvider(); var metadata = System.Web.Mvc.ModelMetadataProviders.Current.GetMetadataForProperties(model, model.GetType()).FirstOrDefault(m => m.PropertyName == "Value3"); var rules = model.GetAttribute("Value3").GetClientValidationRules(metadata, new ControllerContext()); Assert.IsTrue(rules.Any()); }
public void EqualTo_GetOtherDisplayNameWithNullContainer_UsesDependentProperty() { var model = new IsModel() { Value1 = "hello", Value3 = string.Empty }; System.Web.Mvc.ModelMetadataProviders.Current = new InfrastructureModelMetadataProvider(); var metadata = System.Web.Mvc.ModelMetadataProviders.Current.GetMetadataForProperties(model, model.GetType()).FirstOrDefault(m => m.PropertyName == "Value3"); // Set container to null metadata.AdditionalValues["ParentModel"] = null; var rules = model.GetAttribute("Value3").GetClientValidationRules(metadata, new ControllerContext()); Assert.IsTrue(rules.Any()); }