public void FileSizeAttribute_SetsMaximumMB() { Decimal actual = new FileSizeAttribute(12.25).MaximumMB; Decimal expected = 12.25M; Assert.Equal(expected, actual); }
public void FormatErrorMessage_ForName() { attribute = new FileSizeAttribute(12.25); String expected = String.Format(Validations.FileSize, "File", attribute.MaximumMB); String actual = attribute.FormatErrorMessage("File"); Assert.Equal(expected, actual); }
public IAttributeAdapter?GetAttributeAdapter(ValidationAttribute attribute, IStringLocalizer?stringLocalizer) { return(attribute switch { StringLengthAttribute stringLength => new StringLengthAdapter(stringLength), GreaterThanAttribute greaterThan => new GreaterThanAdapter(greaterThan), AcceptFilesAttribute acceptFiles => new AcceptFilesAdapter(acceptFiles), MinLengthAttribute minLength => new MinLengthAdapter(minLength), EmailAddressAttribute email => new EmailAddressAdapter(email), RequiredAttribute required => new RequiredAdapter(required), MaxValueAttribute maxValue => new MaxValueAdapter(maxValue), MinValueAttribute minValue => new MinValueAdapter(minValue), LessThanAttribute lessThan => new LessThanAdapter(lessThan), FileSizeAttribute fileSize => new FileSizeAdapter(fileSize), EqualToAttribute equalTo => new EqualToAdapter(equalTo), IntegerAttribute integer => new IntegerAdapter(integer), DigitsAttribute digits => new DigitsAdapter(digits), NumberAttribute number => new NumberAdapter(number), RangeAttribute range => new RangeAdapter(range), _ => null });
public FileSizeAttributeTests() { attribute = new FileSizeAttribute(12.25); }