Exemplo n.º 1
0
        public void Test_AddAttribute()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());

            //Graph, Node, Edge attribute
            gvp.AddAttribute(AttrType.Graph, new IDisID("x", "y"));
            string tmp = gvp.graph.ToCode();

            if (!tmp.Contains("graph [x=y;]"))
            {
                Assert.Fail("Attr_stmt type attribute not found.");
            }

            //Specific node attribute
            gvp.AddNode("a");
            gvp.AddAttribute(AttrType.SpecificNode, new IDisID("x", "y"), "a");
            tmp = gvp.graph.ToCode();
            if (!tmp.Contains("a [x=y;]"))
            {
                Assert.Fail("Node attribute not found.");
            }

            //Specific node attribute
            gvp.AddEdge("a", "b");
            gvp.AddAttribute(AttrType.SpecificEdge, new IDisID("x", "y"), "a", "b");
            tmp = gvp.graph.ToCode();
            if (!tmp.Contains("a -> b [x=y;]"))
            {
                Assert.Fail("Edge attribute not found.");
            }
        }
Exemplo n.º 2
0
        public void Test_AddEdge()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());

            gvp.AddNode("tn1");
            gvp.AddNode("tn2");
            gvp.AddEdge("tn1", "tn2");
            gvp.AddEdge("tn3", "tn4");
            gvp.AddEdge("tn2", "tn3");
            string tmp = gvp.graph.ToCode();

            if (!tmp.Contains("tn1 -> tn2"))
            {
                Assert.Fail("Edge between existing nodes not found.");
            }
            if (!tmp.Contains("tn2 -> tn3"))
            {
                Assert.Fail("Edge between two other edges not found.");
            }
            if (!tmp.Contains("tn3 -> tn4"))
            {
                Assert.Fail("Edge between new nodes not found.");
            }
        }
Exemplo n.º 3
0
        public void Test_EdgeExists()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());

            gvp.AddEdge("a", "b");
            if (!gvp.EdgeExists("a", "b"))
            {
                Assert.Fail("Edge not found.");
            }
        }
Exemplo n.º 4
0
        public void Test_FindEdge()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());

            gvp.AddEdge("a", "b");

            if (gvp.FindEdge("a", "b") == null)
            {
                Assert.Fail("Edge not found.");
            }
        }
Exemplo n.º 5
0
        public void Test_AddNode()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());

            gvp.AddNode("testNode");
            string tmp = gvp.graph.ToCode();

            if (!tmp.Contains("testNode"))
            {
                Assert.Fail("Node not found.");
            }
        }
Exemplo n.º 6
0
        public void Test_ExportImage()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.DotCode = "digraph{a->b}";
            gvp.GenerateGraph();

            gvp.ExportImage(@".\external\testImage.png");

            if (!File.Exists(@".\external\testImage.png"))
            {
                Assert.Fail("Exported image not found.");
            }
        }
Exemplo n.º 7
0
        public void Test_ClearGraph()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());

            gvp.AddNode("a");

            gvp.ClearGraph();

            if (gvp.NodeExists("a"))
            {
                Assert.Fail("Node found after clearing graph.");
            }
        }
Exemplo n.º 8
0
        public void Test_GenerateGraph()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.DotCode = "digraph{a->b}";
            gvp.GenerateGraph();

            if (!File.Exists(@".\external\dotInput.png"))
            {
                Assert.Fail("Output image not found.");
            }
            if (gvp.GraphImage == null)
            {
                Assert.Fail("GraphImage property is null.");
            }
        }
Exemplo n.º 9
0
        public void Test_ChangeGraphType()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());
            gvp.AddEdge("a", "b");

            if (!gvp.graph.ToCode().Contains("->"))
            {
                Assert.Fail("Edge type is not equal to grapf type before change.");
            }

            gvp.ChangeGraphType(GraphType.Graph);

            if (!gvp.graph.ToCode().Contains("--"))
            {
                Assert.Fail("Edge type is not equal to graph type after change.");
            }
        }
Exemplo n.º 10
0
        public void Test_NodeExists()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());

            //Node exists
            gvp.AddNode("a");
            if (!gvp.NodeExists("a"))
            {
                Assert.Fail("Node not found.");
            }

            //Node is part of an edge
            gvp.AddEdge("a", "b");
            if (!gvp.NodeExistsInEdge("a"))
            {
                Assert.Fail("Node in an edge not found.");
            }
        }
Exemplo n.º 11
0
        public void Test_RemoveEdge()
        {
            GraphVizProcessor gvp = new GraphVizProcessor();

            gvp.graph = new Graph(GraphType.Digraph, new Stmt_list());

            gvp.AddEdge("a", "b");
            gvp.RemoveEdge("a", "b");

            if (gvp.EdgeExists("a", "b"))
            {
                Assert.Fail("Edge found after removal.");
            }
            if (!gvp.NodeExists("a"))
            {
                Assert.Fail("Node not found after edge removal.");
            }
            if (!gvp.NodeExists("b"))
            {
                Assert.Fail("Node not found after edge removal.");
            }
        }