public void Merge_Should_Merge_ProviderExtensions()
        {
            // arrange
            var provider1  = new MockProviderExtensions();
            var convention = new MockFilterConvention(x => x.AddProviderExtension(provider1));
            var provider2  = new MockProviderExtensions();
            var extension  = new FilterConventionExtension(x => x.AddProviderExtension(provider2));
            var context    = new ConventionContext(
                "Scope",
                new ServiceCollection().BuildServiceProvider(),
                DescriptorContext.Create());

            convention.Initialize(context);
            extension.Initialize(context);

            // act
            extension.Merge(context, convention);

            // assert
            Assert.NotNull(convention.DefinitionAccessor);
            Assert.Collection(
                convention.DefinitionAccessor !.ProviderExtensions,
                x => Assert.Equal(provider1, x),
                x => Assert.Equal(provider2, x));
        }
        public void Merge_Should_DeepMerge_Configurations()
        {
            // arrange
            var convention = new MockFilterConvention(
                x => x.Configure <ComparableOperationFilterInput <int> >(d => d.Name("Foo")));
            var extension = new FilterConventionExtension(
                x => x.Configure <ComparableOperationFilterInput <int> >(d => d.Name("Bar")));
            var context = new ConventionContext(
                "Scope",
                new ServiceCollection().BuildServiceProvider(),
                DescriptorContext.Create());

            convention.Initialize(context);
            extension.Initialize(context);

            // act
            extension.Merge(context, convention);

            // assert
            Assert.NotNull(convention.DefinitionAccessor);
            List <ConfigureFilterInputType> configuration =
                Assert.Single(convention.DefinitionAccessor !.Configurations.Values) !;

            Assert.Equal(2, configuration.Count);
        }
        public void Merge_Should_Merge_Provider()
        {
            // arrange
            var convention = new MockFilterConvention(x => x.Provider <QueryableFilterProvider>());
            var extension  = new FilterConventionExtension(x => x.Provider <MockProvider>());
            var context    = new ConventionContext(
                "Scope",
                new ServiceCollection().BuildServiceProvider(),
                DescriptorContext.Create());

            convention.Initialize(context);
            extension.Initialize(context);

            // act
            extension.Merge(context, convention);

            // assert
            Assert.Equal(typeof(MockProvider), convention.DefinitionAccessor?.Provider);
        }
        public void Merge_Should_Merge_ArgumentName()
        {
            // arrange
            var convention = new MockFilterConvention(x => x.ArgumentName("Foo"));
            var extension  = new FilterConventionExtension(x => x.ArgumentName("Bar"));
            var context    = new ConventionContext(
                "Scope",
                new ServiceCollection().BuildServiceProvider(),
                DescriptorContext.Create());

            convention.Initialize(context);
            extension.Initialize(context);

            // act
            extension.Merge(context, convention);

            // assert
            Assert.Equal("Bar", convention.DefinitionAccessor?.ArgumentName);
        }
        public void Merge_Should_Merge_Bindings()
        {
            // arrange
            var convention = new MockFilterConvention(
                x => x.BindRuntimeType <int, ComparableOperationFilterInput <int> >());
            var extension = new FilterConventionExtension(
                x => x.BindRuntimeType <double, ComparableOperationFilterInput <double> >());
            var context = new ConventionContext(
                "Scope",
                new ServiceCollection().BuildServiceProvider(),
                DescriptorContext.Create());

            convention.Initialize(context);
            extension.Initialize(context);

            // act
            extension.Merge(context, convention);

            // assert
            Assert.NotNull(convention.DefinitionAccessor);
            Assert.Contains(typeof(int), convention.DefinitionAccessor !.Bindings);
            Assert.Contains(typeof(double), convention.DefinitionAccessor !.Bindings);
        }