public void RestoreAndResume() { // Arrange var workplan = WorkplanDummy.CreatePausable(); var engine = Workflow.CreateEngine(workplan, new NullContext()); var stepId = workplan.Steps.Single(s => s is PausableStep).Id; var snapShot = new WorkflowSnapshot { Holders = new[] { new HolderSnapshot { HolderId = stepId, Tokens = new IToken[] { new MainToken() } } } }; // Act engine.Restore(snapShot); engine.Completed += EngineCompleted; engine.TransitionTriggered += (sender, transition) => { }; engine.Start(); // <-- This run to the end // Assert Assert.IsTrue(_completed); }
public void PauseAndResume() { // Arrange var workplan = WorkplanDummy.CreatePausable(); var engine = Workflow.CreateEngine(workplan, new NullContext()); engine.TransitionTriggered += (sender, transition) => { }; engine.Completed += EngineCompleted; // Act engine.Start(); // <-- This runs till the first pausable transition var snapShot = engine.Pause(); // Once we resume it will continue engine.Start(); // Assert var stepId = workplan.Steps.Single(s => s is PausableStep).Id; Assert.IsTrue(_completed); Assert.AreEqual(1, snapShot.Holders.Length); Assert.AreEqual(stepId, snapShot.Holders[0].HolderId); Assert.IsInstanceOf <MainToken>(snapShot.Holders[0].HolderState); Assert.AreEqual(1, snapShot.Holders[0].Tokens.Length); }