Exemplo n.º 1
0
        public void AddsIncomingTransitionOnNode()
        {
            var model = new WorkflowDefinitionModel();
            model.Nodes.Add(new NodeModel
            {
                Identifier = "node",
                OutgoingTransitions = new[]
                {
                    new TransitionModel
                    {
                        Identifier = "transitionId",
                        Source = "node",
                        Destination = "destNode"
                    }
                }
            });
            model.Nodes.Add(new NodeModel
            {
                Identifier = "destNode"
            });
            var transformer = new Transform.WorkflowDefinitionTransformer();

            IWorkflowDefinition definition = transformer.TransformBack(model);

            var destNode = definition.Nodes.First(n => n.Identifier == "destNode");
            Assert.That(destNode.IncomingTransitions.Count(), Is.EqualTo(1));
            var transition = destNode.IncomingTransitions.First();
            Assert.That(transition.Identifier, Is.EqualTo("transitionId"));
            Assert.That(transition.Source.Identifier, Is.EqualTo("node"));
        }
Exemplo n.º 2
0
        public void AddsNestedWorkflow()
        {
            var model = new WorkflowDefinitionModel();
            model.Nodes.Add(new NodeModel
            {
                Identifier = "node",
                OutgoingTransitions = new[]
                {
                    new TransitionModel
                    {
                        Identifier = "transitionId",
                        Source = "node",
                        Destination = "nested"
                    }
                }
            });
            model.Nodes.Add(new WorkflowDefinitionModel
            {
                Identifier = "nested",
                OperationType = typeof (TakeDefaultTransitionOperation).AssemblyQualifiedName
            });
            var transformer = new Transform.WorkflowDefinitionTransformer();

            IWorkflowDefinition definition = transformer.TransformBack(model);

            var nestedWorkflow = definition.Nodes.FirstOrDefault(n => n.Identifier == "nested");
            Assert.That(nestedWorkflow, Is.Not.Null);
            Assert.That(nestedWorkflow, Is.InstanceOf<IWorkflowDefinition>());
        }
Exemplo n.º 3
0
        public void SetsWorkflowIdentifier()
        {
            var model = new WorkflowDefinitionModel {Identifier = "identifier"};
            model.Nodes.Add(new NodeModel
            {
                Identifier = "node"
            });
            var transformer = new Transform.WorkflowDefinitionTransformer();

            IWorkflowDefinition definition = transformer.TransformBack(model);

            Assert.That(definition.Identifier, Is.EqualTo("identifier"));
        }
Exemplo n.º 4
0
        public void SetsStartNodePropertyOnNode()
        {
            var model = new WorkflowDefinitionModel();
            model.Nodes.Add(new NodeModel
            {
                Identifier = "node",
                IsInitialNode = true
            });
            var transformer = new Transform.WorkflowDefinitionTransformer();

            IWorkflowDefinition definition = transformer.TransformBack(model);

            var node = definition.Nodes.First();
            Assert.That(definition.InitialNode, Is.EqualTo(node));
        }
Exemplo n.º 5
0
        public void SetsDefaultPropertyOnTransition()
        {
            var model = new WorkflowDefinitionModel();
            model.Nodes.Add(new NodeModel
            {
                Identifier = "node",
                OutgoingTransitions = new[]
                {
                    new TransitionModel
                    {
                        Identifier = "transitionId",
                        IsDefault = true,
                        Source = "node",
                        Destination = "destNode"
                    }
                }
            });
            model.Nodes.Add(new NodeModel
            {
                Identifier = "destNode"
            });
            var transformer = new Transform.WorkflowDefinitionTransformer();

            IWorkflowDefinition definition = transformer.TransformBack(model);

            var transition = definition.Nodes.First(n => n.Identifier == "node").OutgoingTransitions.First();
            Assert.That(transition.IsDefault);
        }
Exemplo n.º 6
0
        public void ReturnsEmptyWorkflowDefinitionIfModelIsEmpty()
        {
            var model = new WorkflowDefinitionModel();
            var transformer = new Transform.WorkflowDefinitionTransformer();

            IWorkflowDefinition definition = transformer.TransformBack(model);

            Assert.That(definition, Is.Not.Null);
            Assert.That(definition.Nodes, Is.Empty);
            Assert.That(definition.OutgoingTransitions, Is.Empty);
            Assert.That(definition.IncomingTransitions, Is.Empty);
        }
Exemplo n.º 7
0
        public void AddsOperationToNode()
        {
            var model = new WorkflowDefinitionModel();
            model.Nodes.Add(new NodeModel
            {
                Identifier = "node",
                OperationType = typeof (TestOperation).AssemblyQualifiedName
            });
            var transformer = new Transform.WorkflowDefinitionTransformer();

            IWorkflowDefinition definition = transformer.TransformBack(model);

            Assert.That(definition.Nodes.First().Operation, Is.EqualTo(typeof (TestOperation)));
        }
Exemplo n.º 8
0
        public void AddsNode()
        {
            var model = new WorkflowDefinitionModel();
            model.Nodes.Add(new NodeModel
            {
                Identifier = "node"
            });
            var transformer = new Transform.WorkflowDefinitionTransformer();

            IWorkflowDefinition definition = transformer.TransformBack(model);

            Assert.That(definition.Nodes.Count, Is.EqualTo(1));
            Assert.That(definition.Nodes.First().Identifier, Is.EqualTo("node"));
        }