public void IsValid_OnEqualValuesReturnsNull() { AttributesModel model = new AttributesModel(); ValidationContext context = new ValidationContext(model); Assert.Null(attribute.GetValidationResult(model.Sum, context)); }
public void IsValid_OnNotEqualValuesReturnsValidationResult() { AttributesModel model = new AttributesModel { Total = 10 }; ValidationContext context = new ValidationContext(model); ValidationResult expected = new ValidationResult(attribute.FormatErrorMessage(context.DisplayName)); ValidationResult actual = attribute.GetValidationResult(model.Sum, context); Assert.Equal(expected.ErrorMessage, actual.ErrorMessage); }
public void IsValid_NotEqualValueMessage() { AttributesModel model = new AttributesModel { Total = 10 }; ValidationContext context = new ValidationContext(model); String expected = String.Format(Validations.EqualTo, context.DisplayName, "Total"); String actual = attribute.GetValidationResult(model.Sum, context).ErrorMessage; Assert.Equal(expected, actual); }
public void IsValid_SetsOtherPropertyDisplayName() { AttributesModel model = new AttributesModel { Total = 10 }; ValidationContext context = new ValidationContext(model); attribute.GetValidationResult(model.Sum, context); String expected = ResourceProvider.GetPropertyTitle(context.ObjectType, attribute.OtherPropertyName); String actual = attribute.OtherPropertyDisplayName; Assert.Equal(expected, actual); }