示例#1
0
        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);
            }
        }
示例#2
0
        public void Constructor_ExpectedValues()
        {
            // Call
            using (var graphControl = new PointedTreeGraphControl())
            {
                // Assert
                Assert.IsInstanceOf <UserControl>(graphControl);
                Assert.IsInstanceOf <IPointedTreeGraphControl>(graphControl);

                Assert.IsNull(graphControl.Data);
                Assert.IsNull(graphControl.Selection);

                Assert.AreEqual(1, graphControl.Controls.Count);

                ZoomControl zoomControl = PointedTreeGraphControlHelper.GetZoomControl(graphControl);

                Assert.AreEqual(300, zoomControl.ZoomDeltaMultiplier);
                Assert.AreEqual(ZoomControlModes.Original, zoomControl.Mode);
                Assert.AreEqual(ZoomViewModifierMode.None, zoomControl.ModifierMode);
                Assert.AreEqual(new TimeSpan(0), zoomControl.AnimationLength);

                Assert.AreEqual(1, zoomControl.Resources.MergedDictionaries.Count);
                ResourceDictionary templateDictionary = zoomControl.Resources.MergedDictionaries.First();
                Assert.AreEqual("/Core.Components.GraphSharp.Forms;component/Templates/PointedTreeGraphTemplate.xaml", templateDictionary.Source.AbsolutePath);

                var graphLayout = (PointedTreeGraphLayout)zoomControl.Content;
                Assert.IsInstanceOf <PointedTreeGraph>(graphLayout.Graph);
            }
        }
示例#3
0
        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);
            }
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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);
            }
        }
示例#6
0
        private static PointedTreeGraph GetPointedTreeGraph(IllustrationPointsFaultTreeControl control)
        {
            var pointedTreeGraphControl = TypeUtils.GetField <PointedTreeGraphControl>(control, "pointedTreeGraphControl");

            return(PointedTreeGraphControlHelper.GetPointedTreeGraph(pointedTreeGraphControl));
        }