Skip to content

Commit 4946925

Browse files
authored
Use file scoped namespaces (#63)
1 parent eff63dc commit 4946925

30 files changed

+4393
-4427
lines changed

README.md

Lines changed: 196 additions & 197 deletions
Large diffs are not rendered by default.

Rubjerg.Graphviz.Test/CGraphBasicOperations.cs

Lines changed: 125 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -2,155 +2,154 @@
22
using System.Linq;
33
using NUnit.Framework;
44

5-
namespace Rubjerg.Graphviz.Test
5+
namespace Rubjerg.Graphviz.Test;
6+
7+
[TestFixture()]
8+
public class CGraphBasicOperations
69
{
7-
[TestFixture()]
8-
public class CGraphBasicOperations
10+
[Test()]
11+
public void TestCopyAttributes()
912
{
10-
[Test()]
11-
public void TestCopyAttributes()
12-
{
13-
RootGraph root = Utils.CreateUniqueTestGraph();
14-
Node n1 = root.GetOrAddNode("1");
15-
Node.IntroduceAttribute(root, "test", "foo");
16-
Assert.AreEqual("foo", n1.GetAttribute("test"));
17-
n1.SetAttribute("test", "bar");
18-
Assert.AreEqual("bar", n1.GetAttribute("test"));
19-
20-
RootGraph root2 = Utils.CreateUniqueTestGraph();
21-
Node n2 = root2.GetOrAddNode("2");
22-
Assert.AreEqual(null, n2.GetAttribute("test"));
23-
Assert.AreEqual(0, n1.CopyAttributesTo(n2));
24-
Assert.AreEqual("bar", n2.GetAttribute("test"));
25-
}
13+
RootGraph root = Utils.CreateUniqueTestGraph();
14+
Node n1 = root.GetOrAddNode("1");
15+
Node.IntroduceAttribute(root, "test", "foo");
16+
Assert.AreEqual("foo", n1.GetAttribute("test"));
17+
n1.SetAttribute("test", "bar");
18+
Assert.AreEqual("bar", n1.GetAttribute("test"));
19+
20+
RootGraph root2 = Utils.CreateUniqueTestGraph();
21+
Node n2 = root2.GetOrAddNode("2");
22+
Assert.AreEqual(null, n2.GetAttribute("test"));
23+
Assert.AreEqual(0, n1.CopyAttributesTo(n2));
24+
Assert.AreEqual("bar", n2.GetAttribute("test"));
25+
}
2626

27-
[Test()]
28-
public void TestDeletions()
29-
{
30-
RootGraph root = Utils.CreateUniqueTestGraph();
27+
[Test()]
28+
public void TestDeletions()
29+
{
30+
RootGraph root = Utils.CreateUniqueTestGraph();
3131

32-
Node tail = root.GetOrAddNode("1");
33-
Node head = root.GetOrAddNode("2");
34-
Node other = root.GetOrAddNode("3");
32+
Node tail = root.GetOrAddNode("1");
33+
Node head = root.GetOrAddNode("2");
34+
Node other = root.GetOrAddNode("3");
3535

36-
Edge edge = root.GetOrAddEdge(tail, head, "edge");
37-
Edge tailout = root.GetOrAddEdge(tail, other, "tailout");
38-
Edge headout = root.GetOrAddEdge(head, other, "headout");
39-
Edge tailin = root.GetOrAddEdge(other, tail, "tailin");
40-
Edge headin = root.GetOrAddEdge(other, head, "headin");
36+
Edge edge = root.GetOrAddEdge(tail, head, "edge");
37+
Edge tailout = root.GetOrAddEdge(tail, other, "tailout");
38+
Edge headout = root.GetOrAddEdge(head, other, "headout");
39+
Edge tailin = root.GetOrAddEdge(other, tail, "tailin");
40+
Edge headin = root.GetOrAddEdge(other, head, "headin");
4141

42-
Assert.IsTrue(root.Equals(root.MyRootGraph));
43-
Assert.IsTrue(root.Equals(tail.MyRootGraph));
44-
Assert.IsTrue(root.Equals(edge.MyRootGraph));
42+
Assert.IsTrue(root.Equals(root.MyRootGraph));
43+
Assert.IsTrue(root.Equals(tail.MyRootGraph));
44+
Assert.IsTrue(root.Equals(edge.MyRootGraph));
4545

46-
Assert.AreEqual(3, tail.TotalDegree());
47-
Assert.AreEqual(3, head.TotalDegree());
48-
Assert.AreEqual(3, root.Nodes().Count());
46+
Assert.AreEqual(3, tail.TotalDegree());
47+
Assert.AreEqual(3, head.TotalDegree());
48+
Assert.AreEqual(3, root.Nodes().Count());
4949

50-
root.Delete(edge);
50+
root.Delete(edge);
5151

52-
Assert.AreEqual(2, tail.TotalDegree());
53-
Assert.AreEqual(2, head.TotalDegree());
54-
Assert.AreEqual(3, root.Nodes().Count());
52+
Assert.AreEqual(2, tail.TotalDegree());
53+
Assert.AreEqual(2, head.TotalDegree());
54+
Assert.AreEqual(3, root.Nodes().Count());
5555

56-
root.Delete(tail);
56+
root.Delete(tail);
5757

58-
Assert.AreEqual(2, root.Nodes().Count());
59-
Assert.AreEqual(2, other.TotalDegree());
60-
}
58+
Assert.AreEqual(2, root.Nodes().Count());
59+
Assert.AreEqual(2, other.TotalDegree());
60+
}
6161

62-
[Test()]
63-
public void TestNodeMerge()
64-
{
65-
RootGraph root = Utils.CreateUniqueTestGraph();
66-
Node merge = root.GetOrAddNode("merge");
67-
Node target = root.GetOrAddNode("target");
68-
Node other = root.GetOrAddNode("other");
69-
70-
Edge selfloop = root.GetOrAddEdge(merge, merge, "selfloop");
71-
Edge contracted = root.GetOrAddEdge(merge, target, "contracted");
72-
Edge counter = root.GetOrAddEdge(target, merge, "counter");
73-
Edge mergeout = root.GetOrAddEdge(merge, other, "mergeout");
74-
Edge targetout = root.GetOrAddEdge(target, other, "targetout");
75-
Edge mergein = root.GetOrAddEdge(other, merge, "mergein");
76-
Edge targetin = root.GetOrAddEdge(other, target, "targetin");
77-
78-
Assert.AreEqual(6, merge.TotalDegree());
79-
Assert.AreEqual(4, target.TotalDegree());
80-
Assert.AreEqual(3, root.Nodes().Count());
81-
82-
//root.ComputeDotLayout();
83-
//root.ToSvgFile("dump1.svg");
84-
//root.FreeLayout();
85-
//root.ToDotFile("dump1.dot");
86-
87-
root.Merge(merge, target);
88-
89-
//root.ComputeDotLayout();
90-
//root.ToSvgFile("dump2.svg");
91-
//root.FreeLayout();
92-
//root.ToDotFile("dump2.dot");
93-
94-
Assert.AreEqual(2, root.Nodes().Count());
95-
Assert.AreEqual(3, target.InDegree());
96-
Assert.AreEqual(3, target.OutDegree());
97-
Assert.AreEqual(2, other.InDegree());
98-
Assert.AreEqual(2, other.OutDegree());
99-
}
62+
[Test()]
63+
public void TestNodeMerge()
64+
{
65+
RootGraph root = Utils.CreateUniqueTestGraph();
66+
Node merge = root.GetOrAddNode("merge");
67+
Node target = root.GetOrAddNode("target");
68+
Node other = root.GetOrAddNode("other");
69+
70+
Edge selfloop = root.GetOrAddEdge(merge, merge, "selfloop");
71+
Edge contracted = root.GetOrAddEdge(merge, target, "contracted");
72+
Edge counter = root.GetOrAddEdge(target, merge, "counter");
73+
Edge mergeout = root.GetOrAddEdge(merge, other, "mergeout");
74+
Edge targetout = root.GetOrAddEdge(target, other, "targetout");
75+
Edge mergein = root.GetOrAddEdge(other, merge, "mergein");
76+
Edge targetin = root.GetOrAddEdge(other, target, "targetin");
77+
78+
Assert.AreEqual(6, merge.TotalDegree());
79+
Assert.AreEqual(4, target.TotalDegree());
80+
Assert.AreEqual(3, root.Nodes().Count());
81+
82+
//root.ComputeDotLayout();
83+
//root.ToSvgFile("dump1.svg");
84+
//root.FreeLayout();
85+
//root.ToDotFile("dump1.dot");
86+
87+
root.Merge(merge, target);
88+
89+
//root.ComputeDotLayout();
90+
//root.ToSvgFile("dump2.svg");
91+
//root.FreeLayout();
92+
//root.ToDotFile("dump2.dot");
93+
94+
Assert.AreEqual(2, root.Nodes().Count());
95+
Assert.AreEqual(3, target.InDegree());
96+
Assert.AreEqual(3, target.OutDegree());
97+
Assert.AreEqual(2, other.InDegree());
98+
Assert.AreEqual(2, other.OutDegree());
99+
}
100100

101-
[Test()]
102-
public void TestEdgeContraction()
101+
[Test()]
102+
public void TestEdgeContraction()
103+
{
104+
//NativeMethods.AllocConsole();
105+
RootGraph root = Utils.CreateUniqueTestGraph();
106+
Node tail = root.GetOrAddNode("x");
107+
Node head = root.GetOrAddNode("xx");
108+
Node other = root.GetOrAddNode("xxx");
109+
110+
Edge contracted = root.GetOrAddEdge(tail, head, "tocontract");
111+
Edge parallel = root.GetOrAddEdge(tail, head, "parallel");
112+
Edge counterparallel = root.GetOrAddEdge(head, tail, "counterparallel");
113+
Edge tailout = root.GetOrAddEdge(tail, other, "tailout");
114+
Edge headout = root.GetOrAddEdge(head, other, "headout");
115+
Edge tailin = root.GetOrAddEdge(other, tail, "tailin");
116+
Edge headin = root.GetOrAddEdge(other, head, "headin");
117+
118+
foreach (Node n in root.Nodes())
103119
{
104-
//NativeMethods.AllocConsole();
105-
RootGraph root = Utils.CreateUniqueTestGraph();
106-
Node tail = root.GetOrAddNode("x");
107-
Node head = root.GetOrAddNode("xx");
108-
Node other = root.GetOrAddNode("xxx");
109-
110-
Edge contracted = root.GetOrAddEdge(tail, head, "tocontract");
111-
Edge parallel = root.GetOrAddEdge(tail, head, "parallel");
112-
Edge counterparallel = root.GetOrAddEdge(head, tail, "counterparallel");
113-
Edge tailout = root.GetOrAddEdge(tail, other, "tailout");
114-
Edge headout = root.GetOrAddEdge(head, other, "headout");
115-
Edge tailin = root.GetOrAddEdge(other, tail, "tailin");
116-
Edge headin = root.GetOrAddEdge(other, head, "headin");
117-
118-
foreach (Node n in root.Nodes())
120+
n.SafeSetAttribute("label", n.GetName(), "no");
121+
n.SafeSetAttribute("fontname", "Arial", "Arial");
122+
foreach (Edge e in n.EdgesOut())
119123
{
120-
n.SafeSetAttribute("label", n.GetName(), "no");
121-
n.SafeSetAttribute("fontname", "Arial", "Arial");
122-
foreach (Edge e in n.EdgesOut())
123-
{
124-
e.SafeSetAttribute("label", e.GetName(), "no");
125-
e.SafeSetAttribute("fontname", "Arial", "Arial");
126-
}
124+
e.SafeSetAttribute("label", e.GetName(), "no");
125+
e.SafeSetAttribute("fontname", "Arial", "Arial");
127126
}
127+
}
128128

129129

130-
Assert.AreEqual(5, tail.TotalDegree());
131-
Assert.AreEqual(5, head.TotalDegree());
132-
Assert.AreEqual(3, root.Nodes().Count());
130+
Assert.AreEqual(5, tail.TotalDegree());
131+
Assert.AreEqual(5, head.TotalDegree());
132+
Assert.AreEqual(3, root.Nodes().Count());
133133

134-
Node contraction = root.Contract(contracted, "contraction result");
134+
Node contraction = root.Contract(contracted, "contraction result");
135135

136-
foreach (Node n in root.Nodes())
136+
foreach (Node n in root.Nodes())
137+
{
138+
n.SafeSetAttribute("label", n.GetName(), "no");
139+
n.SafeSetAttribute("fontname", "Arial", "Arial");
140+
foreach (Edge e in n.EdgesOut())
137141
{
138-
n.SafeSetAttribute("label", n.GetName(), "no");
139-
n.SafeSetAttribute("fontname", "Arial", "Arial");
140-
foreach (Edge e in n.EdgesOut())
141-
{
142-
e.SafeSetAttribute("label", e.GetName(), "no");
143-
e.SafeSetAttribute("fontname", "Arial", "Arial");
144-
}
142+
e.SafeSetAttribute("label", e.GetName(), "no");
143+
e.SafeSetAttribute("fontname", "Arial", "Arial");
145144
}
146-
147-
//Console.Read();
148-
Assert.AreEqual(2, root.Nodes().Count());
149-
Assert.AreEqual(2, contraction.InDegree());
150-
Assert.AreEqual(2, contraction.OutDegree());
151-
Assert.AreEqual(2, other.InDegree());
152-
Assert.AreEqual(2, other.OutDegree());
153145
}
154146

147+
//Console.Read();
148+
Assert.AreEqual(2, root.Nodes().Count());
149+
Assert.AreEqual(2, contraction.InDegree());
150+
Assert.AreEqual(2, contraction.OutDegree());
151+
Assert.AreEqual(2, other.InDegree());
152+
Assert.AreEqual(2, other.OutDegree());
155153
}
154+
156155
}

0 commit comments

Comments
 (0)