public static void WellFormatedWhitespaceNewNodeCommand() { string s = BaseGraphCLI.GenerateNewNodeCommand(typeof(NodeAdd), "add node name"); BaseGraphCommand cmd = BaseGraphCLI.Parse(s); Assert.That(cmd.type == BaseGraphCommandType.NewNode); Assert.That(cmd.nodeType == typeof(NodeAdd)); Assert.That(cmd.name == "add node name"); Assert.That(cmd.forcePositon == false); }
public static void WellFormatedNewNodeWithPositionCommand() { string s = BaseGraphCLI.GenerateNewNodeCommand(typeof(NodeAdd), "addName", new Vector2(42, -42)); BaseGraphCommand cmd = BaseGraphCLI.Parse(s); Assert.That(cmd.type == BaseGraphCommandType.NewNodePosition, "Bad command type: " + cmd.type + " instead of " + BaseGraphCommandType.NewNodePosition); Assert.That(cmd.nodeType == typeof(NodeAdd), "Bad node type: " + cmd.nodeType + " instead of " + typeof(NodeAdd)); 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)); }
public static void WellFormatedNewNodeWithPositionAndDataCommand() { string s = BaseGraphCLI.GenerateNewNodeCommand(typeof(NodePerlinNoise2D), "perlin noise", new Vector2(21, 84), new BaseGraphCLIAttributes { { "persistence", 1.4f }, { "octaves", 2 } }); BaseGraphCommand cmd = BaseGraphCLI.Parse(s); var parsedAttrs = Jsonizer.Parse(cmd.attributes); var persistenceAttr = parsedAttrs[0]; var octavesAttr = parsedAttrs[1]; Assert.That(persistenceAttr.first == "persistence", "The persistence name expected to be 'persistence' but was '" + persistenceAttr.first + "'"); Assert.That((float)persistenceAttr.second == 1.4f, "The persistence value expected to be 1.4 but was '" + persistenceAttr.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 + "'"); }