public async Task TestRunTwoPipelinesInParallel() { IStepTracker fakeTracker1 = A.Fake <IStepTracker>(); IStepTracker fakeTracker2 = A.Fake <IStepTracker>(); IPipeline pipeline1 = new Pipeline(); IPipeline pipeline2 = new Pipeline(); pipeline1.registerRootStep(new StepA(fakeTracker1)); pipeline1.registerStep(new StepB(fakeTracker1)); pipeline1.registerStep(new StepC(fakeTracker1)); pipeline1.registerStep(new StepD(fakeTracker1)); pipeline2.registerRootStep(new StepAWithPipelineState(fakeTracker2)); pipeline2.registerStep(new StepBWithPipelineState(fakeTracker2)); pipeline2.SetPipelineState(new MyCustomPipelineState()); Task task1 = pipeline1.Run(); Task task2 = pipeline2.Run(); await Task.WhenAll(task1, task2); A.CallTo(() => fakeTracker1.Track("StepA")).MustHaveHappened() .Then(A.CallTo(() => fakeTracker1.Track("StepB")).MustHaveHappened()) .Then(A.CallTo(() => fakeTracker1.Track("StepC")).MustHaveHappened()) .Then(A.CallTo(() => fakeTracker1.Track("StepD")).MustHaveHappened()); MyCustomPipelineState finalState = pipeline2.GetCurrentPipelineState <MyCustomPipelineState>(); Assert.AreEqual("Hello World!", finalState.FirstName); Assert.AreEqual("", finalState.LastName); }
public async Task TestPipelineStateAccross2Steps() { IPipeline pipeline = new Pipeline(); IStepTracker fakeStepTracker = A.Fake <IStepTracker>(); pipeline.registerRootStep(new StepAWithPipelineState(fakeStepTracker)); pipeline.registerStep(new StepBWithPipelineState(fakeStepTracker)); MyCustomPipelineState state = new MyCustomPipelineState(); state.FirstName = ""; state.LastName = ""; pipeline.SetPipelineState(state); await pipeline.Run(); A.CallTo(() => fakeStepTracker.Track("Bill")).MustHaveHappened() .Then(A.CallTo(() => fakeStepTracker.Track("Gates")).MustHaveHappened()); MyCustomPipelineState finalState = pipeline.GetCurrentPipelineState <MyCustomPipelineState>(); Assert.AreEqual("Hello World!", finalState.FirstName); Assert.AreEqual("", finalState.LastName); }
public override async Task ExecuteAsync(NextStepAction nextStep, params object[] arguments) { Console.WriteLine($"{DateTime.Now} - StepAWithPipelineState"); MyCustomPipelineState state = GetPipelineState <MyCustomPipelineState>(); state.FirstName = "Bill"; state.LastName = "Gates"; await Task.Delay(2000); await nextStep(); }
public async Task TestPipelineState() { IPipeline pipeline = new Pipeline(); IStepTracker fakeStepTracker = A.Fake <IStepTracker>(); pipeline.registerRootStep(new StepAWithPipelineState(fakeStepTracker)); MyCustomPipelineState state = new MyCustomPipelineState(); state.FirstName = ""; state.LastName = ""; pipeline.SetPipelineState(state); await pipeline.Run(); Assert.AreEqual("Bill", state.FirstName); Assert.AreEqual("Gates", state.LastName); }