Esempio n. 1
0
        public void PerlinNoiseNodeToDebugNodeParsedCommands()
        {
            var builder = PWGraphBuilder.NewGraph <PWMainGraph>()
                          .NewNode(typeof(PWNodePerlinNoise2D), "perlin")
                          .NewNode(typeof(PWNodeDebugInfo), "debug")
                          .Link("perlin", "debug");

            //list of the expected created commands
            List <PWGraphCommand> expectedCommands = new List <PWGraphCommand>()
            {
                new PWGraphCommand(typeof(PWNodePerlinNoise2D), "perlin"),
                new PWGraphCommand(typeof(PWNodeDebugInfo), "debug"),
                new PWGraphCommand("perlin", "debug"),
            };

            //get the commands as string
            var builderCommands = builder.GetCommands();

            for (int i = 0; i < expectedCommands.Count; i++)
            {
                //Parse the command and get the resulting command object
                PWGraphCommand cmd = PWGraphCLI.Parse(builderCommands[i]);

                Assert.That(cmd == expectedCommands[i]);
            }
        }
Esempio n. 2
0
        public void WhiteSpaceLinkCommand()
        {
            PWGraphCommand cmd = PWGraphCLI.Parse("    	 	 	Link 		 	 node1   	node2	 	      ");

            Assert.That(cmd.type == PWGraphCommandType.Link);
            Assert.That(cmd.fromNodeName == "node1");
            Assert.That(cmd.toNodeName == "node2");
        }
Esempio n. 3
0
        public void WellFormatedLinkCommandNameWhitespaces()
        {
            string         s   = PWGraphCLI.GenerateLinkCommand("node 1", "node 2");
            PWGraphCommand cmd = PWGraphCLI.Parse(s);

            Assert.That(cmd.type == PWGraphCommandType.Link);
            Assert.That(cmd.fromNodeName == "node 1");
            Assert.That(cmd.toNodeName == "node 2");
        }
Esempio n. 4
0
        public void WhiteSpaceNewNodeWithPositionCommand()
        {
            PWGraphCommand cmd = PWGraphCLI.Parse("  	  NewNode 	      PWNodeAdd  	    add  	    (  	 42,   -42 	   )	 ");

            Assert.That(cmd.type == PWGraphCommandType.NewNodePosition);
            Assert.That(cmd.nodeType == typeof(PWNodeAdd));
            Assert.That(cmd.name == "add");
            Assert.That(cmd.forcePositon == true);
            Assert.That(cmd.position == new Vector2(42, -42));
        }
Esempio n. 5
0
        public void WellFormatedWhitespaceNewNodeCommand()
        {
            string         s   = PWGraphCLI.GenerateNewNodeCommand(typeof(PWNodeAdd), "add node name");
            PWGraphCommand cmd = PWGraphCLI.Parse(s);

            Assert.That(cmd.type == PWGraphCommandType.NewNode);
            Assert.That(cmd.nodeType == typeof(PWNodeAdd));
            Assert.That(cmd.name == "add node name");
            Assert.That(cmd.forcePositon == false);
        }
Esempio n. 6
0
        public void WellFormatedNewNodeWithPositionCommand()
        {
            string         s   = PWGraphCLI.GenerateNewNodeCommand(typeof(PWNodeAdd), "addName", new Vector2(42, -42));
            PWGraphCommand cmd = PWGraphCLI.Parse(s);

            Assert.That(cmd.type == PWGraphCommandType.NewNodePosition, "Bad command type: " + cmd.type + " instead of " + PWGraphCommandType.NewNodePosition);
            Assert.That(cmd.nodeType == typeof(PWNodeAdd), "Bad node type: " + cmd.nodeType + " instead of " + typeof(PWNodeAdd));
            Assert.That(cmd.name == "addName", "Bad node name: " + cmd.name + " instead of addName");
            Assert.That(cmd.forcePositon == true, "Forceposition is false but expected to be true");
            Assert.That(cmd.position == new Vector2(42, -42), "Bad node position: " + cmd.position + " instead of " + new Vector2(42, -42));
        }
Esempio n. 7
0
        public void WellFormatedLinkAnchorNameCommand()
        {
            string         s   = PWGraphCLI.GenerateLinkAnchorNameCommand("node1", "a1", "node2", "a2");
            PWGraphCommand cmd = PWGraphCLI.Parse(s);

            Assert.That(cmd.type == PWGraphCommandType.LinkAnchorName);
            Assert.That(cmd.fromNodeName == "node1");
            Assert.That(cmd.toNodeName == "node2");
            Assert.That(cmd.fromAnchorFieldName == "a1");
            Assert.That(cmd.toAnchorFieldName == "a2");
        }
Esempio n. 8
0
        public void WellFormatedLinkAnchorCommandNameWhitespaces()
        {
            string         s   = PWGraphCLI.GenerateLinkAnchorCommand("node 1", 1, "node 2", 4);
            PWGraphCommand cmd = PWGraphCLI.Parse(s);

            Assert.That(cmd.type == PWGraphCommandType.LinkAnchor);
            Assert.That(cmd.fromNodeName == "node 1");
            Assert.That(cmd.toNodeName == "node 2");
            Assert.That(cmd.fromAnchorIndex == 1);
            Assert.That(cmd.toAnchorIndex == 4);
        }
Esempio n. 9
0
        public void WellFormatedNewNodeWithPositionAndDataCommand()
        {
            string s = PWGraphCLI.GenerateNewNodeCommand(typeof(PWNodePerlinNoise2D), "perlin noise", new Vector2(21, 84), new PWGraphCLIAttributes()
            {
                { "persistance", 1.4f }, { "octaves", 2 }
            });
            PWGraphCommand cmd = PWGraphCLI.Parse(s);

            var parsedAttrs     = PWJson.Parse(cmd.attributes);
            var persistanceAttr = parsedAttrs[0];
            var octavesAttr     = parsedAttrs[1];

            Assert.That(persistanceAttr.first == "persistance", "The persistance name expected to be 'persistance' but was '" + persistanceAttr.first + "'");
            Assert.That((float)persistanceAttr.second == 1.4f, "The persistance value expected to be 1.4 but was '" + persistanceAttr.second + "'");
            Assert.That(octavesAttr.first == "octaves", "The octaves name expected to be 'octaves' but was '" + octavesAttr.first + "'");
            Assert.That((int)octavesAttr.second == 2, "The octaves value expected to be 2 but was '" + octavesAttr.second + "'");
        }
Esempio n. 10
0
        public void SliderNodeToAddNodeWithAnchorLink()
        {
            var builder = PWGraphBuilder.NewGraph <PWMainGraph>()
                          .NewNode <PWNodeSlider>("s1")
                          .NewNode <PWNodeSlider>("s2")
                          .NewNode <PWNodeSlider>("s3")
                          .NewNode <PWNodeSlider>("s4")
                          .NewNode <PWNodeAdd>("add")
                          .Link("s1", "outValue", "add", "values")
                          .Link("s2", "outValue", "add", "values")
                          .Link("s3", 1, "add", 1)
                          .Link("s4", 1, "add", 1);

            var expectedCommands = new List <PWGraphCommand>()
            {
                new PWGraphCommand(typeof(PWNodeSlider), "s1"),
                new PWGraphCommand(typeof(PWNodeSlider), "s2"),
                new PWGraphCommand(typeof(PWNodeSlider), "s3"),
                new PWGraphCommand(typeof(PWNodeSlider), "s4"),
                new PWGraphCommand(typeof(PWNodeAdd), "add"),
                new PWGraphCommand("s1", "outValue", "add", "values"),
                new PWGraphCommand("s2", "outValue", "add", "values"),
                new PWGraphCommand("s3", 1, "add", 1),
                new PWGraphCommand("s4", 1, "add", 1),
            };

            var commands = builder.GetCommands();

            for (int i = 0; i < expectedCommands.Count; i++)
            {
                //Parse the command and get the resulting command object
                PWGraphCommand cmd = PWGraphCLI.Parse(commands[i]);

                Assert.That(cmd == expectedCommands[i]);
            }
        }