Exemple #1
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);
        }
Exemple #2
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));
        }
Exemple #3
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 + "'");
        }