public void ErrorMessageTest() { var attribute = new NumericAttribute(); attribute.ErrorMessage = "SampleErrorMessage"; const string invalidValue = "a"; var result = attribute.GetValidationResult(invalidValue, new ValidationContext(0, null, null)); Assert.AreEqual("SampleErrorMessage", result.ErrorMessage); }
public void ErrorResourcesTest() { var attribute = new NumericAttribute(); attribute.ErrorMessageResourceName = "ErrorMessage"; attribute.ErrorMessageResourceType = typeof(ErrorResources); const string invalidValue = "a"; var result = attribute.GetValidationResult(invalidValue, new ValidationContext(0, null, null)); Assert.AreEqual(ErrorResources.ErrorMessage, result.ErrorMessage); }
public void GlobalizedErrorResourcesTest() { System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-MX"); var attribute = new NumericAttribute(); attribute.ErrorMessageResourceName = "ErrorMessage"; attribute.ErrorMessageResourceType = typeof(ErrorResources); const string invalidValue = "a"; var result = attribute.GetValidationResult(invalidValue, new ValidationContext(0, null, null)); Assert.AreEqual("mensaje de error", result.ErrorMessage); }