コード例 #1
0
        public void AddErrorFilter_1_Services_Is_Null()
        {
            // arrange
            // act
            Action action = () =>
                            SchemaServiceCollectionExtensions.AddErrorFilter <MyErrorFilter>(null);

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
コード例 #2
0
        public void AddErrorFilter_2_Filter_Is_Null()
        {
            // arrange
            var services = new ServiceCollection();

            // act
            Action action = () =>
                            SchemaServiceCollectionExtensions.AddErrorFilter(
                services, default(Func <IError, IError>));

            // assert
            Assert.Throws <ArgumentNullException>(action);
        }
コード例 #3
0
        public void AddErrorFilter_1()
        {
            // arrange
            var services = new ServiceCollection();

            // act
            SchemaServiceCollectionExtensions.AddErrorFilter <MyErrorFilter>(services);

            // assert
            Assert.Collection(services,
                              t =>
            {
                Assert.Equal(typeof(IErrorFilter), t.ServiceType);
                Assert.Equal(typeof(MyErrorFilter), t.ImplementationType);
            });
        }
コード例 #4
0
        public void AddErrorFilter_2()
        {
            // arrange
            var services = new ServiceCollection();
            Func <IError, IError> filter = error => error;

            // act
            SchemaServiceCollectionExtensions.AddErrorFilter(services, filter);

            // assert
            Assert.Collection(services,
                              t =>
            {
                Assert.Equal(typeof(IErrorFilter), t.ServiceType);
                Assert.IsType <FuncErrorFilterWrapper>(t.ImplementationInstance);
            });
        }
コード例 #5
0
        public void AddErrorFilter_3()
        {
            // arrange
            var services = new ServiceCollection();
            Func <IServiceProvider, IErrorFilter> factory =
                sp => sp.GetRequiredService <IErrorFilter>();

            // act
            SchemaServiceCollectionExtensions.AddErrorFilter(services, factory);

            // assert
            Assert.Collection(services,
                              t =>
            {
                Assert.Equal(typeof(IErrorFilter), t.ServiceType);
                Assert.Equal(factory, t.ImplementationFactory);
            });
        }