public void AsyncPipeline_Execution_Cancellation_Test() { //Arrange PipelineComponentResolver.AddAsync(new DelayComponent(), new BarComponent()); var types = new List <Type> { typeof(DelayComponent), typeof(BarComponent) }; var config = types.ToDictionary <Type, string, IDictionary <string, string> >( t => t.Name, t => new Dictionary <string, string> { { "test", "value" } }); var cts = new CancellationTokenSource(TimeSpan.FromSeconds(2)); var target = new AsyncPipeline <TestPayload>(PipelineComponentResolver, types, config, null); //Act Func <Task <TestPayload> > act = () => target.ExecuteAsync(new TestPayload(), cts.Token); //Assert act.Should().Throw <OperationCanceledException>(); }
public void Pipeline_TerminateExecution_Test() { //Arrange PipelineComponentResolver.Add(new FooComponent(), new PipelineExecutionTerminatingComponent(), new BarComponent()); var types = new List <Type> { typeof(FooComponent), typeof(PipelineExecutionTerminatingComponent), typeof(BarComponent) }; var config = types.ToDictionary <Type, string, IDictionary <string, string> >( t => t.Name, t => new Dictionary <string, string> { { "test", "value" } }); var target = new Pipeline <TestPayload>(PipelineComponentResolver, types, config, null); //Act var result = target.Execute(new TestPayload()); //Assert result.Should().NotBeNull(); result.Count.Should().Be(2); result.FooStatus.Should().Be($"{nameof(FooComponent)} executed!"); result.BarStatus.Should().BeNull(); }
public void AsyncPipelineComponent_Exception_Test() { //Arrange PipelineComponentResolver.AddAsync(new FooComponent(), new BarExceptionComponent()); var types = new List <Type> { typeof(FooComponent), typeof(BarExceptionComponent) }; var config = types.ToDictionary <Type, string, IDictionary <string, string> >( t => t.Name, t => new Dictionary <string, string> { { "test", "value" } }); var target = new AsyncPipeline <TestPayload>(PipelineComponentResolver, types, config, null); //Act Func <Task <TestPayload> > act = () => target.ExecuteAsync(new TestPayload()); //Assert act.Should().ThrowExactly <PipelineExecutionException>() .And.InnerException.Should().BeOfType <NotImplementedException>(); }