public async void PipelineRunner_Does_Not_Execute_When_Processors_Collection_Is_Null() { var pipelineRunner = new PipelineRunner(); var pipeline = new Mock <IPipeline>(); pipeline.Setup(x => x.GetProcessors()).Returns((IEnumerable <IProcessor>)null); await pipelineRunner.RunPipeline(pipeline.Object, string.Empty); }
public async void PipelineRunner_Uses_Declared_Processors_In_Pipeline() { var pipelineRunner = new PipelineRunner(); var pipeline = new Mock <IPipeline>(); pipeline.Setup(x => x.GetProcessors()).Returns(Enumerable.Empty <IProcessor>()); await pipelineRunner.RunPipeline(pipeline.Object, string.Empty); pipeline.Verify(x => x.GetProcessors(), Times.AtLeastOnce); }
public async void Pipeline_Mechanism_Produces_A_Simple_Check_Before_Returning_A_Result() { PipelineRunner runner = new PipelineRunner(); var arguments = new HelloWorldArguments { Name = " " }; await runner.RunPipeline(new HelloWorldPipelineWithValidation(), arguments); arguments.GetMessages(MessageFilter.Errors).Should().ContainSingle(pipelineMessage => pipelineMessage.Message.Equals(HelloWorldPipelineMessages.NameMustBeProvided)); }
public async void Pipeline_Mechanism_Is_Able_To_Produce_A_Simple_Result() { PipelineRunner runner = new PipelineRunner(); var arguments = new HelloWorldArguments() { Name = "Sergey" }; await runner.RunPipeline(new HelloWorldPipeline(), arguments); arguments.Result.Should().Be("Hello, Sergey!", $"we've passed name '{arguments.Name}' to the pipeline, and expect it to be displayed in phrase 'Hello, {arguments.Name}!'"); }
public async void PipelineRunner_Executes_Processors_In_The_Collection_In_Exact_Order() { var pipelineRunner = new PipelineRunner(); var executionSequence = new MockSequence(); var mockRepository = new MockRepository(MockBehavior.Strict); var a = mockRepository.Create <IProcessor>(); var b = mockRepository.Create <IProcessor>(); var c = mockRepository.Create <IProcessor>(); a.InSequence(executionSequence).Setup(x => x.Execute(It.IsAny <object>())).Returns(Task.CompletedTask); b.InSequence(executionSequence).Setup(x => x.Execute(It.IsAny <object>())).Returns(Task.CompletedTask); c.InSequence(executionSequence).Setup(x => x.Execute(It.IsAny <object>())).Returns(Task.CompletedTask); var pipeline = new Mock <IPipeline>(); pipeline.Setup(x => x.GetProcessors()).Returns(new [] { a.Object, b.Object, c.Object }); await pipelineRunner.RunPipeline(pipeline.Object, string.Empty); }