public void GetLinearNodesTest() { var node = new CommandNode(); var command1 = new Command { Name = "show config" }; var command2 = new Command { Name = "show" }; var command3 = new Command { Name = "show test" }; var command4 = new Command { Name = "linear" }; node.Add(command1); node.Add(command2); node.Add(command3); node.Add(command4); int count = 0; foreach (var n in node.LinearNodes) { count++; } Assert.IsTrue(count == 4); }
public void BuildFromFile() { string refsText = Path.GetFullPath(Path.Combine(DataPath, "refs.txt")); string rawLine = "::from ./bsinstalldir.txt"; CommandNode root = new CommandNode(rawLine); LeafNode childToAdd = new LeafNode(@"""Beat Saber_Data/"); root.Add(childToAdd); childToAdd = new LeafNode(@"""""Managed/"); root.Add(childToAdd); childToAdd.Add(new FileNode(@"""""""Unity.TextMeshPro.dll?virt?alias=UnityAlias.TextMeshPro.dll")); childToAdd.Add(new FileNode(@"""""""UnityEngine.dll")); PrintChildren(root); }
public void CreationThreeLevelCommandTest1() { var node = new CommandNode(); var command1 = new Command { Name = "show config" }; var command2 = new Command { Name = "show" }; node.Add(command2); node.Add(command1); Assert.IsTrue(node.Parent == null); Assert.IsNull(node.Command); Assert.IsTrue(node.Nodes.ContainsKey("show")); Assert.IsTrue(node.Nodes["show"].Command == command2); Assert.IsTrue(node.Nodes["show"].Nodes.ContainsKey("config")); Assert.IsTrue(node.Nodes["show"].Nodes["config"].Command == command1); }
public void GetFullNameTest() { var node = new CommandNode(); var command1 = new Command { Name = "show config" }; var command2 = new Command { Name = "show" }; var command3 = new Command { Name = "show test" }; node.Add(command1); node.Add(command2); node.Add(command3); Assert.IsTrue(node.Nodes["show"].FullName == "show"); Assert.IsTrue(node.Nodes["show"].Nodes["config"].FullName == "show config"); Assert.IsTrue(node.Nodes["show"].Nodes["test"].FullName == "show test"); }
public void SearchDeeperTest4() { var node = new CommandNode(); var command1 = new Command { Name = "show config" }; var command2 = new Command { Name = "show" }; var command3 = new Command { Name = "show test" }; node.Add(command1); node.Add(command2); node.Add(command3); string line = "show"; Assert.IsTrue(node.SearchDeeper(ref line).FullName == "show"); Assert.IsTrue(String.IsNullOrEmpty(line)); }
public void SearchThreeLevelCommandTest2() { var node = new CommandNode(); var command1 = new Command { Name = "show config" }; var command2 = new Command { Name = "show" }; node.Add(command1); node.Add(command2); List <CommandNode> cn1 = node.Search("show"); Assert.IsNotNull(cn1); Assert.IsTrue(cn1.Count == 1); Assert.IsTrue(cn1.First().Name == "show"); Assert.IsNotNull(cn1.First().Command); List <CommandNode> cn2 = node.Search("test"); Assert.IsNotNull(cn2); Assert.IsTrue(cn2.Count == 0); List <CommandNode> cn3 = node.Search("sh"); Assert.IsNotNull(cn3); Assert.IsTrue(cn3.First().Name == "show"); Assert.IsNotNull(cn3.Count == 1); List <CommandNode> cn4 = node.Search("show c"); Assert.IsNotNull(cn4); Assert.IsTrue(cn4.First().Name == "config"); Assert.IsNotNull(cn3.Count == 1); }
public void CreationOneLevelCommandTest() { var node = new CommandNode(); var command = new Command() { Name = "show" }; node.Add(command); Assert.IsTrue(node.Parent == null); Assert.IsNull(node.Command); Assert.IsTrue(node.Nodes.ContainsKey("show")); Assert.IsTrue(node.Nodes["show"].Command == command); // Assert.IsTrue(node.Nodes.First().Value.First().Command == "show"); }
/// <summary> /// Add command to list of all commands. /// </summary> /// <param name="command"></param> internal void AddCommand(YCommand command) { lock (savedCommands) { int structureLength = command.Structure.Count; if (structureLength > maxLength) { maxLength = structureLength; } if (savedCommands.TryGetValue(structureLength, out CommandNode node)) { node.Add(command); } else { node = new CommandNode(structureLength); node.Add(command); savedCommands.Add(structureLength, node); } } }