public void SubWorkflow() { // Arrange var workplan = WorkplanDummy.CreateSub(); var step = new SubworkflowStep(workplan); var exits = workplan.Connectors.Where(c => c.Classification.HasFlag(NodeClassification.Exit)).ToArray(); // Act var trans = step.CreateInstance(null); // Assert Assert.IsInstanceOf <SubworkflowTransition>(trans); Assert.AreEqual(2, step.Outputs.Length); Assert.AreEqual(2, step.OutputDescriptions.Length); var success = step.OutputDescriptions[0]; Assert.AreEqual("End", success.Name); Assert.AreEqual(OutputType.Success, success.OutputType); Assert.AreEqual(exits[0].Id, success.MappingValue); var failed = step.OutputDescriptions[1]; Assert.AreEqual("Failed", failed.Name); Assert.AreEqual(OutputType.Failure, failed.OutputType); Assert.AreEqual(exits[1].Id, failed.MappingValue); }
public void SubWorkflowTransition() { // Arrange var workplan = WorkplanDummy.CreateSub(); var exits = workplan.Connectors.Where(c => c.Classification.HasFlag(NodeClassification.Exit)).ToArray(); var outputs = new[] { new OutputDescription { MappingValue = (int)exits[0].Id }, new OutputDescription { MappingValue = (int)exits[1].Id }, }; var trans = new SubworkflowTransition(Workflow.CreateEngine(workplan, new NullContext()), TransitionBase.CreateIndexResolver(outputs)) { Id = 1, Inputs = new[] { _inputs[0] }, Outputs = _outputs }; var triggered = new List <ITransition>(); // Act trans.Initialize(); trans.Triggered += (sender, args) => triggered.Add((ITransition)sender); _inputs[0].Add(_token); // Assert Assert.AreEqual(0, _inputs[0].Tokens.Count()); Assert.AreEqual(_token, _outputs[0].Tokens.First()); Assert.AreEqual(2, triggered.Count); Assert.IsTrue(triggered.All(t => t is DummyTransition)); }