コード例 #1
0
            public async Task Exceptions_Dont_Prevent_PipelineComplete_Signal_From_Being_Sent()
            {
                var source = new FunctionBasedSource <int, int>();
                var stage  = new Mock <IStage <int, int> >();

                stage.Setup(s => s.Process(It.IsAny <Query <int, int> >(), It.IsAny <CancellationToken>()))
                .Throws <Exception>();

                var pipeline = new Pipeline <int, int>(source, stage.Object);
                await Assert.ThrowsAnyAsync <PipelineException <int, int> >(() => pipeline.GetAsync(new[] { 1 }));

                stage.Verify(s => s.SignalAsync(It.IsAny <PipelineComplete <int, int> >(), It.IsAny <CancellationToken>()), Times.Once);
            }
コード例 #2
0
            public async Task Retries_Returned_From_First_Stage_Are_Ignored()
            {
                var source = new FunctionBasedSource <int, int>();
                var stage  = new Mock <IStage <int, int> >();

                stage.Setup(s => s.Process(It.IsAny <Query <int, int> >(), It.IsAny <CancellationToken>()))
                .Returns <Query <int, int>, CancellationToken>((r, t) => new[] { new Retry <int, int>(r.Metadata, r.Ids) });

                var pipeline = new Pipeline <int, int>(source, stage.Object);
                var results  = await pipeline.GetAsync(new[] { 1, 2 });

                Assert.Empty(results);
            }