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."); } }
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."); } }
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."); } }
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."); } }
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."); } }
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."); } }
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."); } }