コード例 #1
0
ファイル: EqualToAttributeTests.cs プロジェクト: mdy6/ToDoApp
        public void EqualToAttribute_SetsOtherPropertyName()
        {
            String actual   = new EqualToAttribute("OtherProperty").OtherPropertyName;
            String expected = "OtherProperty";

            Assert.Equal(expected, actual);
        }
コード例 #2
0
ファイル: EqualToAttributeTests.cs プロジェクト: mdy6/ToDoApp
        public void GetValidationResult_NoProperty_Error()
        {
            attribute = new EqualToAttribute("Temp");
            ValidationContext context = new(new AllTypesView());

            String?expected = Validation.For("EqualTo", context.DisplayName, "Temp");
            String?actual   = attribute.GetValidationResult("Test", context)?.ErrorMessage;

            Assert.Equal(expected, actual);
        }
コード例 #3
0
 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),
         MaxLengthAttribute maxLength => new MaxLengthAdapter(maxLength),
         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),
         NumericAttribute numeric => new NumericAdapter(numeric),
         EqualToAttribute equalTo => new EqualToAdapter(equalTo),
         IntegerAttribute integer => new IntegerAdapter(integer),
         DigitsAttribute digits => new DigitsAdapter(digits),
         RangeAttribute range => new RangeAdapter(range),
         _ => null
     });
コード例 #4
0
ファイル: EqualToAttributeTests.cs プロジェクト: mdy6/ToDoApp
 public EqualToAttributeTests()
 {
     attribute = new EqualToAttribute(nameof(AllTypesView.StringField));
     Resource.Set(nameof(AllTypesView))["", "Titles", nameof(AllTypesView.StringField)] = "Other title";
 }