コード例 #1
0
        public void NullTest()
        {
            try
            {
                FiltersPipelineFactory.Create(null, null);
            }
            catch (ArgumentException)
            {
                return;
            }

            throw new Exception("FiltersPipelineFactory.Create should throw exception for null");
        }
コード例 #2
0
        public async Task PipelineTestAsync()
        {
            var filterMock1 = new Mock <IFilter>();

            filterMock1.Setup(x => x.Execute(It.IsAny <IRequestContext>(), It.IsAny <FilterAction>()))
            .Returns <IRequestContext, FilterAction>((ctx, next) => next(ctx));
            var filterMock2 = new Mock <IFilter>();

            filterMock2.Setup(x => x.Execute(It.IsAny <IRequestContext>(), It.IsAny <FilterAction>()))
            .Returns <IRequestContext, FilterAction>((ctx, next) => next(ctx));

            var pipeline = FiltersPipelineFactory.Create(new[] { filterMock1.Object, filterMock2.Object }, null);

            await pipeline(Context);

            filterMock1.Verify(x => x.Execute(It.IsAny <IRequestContext>(), It.IsAny <FilterAction>()), Times.Once);
            filterMock2.Verify(x => x.Execute(It.IsAny <IRequestContext>(), It.IsAny <FilterAction>()), Times.Once);
        }
コード例 #3
0
        public async Task EmptyTest()
        {
            var pipeline = FiltersPipelineFactory.Create(new IFilter[0], null);

            (await pipeline(Context)).Should().BeNull();
        }