/// <summary> /// Insert test. /// /// This is the main body of the Insert Test. /// </summary> /// <param name="size">The size of the web.</param> /// <param name="insertAt">The insertAt point.</param> /// <param name="expected">The expected output.</param> private static void InsertNodeTest(uint size, uint insertAt, string expected) { //Refresh the whole hyperweb to size+1 nodes (including root) Node root = new Node(null); var curStat = root.CurrentState; List<Node> AllNodes = new List<Node>(new Node[] { root }); for (uint j = 0; j < size; j++) { Node n = new Node(null); root.InsertNode(n); AllNodes.Add(n); } //And add the node n+2, at insertion point i. Node n2 = new Node(null); AllNodes[(int)insertAt].InsertNode(n2); string actual = root.DumpAllNodes(); if (expected != actual) Assert.Fail("Failed on size " + size + ", insertAt " + insertAt + ":\n\n" + expected + "\n\n" + actual); }
private void InsertNodeTestCreate(uint size) { //Refresh the whole hyperweb to size+1 nodes (including root) Node root = new Node(null); var curStat = root.CurrentState; for (uint j = 0; j < size; j++) root.InsertNode(new Node(null)); //And add the node n+2, at insertion point i. root.InsertNode(new Node(null)); string actual = root.DumpAllNodes(); TextWriter tr = new StreamWriter(File.OpenWrite(@"C:\Users\joel.day3\Documents\Visual Studio 2008\Projects\school\cs340project\cs340project\UnitTesting\TestNodeData\" + (size + 1).ToString() + "Nodes.txt")); tr.Write(actual); tr.Close(); }
public void RemoveTest() { TextReader tr = new StreamReader(Assembly.GetExecutingAssembly() .GetManifestResourceStream("UnitTesting.TestNodeData.2Nodes.txt")); string expected = tr.ReadToEnd(); Node root = new Node(null); List<Node> AllNodes = new List<Node>(new Node[] { root }); for (uint j = 0; j < 3; j++) { Node n = new Node(null); root.InsertNode(n); AllNodes.Add(n); } //Remove the node they wanted us to. AllNodes[3].RemoveById(3); string actual = root.DumpAllNodes(); if (expected != actual) Assert.Fail("Failed on size 4"); }