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));
        }
        public void SubworkflowPause()
        {
            // Arrange
            var workplan = WorkplanDummy.CreatePausableSub();
            var exits    = workplan.Connectors.Where(c => c.Classification.HasFlag(NodeClassification.Exit)).ToArray();
            var outputs  = new[]
            {
                new OutputDescription {
                    MappingValue = (int)exits[0].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);
            trans.Pause();
            var state = trans.InternalState;

            trans.Resume();

            // Assert
            Assert.AreEqual(0, _inputs[0].Tokens.Count());
            Assert.AreEqual(_token, _outputs[0].Tokens.First());
            Assert.AreEqual(1, triggered.Count);
            Assert.IsInstanceOf <WorkflowSnapshot>(state);
            var snapshot = (WorkflowSnapshot)state;

            Assert.AreEqual(1, snapshot.Holders.Length);
            var stepId = workplan.Steps.First(s => s is PausableStep).Id;

            Assert.AreEqual(stepId, snapshot.Holders[0].HolderId);
        }