public void CreationThreeLevelCommandTest2() { var node = new CommandNode(); var command1 = new Command { Name = "show config" }; var command2 = new Command { Name = "show" }; node.Add(command1); node.Add(command2); 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 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"); }
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 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 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 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"); }