-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dot.Tests.cs
90 lines (69 loc) · 1.58 KB
/
Dot.Tests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
namespace KismetAnalyzer;
using Xunit;
using Dot;
public class DotTests {
[Fact]
public void TestEmptyGraph()
{
var graph = new Graph("digraph");
var writer = new StringWriter();
graph.Write(writer);
Assert.Equal(@"digraph
{
}
", writer.ToString());
}
[Fact]
public void TestGraphAttributes()
{
var graph = new Graph("digraph");
graph.GraphAttributes["test"] = "value";
var writer = new StringWriter();
graph.Write(writer);
Assert.Equal(@"digraph
{
graph [test = ""value""]
}
", writer.ToString());
}
[Fact]
public void TestNodes()
{
var graph = new Graph("digraph");
var node = new Node("nodeA");
node.Attributes["color"] = "blue";
graph.Nodes.Add(node);
graph.GraphAttributes["test"] = "value";
var writer = new StringWriter();
graph.Write(writer);
Assert.Equal(@"digraph
{
graph [test = ""value""]
nodeA [color = ""blue""]
}
", writer.ToString());
}
[Fact]
public void TestSubgraph()
{
var graph = new Graph("digraph");
var node = new Node("nodeA");
node.Attributes["color"] = "blue";
graph.Nodes.Add(node);
var subgraph = new Subgraph();
subgraph.Attributes["rank"] = "min";
subgraph.Nodes.Add(new Node("nodeA"));
graph.Subgraphs.Add(subgraph);
var writer = new StringWriter();
graph.Write(writer);
Assert.Equal(@"digraph
{
nodeA [color = ""blue""]
{
rank = ""min"";
nodeA
}
}
", writer.ToString());
}
}