Exemple #1
0
        public void ExecuteWorkflow(ExecutionPath route, int expectedTransitions, string expectedPath)
        {
            // Arrange
            var workplan = WorkplanDummy.CreateFull();
            var engine   = Workflow.CreateEngine(workplan, new NullContext());

            // Act
            var triggerCount = 0;
            var path         = string.Empty;

            engine.TransitionTriggered += delegate(object sender, ITransition transition)
            {
                var dummy = (DummyTransition)transition;
                if (route == ExecutionPath.Alternative)
                {
                    dummy.ResultOutput = dummy.Outputs.Length - 1;
                }
                triggerCount++;
                path += "->" + dummy.Name;
            };
            engine.Completed += EngineCompleted;
            engine.Start();
            // Synchronus execution means we are done here
            Workflow.Destroy(engine);

            // Assert
            Assert.IsTrue(_completed);
            Assert.AreEqual(expectedTransitions, triggerCount, "Less transitions triggered than expected!");
            Assert.AreEqual(expectedPath, path, "Workflow engine did not take the correct path!");
        }
Exemple #2
0
        public void ValidateFullSuccess()
        {
            // Arrange
            var workplan = WorkplanDummy.CreateFull();

            // Act
            var validation = Workflow.Validate(workplan, ValidationAspect.DeadEnd | ValidationAspect.LoneWolf);

            // Assert
            Assert.IsTrue(validation.Success, "Validation did not return success for a valid workplan!");
            Assert.AreEqual(0, validation.Errors.Length, "Valid workplan must not report errors!");
        }
Exemple #3
0
        public void InstantiateWorkflow()
        {
            // Arrange
            var workplan = WorkplanDummy.CreateFull();

            // Act
            var context  = new FakeContext();
            var workflow = WorkflowFactory.Instantiate(workplan, context);

            // Simple assert
            Assert.AreEqual(workplan.Connectors.Count(), workflow.Places.Count(), "Not all connectors transformed to places!");
            Assert.AreEqual(workplan.Steps.Count(), workflow.Transitions.Count(), "Not all steps transformed to transitions!");
            Assert.IsTrue(workflow.Transitions.Cast <DummyTransition>().All(t => t.Context == context), "Context not passed to all transitions!");
            // Structure assert
            var transitions = workflow.Transitions;

            Assert.AreEqual(2, transitions[0].Outputs.Length);
            Assert.AreEqual(transitions[0].Outputs[1], transitions[1].Inputs[0]);
            Assert.AreEqual(transitions[0].Outputs[0], transitions[2].Inputs[0]);
            Assert.AreEqual(transitions[1].Outputs[0], transitions[2].Inputs[0]);
            Assert.AreEqual(transitions[2].Outputs[0], transitions[2].Outputs[1]);
            Assert.AreEqual(transitions[2].Outputs[0], workflow.EndPlaces().First());
        }