public void GetValidationDetails_MarkedWithClientValidator_ReturnsValidator() { // Arrange var provider = new DefaultValidationMetadataProvider(); var attribute = new TestClientModelValidationAttribute(); var attributes = new Attribute[] { attribute }; var key = ModelMetadataIdentity.ForProperty(typeof(int), "Length", typeof(string)); var context = new ValidationMetadataProviderContext(key, new ModelAttributes(attributes, new object[0])); // Act provider.GetValidationMetadata(context); // Assert var validatorMetadata = Assert.Single(context.ValidationMetadata.ValidatorMetadata); Assert.Same(attribute, validatorMetadata); }
public void GetValidationDetails_MarkedWithClientValidator_ReturnsValidator() { // Arrange var provider = new DefaultValidationMetadataProvider(); var attribute = new TestClientModelValidationAttribute(); var attributes = new Attribute[] { attribute }; var key = ModelMetadataIdentity.ForProperty(typeof(string).GetProperty(nameof(string.Length)), typeof(int), typeof(string)); var context = new ValidationMetadataProviderContext(key, new ModelAttributes(new object[0], attributes, null)); // Act provider.CreateValidationMetadata(context); // Assert var validatorMetadata = Assert.Single(context.ValidationMetadata.ValidatorMetadata); Assert.Same(attribute, validatorMetadata); }