public void ToStringReturnsElementsInOrder() { // Arrange var sut = new Node <int>(5); sut.Insert(6); sut.Insert(7); sut.Insert(4); sut.Insert(3); // Act var toString = sut.ToString(); // Assert var values = toString.Split(',', 0); for (int i = 1; i < values.Length - 1; i++) { Assert.Greater(values[i], values[i - 1]); } }
partial void test_math_nodeToolStripMenuItem_Click(object sender, EventArgs e) { string log = ""; Node a = new Node(); // test constructor log += "\nNode " + a.ToString(); a.ID = 0; // test ID Node b = new Node(1); // test constructor log += "\n\nNode " + a.ToString(); log += "\nNode " + b.ToString(); object[] c0 = { 1.19, 4.23 }; a.Coordinate = c0; object[] c1 = { 2.90, 3.01 }; b.Coordinate = c1; // test coordinate object[] c2 = { 1.09, 0.98 }; Node c = new Node(2, c2); // test constructor Node[] n = { a, b, c }; log += "\n"; for (int i = 0; i < n.Length; i++) { log += "\nNode " + n[i].ToString(); } Math.Vector x, y, z; // connect node 0 to node 1 with directed edge x = new Math.Vector((double)a.Coordinate[0], (double)a.Coordinate[1]); y = new Math.Vector((double)b.Coordinate[0], (double)b.Coordinate[1]); z = y - x; DirectedEdge e0 = new DirectedEdge(a, b); e0.Weight = z.Magnitude; a.Add(e0); b.Add(e0); // connect node 1 to node 2 with directed edge x = new Math.Vector((double)b.Coordinate[0], (double)b.Coordinate[1]); y = new Math.Vector((double)c.Coordinate[0], (double)c.Coordinate[1]); z = y - x; DirectedEdge e1 = new DirectedEdge(b, c); e1.Weight = z.Magnitude; b.Add(e1); c.Add(e1); // connect node 2 to node 0 with edge x = new Math.Vector((double)c.Coordinate[0], (double)c.Coordinate[1]); y = new Math.Vector((double)a.Coordinate[0], (double)a.Coordinate[1]); z = y - x; Edge e2 = (Edge) new Edge() .Configure(c, a); e2.Weight = z.Magnitude; c.Add(e2); a.Add(e2); log += "\n"; for (int i = 0; i < n.Length; i++) { log += "\nNode " + n[i].ToString(); } richTextBox.Text = log; }
public void ToStringTest() { Assert.True(n.ToString() == c.ToString()); }