public void MaxValueAttribute_ForDouble() { Decimal actual = new MaxValueAttribute(12.56).Maximum; Decimal expected = 12.56M; Assert.Equal(expected, actual); }
public void FormatErrorMessage_ForInteger() { attribute = new MaxValueAttribute(10); String expected = String.Format(Validations.FieldMustBeLessOrEqualTo, "Sum", attribute.Maximum); String actual = attribute.FormatErrorMessage("Sum"); Assert.Equal(expected, actual); }
public void GetClientValidationRules_ReturnsMaxRangeValidationRule() { ModelMetadata metadata = new DataAnnotationsModelMetadataProvider().GetMetadataForProperty(null, typeof(AdaptersModel), "MaxValue"); MaxValueAdapter adapter = new MaxValueAdapter(metadata, new ControllerContext(), new MaxValueAttribute(128)); String expectedMessage = new MaxValueAttribute(128).FormatErrorMessage(metadata.GetDisplayName()); ModelClientValidationRule actual = adapter.GetClientValidationRules().Single(); Assert.Equal(128M, actual.ValidationParameters["max"]); Assert.Equal(expectedMessage, actual.ErrorMessage); Assert.Equal("range", actual.ValidationType); Assert.Single(actual.ValidationParameters); }
public void MaxValueAttribute_ForInteger() { Decimal actual = new MaxValueAttribute(10).Maximum; Decimal expected = 10M; Assert.Equal(expected, actual); }
public MaxValueAttributeTests() { attribute = new MaxValueAttribute(12.56); }