예제 #1
0
        private GraphModel CreateGraph()
        {
            // graph sceme:
            //   node1 -------------> node2 -------------> node3
            //          connection1          connection2

            var graph        = new GraphModel(new GraphType());
            var sourceType   = new SourceNode("test");
            var transferType = new NodeWithProperties();
            var destType     = new DestinationNode();

            var node1 = sourceType.CreateNode();

            graph.AddNode(node1);

            var node2 = transferType.CreateNode();

            graph.AddNode(node2);

            var node3 = destType.CreateNode();

            graph.AddNode(node3);

            var connection1 = graph.Connect(sourceType.Out.FromNode(node1), transferType.In.FromNode(node2));
            var connection2 = graph.Connect(transferType.Out.FromNode(node2), destType.In.FromNode(node3));

            (node2.PropertyBlock as NodeWithProperties.Properties).Value = "TestValue";

            return(graph);
        }
예제 #2
0
        public async Task ExecuteAsync_Should_Succeed_MultipleNodes()
        {
            // graph sceme:
            //   node1 -------------> node2 -------------> node3
            //          connection1          connection2

            var graph        = new GraphModel(GraphModelTests.CreateGraphType(new AppendConnection("+")));
            var sourceType   = new SourceNode("test");
            var transferType = new TransferNode();
            var destType     = new DestinationNode();

            var node1 = sourceType.CreateNode();

            graph.AddNode(node1);

            var node2 = transferType.CreateNode();

            graph.AddNode(node2);

            var node3 = destType.CreateNode();

            graph.AddNode(node3);

            var connection1 = graph.Connect(sourceType.Out.FromNode(node1), transferType.In.FromNode(node2));
            var connection2 = graph.Connect(transferType.Out.FromNode(node2), destType.In.FromNode(node3));

            var result = await graph.ExecuteAsync(ExecuteNodeAsync, ExecuteConnectionAsync);

            Assert.That(result, Is.Not.Null);

            var pv1 = GetPortValue <string>(sourceType.Out, result, node1);

            Assert.That(pv1.HasValue, Is.True);
            Assert.That(pv1.Value, Is.EqualTo("test"));

            var pv2 = GetPortValue <string>(transferType.Out, result, node2);

            Assert.That(pv2.HasValue, Is.True);
            Assert.That(pv2.Value, Is.EqualTo("test+"));

            var cv1 = GetConnectionValue <string>(result, connection1);

            Assert.That(cv1.HasValue, Is.True);
            Assert.That(cv1.Value, Is.EqualTo("test+"));

            var cv2 = GetConnectionValue <string>(result, connection2);

            Assert.That(cv2.HasValue, Is.True);
            Assert.That(cv2.Value, Is.EqualTo("test++"));

            Assert.That(destType.OutValue, Is.EqualTo("test++"));
        }