public void GivenGraphControlWithoutData_WhenDataSet_ThenGraphControlUpdated() { // Given using (var graphControl = new PointedTreeGraphControl()) { var doubleUsedNode = new GraphNode("<text>Double used</text>", new GraphNode[0], false); var node = new GraphNode("<text>Root</text>", new[] { new GraphNode("<text>Child 1</text>", new[] { doubleUsedNode }, false), new GraphNode("<text>Child 2</text>", new[] { doubleUsedNode }, false) }, false); PointedTreeGraph originalGraph = PointedTreeGraphControlHelper.GetPointedTreeGraph(graphControl); // When graphControl.Data = node; // Then PointedTreeGraph newGraph = PointedTreeGraphControlHelper.GetPointedTreeGraph(graphControl); Assert.AreNotSame(originalGraph, newGraph); Assert.AreEqual(5, newGraph.VertexCount); Assert.AreEqual(4, newGraph.EdgeCount); } }
public void GivenControlWithSelectedVertex_WhenOtherVertexSelected_FirstSelectedVertexUnselected() { // Given using (var graphControl = new PointedTreeGraphControl()) { var node = new GraphNode("<text>node 1</text>", new[] { new GraphNode("<text>node 2</text>", new GraphNode[0], true) }, true); graphControl.Data = node; PointedTreeGraph graph = PointedTreeGraphControlHelper.GetPointedTreeGraph(graphControl); PointedTreeElementVertex firstSelectedVertex = graph.Vertices.ElementAt(1); firstSelectedVertex.IsSelected = true; PointedTreeElementVertex newSelectedVertex = graph.Vertices.First(); // When newSelectedVertex.IsSelected = true; // Then Assert.IsFalse(firstSelectedVertex.IsSelected); } }
public void GivenGraphControlWithData_WhenDataSetToNull_ThenGraphControlUpdated() { // Given var node = new GraphNode("<text>Root</text>", new[] { new GraphNode("<text>Child 1</text>", new GraphNode[0], false) }, false); using (var graphControl = new PointedTreeGraphControl { Data = node }) { PointedTreeGraph graph = PointedTreeGraphControlHelper.GetPointedTreeGraph(graphControl); // Precondition Assert.AreEqual(2, graph.VertexCount); Assert.AreEqual(1, graph.EdgeCount); // When graphControl.Data = null; // Then graph = PointedTreeGraphControlHelper.GetPointedTreeGraph(graphControl); Assert.AreEqual(0, graph.VertexCount); Assert.AreEqual(0, graph.EdgeCount); } }
public void GivenControlWithData_WhenVertexSelected_SelectionSetToGraphNodeAndSelectionChangedFired() { // Given using (var graphControl = new PointedTreeGraphControl()) { var childNode = new GraphNode("<text>node 2</text>", new GraphNode[0], true); var node = new GraphNode("<text>node 1</text>", new[] { childNode }, true); graphControl.Data = node; PointedTreeGraph graph = PointedTreeGraphControlHelper.GetPointedTreeGraph(graphControl); var selectionChanged = 0; graphControl.SelectionChanged += (sender, args) => selectionChanged++; // Precondition Assert.IsNull(graphControl.Selection); // When PointedTreeElementVertex selectedVertex = graph.Vertices.ElementAt(1); selectedVertex.IsSelected = true; // Then Assert.AreSame(childNode, graphControl.Selection); Assert.AreEqual(1, selectionChanged); } }
private static PointedTreeGraph GetPointedTreeGraph(IllustrationPointsFaultTreeControl control) { var pointedTreeGraphControl = TypeUtils.GetField <PointedTreeGraphControl>(control, "pointedTreeGraphControl"); return(PointedTreeGraphControlHelper.GetPointedTreeGraph(pointedTreeGraphControl)); }