public void RenderError() { const string graph = @"invalid"; var graphViz = new GraphViz(); graphViz.LayoutAndRender(null, graph, null, null, "svg"); }
public void RenderWithWarningAsException() { const string graph = @"digraph G { node [style=filled, shape=rec] # Nodes ""String age"" # Formatting ""String age"" [color=green] } "; var graphViz = new GraphViz(); graphViz.Config.TreatWarningsAsErrors = true; graphViz.LayoutAndRender(null, graph, null, null, "svg"); }
public void RenderWithWarning() { const string graph = @"digraph G { node [style=filled, shape=rec] # Nodes ""String age"" # Formatting ""String age"" [color=green] } "; const string expectedOutput = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?> <!DOCTYPE svg PUBLIC ""-//W3C//DTD SVG 1.1//EN"" ""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd""> <!-- Generated by graphviz version 2.43.20200408.0903 (20200408.0903) --> <!-- Title: G Pages: 1 --> <svg width=""80pt"" height=""44pt"" viewBox=""0.00 0.00 80.00 44.00"" xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink""> <g id=""graph0"" class=""graph"" transform=""scale(1 1) rotate(0) translate(4 40)""> <title>G</title> <polygon fill=""white"" stroke=""transparent"" points=""-4,4 -4,-40 76,-40 76,4 -4,4""/> <!-- String age --> <g id=""node1"" class=""node""> <title>String age</title> <polygon fill=""green"" stroke=""green"" points=""72,-36 0,-36 0,0 72,0 72,-36""/> <text text-anchor=""middle"" x=""36"" y=""-14.3"" font-family=""Times New Roman,serif"" font-size=""14.00"">String age</text> </g> </g> </svg> "; var graphViz = new GraphViz(); byte[] result = graphViz.LayoutAndRender(null, graph, null, null, "svg"); string output = Encoding.ASCII.GetString(result); Assert.AreEqual(expectedOutput, output); }
public void RenderToOutputWithNonDefaultLayout() { const string graph = @"digraph G { node [style=filled, shape=rect] # Nodes ""String age"" -> ""Int64.Parse()"" -> {""Int64"", ""Collector""} # Formatting ""String age"" [color=green] ""Int64"" [color=""#9fbff4""] ""Int64.Parse()"" [shape=invhouse] ""Collector"" [color = ""#c361f4""] { rank=same; ""Int64.Parse()"", ""Collector""} }"; const string expectedOutput = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?> <!DOCTYPE svg PUBLIC ""-//W3C//DTD SVG 1.1//EN"" ""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd""> <!-- Generated by graphviz version 2.43.20200408.0903 (20200408.0903) --> <!-- Title: G Pages: 1 --> <svg width=""200pt"" height=""171pt"" viewBox=""0.00 0.00 200.39 171.23"" xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink""> <g id=""graph0"" class=""graph"" transform=""scale(1 1) rotate(0) translate(4 167.23)""> <title>G</title> <polygon fill=""white"" stroke=""transparent"" points=""-4,4 -4,-167.23 196.39,-167.23 196.39,4 -4,4""/> <!-- String age --> <g id=""node1"" class=""node""> <title>String age</title> <polygon fill=""green"" stroke=""green"" points=""72,-66.12 0,-66.12 0,-30.12 72,-30.12 72,-66.12""/> <text text-anchor=""middle"" x=""36"" y=""-44.42"" font-family=""Times New Roman,serif"" font-size=""14.00"">String age</text> </g> <!-- Int64.Parse() --> <g id=""node2"" class=""node""> <title>Int64.Parse()</title> <polygon fill=""lightgrey"" stroke=""black"" points=""37.91,-65 109.41,-52.56 180.91,-65 180.85,-85.12 37.98,-85.12 37.91,-65""/> <text text-anchor=""middle"" x=""109.41"" y=""-66.86"" font-family=""Times New Roman,serif"" font-size=""14.00"">Int64.Parse()</text> </g> <!-- String age->Int64.Parse() --> <g id=""edge1"" class=""edge""> <title>String age->Int64.Parse()</title> <path fill=""none"" stroke=""black"" d=""M72.28,-59.21C72.35,-59.23 72.42,-59.25 72.49,-59.27""/> <polygon fill=""black"" stroke=""black"" points=""62.12,-59.76 72.71,-59.34 64.17,-53.07 62.12,-59.76""/> </g> <!-- Int64 --> <g id=""node3"" class=""node""> <title>Int64</title> <polygon fill=""#9fbff4"" stroke=""#9fbff4"" points=""192.39,-36 138.39,-36 138.39,0 192.39,0 192.39,-36""/> <text text-anchor=""middle"" x=""165.39"" y=""-14.3"" font-family=""Times New Roman,serif"" font-size=""14.00"">Int64</text> </g> <!-- Int64.Parse()->Int64 --> <g id=""edge2"" class=""edge""> <title>Int64.Parse()->Int64</title> <path fill=""none"" stroke=""black"" d=""M125.6,-55.36C129.66,-51.55 134.12,-47.36 138.54,-43.21""/> <polygon fill=""black"" stroke=""black"" points=""140.97,-45.73 145.86,-36.33 136.18,-40.63 140.97,-45.73""/> </g> <!-- Collector --> <g id=""node4"" class=""node""> <title>Collector</title> <polygon fill=""#c361f4"" stroke=""#c361f4"" points=""161.24,-163.23 93.24,-163.23 93.24,-127.23 161.24,-127.23 161.24,-163.23""/> <text text-anchor=""middle"" x=""127.24"" y=""-141.53"" font-family=""Times New Roman,serif"" font-size=""14.00"">Collector</text> </g> <!-- Int64.Parse()->Collector --> <g id=""edge3"" class=""edge""> <title>Int64.Parse()->Collector</title> <path fill=""none"" stroke=""black"" d=""M112.94,-85.31C115.1,-94.4 117.96,-106.33 120.54,-117.16""/> <polygon fill=""black"" stroke=""black"" points=""117.18,-118.16 122.91,-127.08 123.99,-116.54 117.18,-118.16""/> </g> </g> </svg> "; var graphViz = new GraphViz(); // ReSharper disable once StringLiteralTypo byte[] result = graphViz.LayoutAndRender(null, graph, null, "neato", "svg"); string output = Encoding.ASCII.GetString(result); Assert.AreEqual(expectedOutput, output); }
public void RenderToOutput() { const string graph = @"digraph G { node [style=filled, shape=rect] # Nodes ""String age"" -> ""Int64.Parse()"" -> {""Int64"", ""Collector""} # Formatting ""String age"" [color=green] ""Int64"" [color=""#9fbff4""] ""Int64.Parse()"" [shape=invhouse] ""Collector"" [color = ""#c361f4""] { rank=same; ""Int64.Parse()"", ""Collector""} }"; const string expectedOutput = @"<?xml version=""1.0"" encoding=""UTF-8"" standalone=""no""?> <!DOCTYPE svg PUBLIC ""-//W3C//DTD SVG 1.1//EN"" ""http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd""> <!-- Generated by graphviz version 2.43.20200408.0903 (20200408.0903) --> <!-- Title: G Pages: 1 --> <svg width=""238pt"" height=""188pt"" viewBox=""0.00 0.00 237.50 188.00"" xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink""> <g id=""graph0"" class=""graph"" transform=""scale(1 1) rotate(0) translate(4 184)""> <title>G</title> <polygon fill=""white"" stroke=""transparent"" points=""-4,4 -4,-184 233.5,-184 233.5,4 -4,4""/> <!-- String age --> <g id=""node1"" class=""node""> <title>String age</title> <polygon fill=""green"" stroke=""green"" points=""107.5,-180 35.5,-180 35.5,-144 107.5,-144 107.5,-180""/> <text text-anchor=""middle"" x=""71.5"" y=""-158.3"" font-family=""Times New Roman,serif"" font-size=""14.00"">String age</text> </g> <!-- Int64.Parse() --> <g id=""node2"" class=""node""> <title>Int64.Parse()</title> <polygon fill=""lightgrey"" stroke=""black"" points=""-0,-84.44 71.5,-72 143,-84.44 142.93,-104.56 0.07,-104.56 -0,-84.44""/> <text text-anchor=""middle"" x=""71.5"" y=""-86.3"" font-family=""Times New Roman,serif"" font-size=""14.00"">Int64.Parse()</text> </g> <!-- String age->Int64.Parse() --> <g id=""edge1"" class=""edge""> <title>String age->Int64.Parse()</title> <path fill=""none"" stroke=""black"" d=""M71.5,-143.7C71.5,-134.99 71.5,-124.3 71.5,-114.83""/> <polygon fill=""black"" stroke=""black"" points=""75,-114.82 71.5,-104.82 68,-114.82 75,-114.82""/> </g> <!-- Int64 --> <g id=""node3"" class=""node""> <title>Int64</title> <polygon fill=""#9fbff4"" stroke=""#9fbff4"" points=""98.5,-36 44.5,-36 44.5,0 98.5,0 98.5,-36""/> <text text-anchor=""middle"" x=""71.5"" y=""-14.3"" font-family=""Times New Roman,serif"" font-size=""14.00"">Int64</text> </g> <!-- Int64.Parse()->Int64 --> <g id=""edge2"" class=""edge""> <title>Int64.Parse()->Int64</title> <path fill=""none"" stroke=""black"" d=""M71.5,-71.7C71.5,-63.98 71.5,-54.71 71.5,-46.11""/> <polygon fill=""black"" stroke=""black"" points=""75,-46.1 71.5,-36.1 68,-46.1 75,-46.1""/> </g> <!-- Collector --> <g id=""node4"" class=""node""> <title>Collector</title> <polygon fill=""#c361f4"" stroke=""#c361f4"" points=""229.5,-108 161.5,-108 161.5,-72 229.5,-72 229.5,-108""/> <text text-anchor=""middle"" x=""195.5"" y=""-86.3"" font-family=""Times New Roman,serif"" font-size=""14.00"">Collector</text> </g> <!-- Int64.Parse()->Collector --> <g id=""edge3"" class=""edge""> <title>Int64.Parse()->Collector</title> <path fill=""none"" stroke=""black"" d=""M143.19,-90C145.81,-90 148.43,-90 151.05,-90""/> <polygon fill=""black"" stroke=""black"" points=""151.17,-93.5 161.17,-90 151.17,-86.5 151.17,-93.5""/> </g> </g> </svg> "; var graphViz = new GraphViz(); byte[] result = graphViz.LayoutAndRender(null, graph, null, null, "svg"); string output = Encoding.ASCII.GetString(result); Assert.AreEqual(expectedOutput, output); }