public void AdapterFactory_RegistersAdapters_ForDataAnnotationAttributes(
            ValidationAttribute attribute,
            Type expectedAdapterType)
        {
            // Arrange
            var adapters       = new DataAnnotationsClientModelValidatorProvider().AttributeFactories;
            var adapterFactory = adapters.Single(kvp => kvp.Key == attribute.GetType()).Value;

            // Act
            var adapter = adapterFactory(attribute);

            // Assert
            Assert.IsType(expectedAdapterType, adapter);
        }
        public void AdapterFactory_RegistersAdapters_ForDataTypeAttributes(
            ValidationAttribute attribute,
            string expectedRuleName)
        {
            // Arrange
            var adapters       = new DataAnnotationsClientModelValidatorProvider().AttributeFactories;
            var adapterFactory = adapters.Single(kvp => kvp.Key == attribute.GetType()).Value;

            // Act
            var adapter = adapterFactory(attribute);

            // Assert
            var dataTypeAdapter = Assert.IsType <DataTypeAttributeAdapter>(adapter);

            Assert.Equal(expectedRuleName, dataTypeAdapter.RuleName);
        }
Example #3
0
        public void AdapterFactory_RegistersAdapters_ForDataAnnotationAttributes(
            ValidationAttribute attribute,
            Type expectedAdapterType)
        {
            // Arrange
            var adapters = new DataAnnotationsClientModelValidatorProvider(
                new TestOptionsManager <MvcDataAnnotationsLocalizationOptions>(),
                stringLocalizerFactory: null)
                           .AttributeFactories;
            var adapterFactory = adapters.Single(kvp => kvp.Key == attribute.GetType()).Value;

            // Act
            var adapter = adapterFactory(attribute, stringLocalizer: null);

            // Assert
            Assert.IsType(expectedAdapterType, adapter);
        }
        public void AdapterFactory_RegistersAdapters_ForDataTypeAttributes(
            ValidationAttribute attribute,
            string expectedRuleName)
        {
            // Arrange
            var adapters = new DataAnnotationsClientModelValidatorProvider().AttributeFactories;
            var adapterFactory = adapters.Single(kvp => kvp.Key == attribute.GetType()).Value;

            // Act
            var adapter = adapterFactory(attribute);

            // Assert
            var dataTypeAdapter = Assert.IsType<DataTypeAttributeAdapter>(adapter);
            Assert.Equal(expectedRuleName, dataTypeAdapter.RuleName);
        }
        public void AdapterFactory_RegistersAdapters_ForDataAnnotationAttributes(
            ValidationAttribute attribute,
            Type expectedAdapterType)
        {
            // Arrange
            var adapters = new DataAnnotationsClientModelValidatorProvider().AttributeFactories;
            var adapterFactory = adapters.Single(kvp => kvp.Key == attribute.GetType()).Value;

            // Act
            var adapter = adapterFactory(attribute);

            // Assert
            Assert.IsType(expectedAdapterType, adapter);
        }
        public void AdapterFactory_RegistersAdapters_ForDataAnnotationAttributes(
            ValidationAttribute attribute,
            Type expectedAdapterType)
        {
            // Arrange
            var adapters = new DataAnnotationsClientModelValidatorProvider(
                new TestOptionsManager<MvcDataAnnotationsLocalizationOptions>(),
                stringLocalizerFactory: null)
                .AttributeFactories;
            var adapterFactory = adapters.Single(kvp => kvp.Key == attribute.GetType()).Value;

            // Act
            var adapter = adapterFactory(attribute, stringLocalizer: null);

            // Assert
            Assert.IsType(expectedAdapterType, adapter);
        }