Exemplo n.º 1
0
 public void VisitEdge_edgeWithArrowTail_setsStatementAttributeValueArrowTail()
 {
     var style = new EdgeStyle();
     style.ArrowTail = ArrowShape.Crow;
     var edge = CreateEdge("start", "finish", style);
     var renderer = new DotRenderer();
     var statement = renderer.VisitEdge(edge);
     Assert.That(statement.AttributeValue(Dot.ArrowTail), Is.EqualTo("crow"));
 }
Exemplo n.º 2
0
 public void VisitEdge_edgeWithArrowTail_setsStatementAttributeArrowTail()
 {
     var style = new EdgeStyle();
     style.ArrowTail = ArrowShape.Box;
     var edge = CreateEdge("start", "finish", style);
     var renderer = new DotRenderer();
     var statement = renderer.VisitEdge(edge);
     Assert.That(statement.Attributes, Has.Member(Dot.ArrowTail));
 }
        public void VisitEdge_edgeWithArrowHead_setsStatementAttributeArrowHead()
        {
            var style = new EdgeStyle();

            style.ArrowHead = ArrowShape.Normal;
            var edge      = CreateEdge("start", "finish", style);
            var renderer  = new DotRenderer();
            var statement = renderer.VisitEdge(edge);

            Assert.That(statement.Attributes, Has.Member(Dot.ArrowHead));
        }
        public void VisitEdge_edgeWithColor_setsStatementAttributeColor()
        {
            var style = new EdgeStyle();

            style.Color = Color.SkyBlue;
            var edge      = CreateEdge("start", "finish", style);
            var renderer  = new DotRenderer();
            var statement = renderer.VisitEdge(edge);

            Assert.That(statement.Attributes, Has.Member(Dot.Color));
        }
        public void VisitNode_nodeWithFontcolor_setsStatementAttributeFontColor()
        {
            var style = new NodeStyle
            {
                FontColor = Color.Green
            };
            var renderer  = new DotRenderer();
            var node      = new Node("Name", "Label", style);
            var statement = renderer.VisitNode(node);

            Assert.That(statement.Attributes, Has.Member(Dot.FontColor));
        }
        public void RenderGraph_givenFillColor_generatesImage()
        {
            var colors = new List <Color>
            {
                Color.Blue,
                Color.Red,
                Color.Green,
                Color.White,
                Color.Black,
                Color.Aqua,
                Color.Yellow,
                Color.Magenta,
                Color.LightYellow,
                Color.SkyBlue,
                Color.OldLace,
                Color.SteelBlue,
                Color.DeepSkyBlue,
                Color.Gray,
                Color.Cornsilk
            };

            var nodes = new List <Node>();
            var edges = new List <Edge>();

            foreach (var fill in colors)
            {
                Node prior = null;
                foreach (var font in colors)
                {
                    Node n = CreateNode(fill, font);
                    nodes.Add(n);
                    if (prior != null)
                    {
                        Edge e = new Edge(prior, n);
                        edges.Add(e);
                    }

                    prior = n;
                }
            }

            var graphFactory = new GraphFactory();
            var graph        = graphFactory.CreateGraph(nodes, edges);

            var renderer = new DotRenderer(graph);
            var image    = renderer.RenderImage();

            image.Save("NodeFillColor.png");
        }
Exemplo n.º 7
0
        public void RenderGraph_givenArrowShape_generatesImage(
            [Values(ArrowShape.Box, ArrowShape.Crow, ArrowShape.Diamond, ArrowShape.Dot, ArrowShape.Inv, ArrowShape.None, ArrowShape.Normal, ArrowShape.Tee, ArrowShape.Vee)]
            ArrowShape arrowHead)
        {
            var edgeStyle = new EdgeStyle();

            edgeStyle.ArrowHead = arrowHead;

            var startStyles
                = new List <ArrowShape>
                {
                ArrowShape.Box,
                ArrowShape.Crow,
                ArrowShape.Diamond,
                ArrowShape.Dot,
                ArrowShape.Inv,
                ArrowShape.None,
                ArrowShape.Normal,
                ArrowShape.Tee,
                ArrowShape.Vee
                };

            var starts = new List <Node>();
            var edges  = new List <Edge>();
            var finish = new Node("finish", "Finish");

            foreach (var shape in startStyles)
            {
                var n = Enum.GetName(typeof(ArrowShape), shape);
                var s = new Node(n, n);
                edgeStyle.ArrowTail = shape;
                var e = new Edge(s, finish, edgeStyle);

                starts.Add(s);
                edges.Add(e);
            }

            var graphFactory = new GraphFactory();
            var graph        = graphFactory.CreateGraph(starts, finish, edges);

            var renderer = new DotRenderer(graph);

            var head     = Enum.GetName(typeof(ArrowShape), arrowHead);
            var filename = head + ".png";
            var image    = renderer.RenderImage();

            image.Save(filename);
        }
Exemplo n.º 8
0
        public void RenderGraph_givenFillColor_generatesImage()
        {
            var colors = new List<Color>
                             {
                                 Color.Blue,
                                 Color.Red,
                                 Color.Green,
                                 Color.White,
                                 Color.Black,
                                 Color.Aqua,
                                 Color.Yellow,
                                 Color.Magenta,
                                 Color.LightYellow,
                                 Color.SkyBlue,
                                 Color.OldLace,
                                 Color.SteelBlue,
                                 Color.DeepSkyBlue,
                                 Color.Gray,
                                 Color.Cornsilk
                             };

            var nodes = new List<Node>();
            var edges = new List<Edge>();

            foreach (var fill in colors)
            {
                Node prior = null;
                foreach (var font in colors)
                {
                    Node n = CreateNode(fill, font);
                    nodes.Add(n);
                    if (prior != null)
                    {
                        Edge e = new Edge(prior, n);
                        edges.Add(e);
                    }

                    prior = n;
                }
            }

            var graphFactory = new GraphFactory();
            var graph = graphFactory.CreateGraph(nodes, edges);

            var renderer = new DotRenderer(graph);
            var image = renderer.RenderImage();
            image.Save("NodeFillColor.png");
        }
Exemplo n.º 9
0
        public void RenderGraph_givenNodeShape_generatesImage(
            [Values(NodeShape.None,
                    NodeShape.Box,
                    NodeShape.Circle,
                    NodeShape.Diamond,
                    NodeShape.DoubleCircle,
                    NodeShape.DoubleOctagon,
                    NodeShape.Egg,
                    NodeShape.Ellipse,
                    NodeShape.Hexagon,
                    NodeShape.House,
                    NodeShape.InvHouse,
                    NodeShape.InvTrapezium,
                    NodeShape.InvTriangle,
                    NodeShape.MCircle,
                    NodeShape.MDiamond,
                    NodeShape.MSquare,
                    NodeShape.Octagon,
                    NodeShape.Parallelogram,
                    NodeShape.Pentagon,
                    NodeShape.Plaintext,
                    NodeShape.Point,
                    NodeShape.Polygon,
                    NodeShape.Septagon,
                    NodeShape.Trapezium,
                    NodeShape.Triangle,
                    NodeShape.TripleOctagon)]
            NodeShape shape)
        {
            var nodeStyle = new NodeStyle();

            nodeStyle.Shape = shape;

            var n = Enum.GetName(typeof(NodeShape), shape);

            var node = nodeStyle.CreateNode(n, n);

            var graphFactory = new GraphFactory();
            var graph        = graphFactory.CreateGraph(node);

            var renderer = new DotRenderer(graph);

            var filename = n + ".png";
            var image    = renderer.RenderImage();

            image.Save(filename);
        }
Exemplo n.º 10
0
        public void RenderGraph_givenArrowShape_generatesImage(
            [Values(ArrowShape.Box, ArrowShape.Crow, ArrowShape.Diamond, ArrowShape.Dot, ArrowShape.Inv, ArrowShape.None, ArrowShape.Normal, ArrowShape.Tee, ArrowShape.Vee)]
            ArrowShape arrowHead)
        {
            var edgeStyle = new EdgeStyle();
            edgeStyle.ArrowHead = arrowHead;

            var startStyles
                = new List<ArrowShape>
                      {
                          ArrowShape.Box,
                          ArrowShape.Crow,
                          ArrowShape.Diamond,
                          ArrowShape.Dot,
                          ArrowShape.Inv,
                          ArrowShape.None,
                          ArrowShape.Normal,
                          ArrowShape.Tee,
                          ArrowShape.Vee
                      };

            var starts = new List<Node>();
            var edges = new List<Edge>();
            var finish = new Node("finish", "Finish");

            foreach (var shape in startStyles)
            {
                var n = Enum.GetName(typeof(ArrowShape), shape);
                var s = new Node(n, n);
                edgeStyle.ArrowTail = shape;
                var e = new Edge(s, finish, edgeStyle);

                starts.Add(s);
                edges.Add(e);
            }

            var graphFactory = new GraphFactory();
            var graph = graphFactory.CreateGraph(starts, finish, edges);

            var renderer = new DotRenderer(graph);

            var head = Enum.GetName(typeof(ArrowShape), arrowHead);
            var filename = head + ".png";
            var image = renderer.RenderImage();
            image.Save(filename);
        }
Exemplo n.º 11
0
        public void RenderGraph_givenNodeShape_generatesImage(
            [Values(NodeShape.None,
                    NodeShape.Box,
                    NodeShape.Circle,
                    NodeShape.Diamond,
                    NodeShape.DoubleCircle,
                    NodeShape.DoubleOctagon,
                    NodeShape.Egg,
                    NodeShape.Ellipse,
                    NodeShape.Hexagon,
                    NodeShape.House,
                    NodeShape.InvHouse,
                    NodeShape.InvTrapezium,
                    NodeShape.InvTriangle,
                    NodeShape.MCircle,
                    NodeShape.MDiamond,
                    NodeShape.MSquare,
                    NodeShape.Octagon,
                    NodeShape.Parallelogram,
                    NodeShape.Pentagon,
                    NodeShape.Plaintext,
                    NodeShape.Point,
                    NodeShape.Polygon,
                    NodeShape.Septagon,
                    NodeShape.Trapezium,
                    NodeShape.Triangle,
                    NodeShape.TripleOctagon)]
            NodeShape shape)
        {
            var nodeStyle = new NodeStyle();
            nodeStyle.Shape = shape;

            var n = Enum.GetName(typeof(NodeShape), shape);

            var node = nodeStyle.CreateNode(n, n);

            var graphFactory = new GraphFactory();
            var graph = graphFactory.CreateGraph(node);

            var renderer = new DotRenderer(graph);

            var filename = n + ".png";
            var image = renderer.RenderImage();
            image.Save(filename);
        }
Exemplo n.º 12
0
 public void Constructor_suppliedGraph_setsProperty()
 {
     var graph = CreateGraph();
     var renderer = new DotRenderer(graph);
     Assert.That(renderer.Graph, Is.EqualTo(graph));
 }
Exemplo n.º 13
0
 public void VisitGraph_withParameters_returnsDotStatement()
 {
     var renderer = new DotRenderer();
     var graph = CreateGraph();
     var nodes = new List<IDotStatement>();
     var edges = new List<IDotStatement>();
     var subGraphs = new List<IDotStatement>();
     var statement = renderer.VisitGraph(graph, nodes, edges, subGraphs);
     Assert.That(statement, Is.Not.Null);
 }
Exemplo n.º 14
0
 public void VisitNode_missingNode_throwsException()
 {
     var renderer = new DotRenderer();
     renderer.VisitNode(null);
 }
Exemplo n.º 15
0
 public void VisitNode_nodeWithFontcolor_setsStatementAttributeFontColor()
 {
     var style = new NodeStyle
                     {
                         FontColor = Color.Green
                     };
     var renderer = new DotRenderer();
     var node = new Node("Name", "Label", style);
     var statement = renderer.VisitNode(node);
     Assert.That(statement.Attributes, Has.Member(Dot.FontColor));
 }
Exemplo n.º 16
0
 public void VisitEdge_edgeWithColor_setsStatementAttributeColor()
 {
     var style = new EdgeStyle();
     style.Color = Color.SkyBlue;
     var edge = CreateEdge("start", "finish", style);
     var renderer = new DotRenderer();
     var statement = renderer.VisitEdge(edge);
     Assert.That(statement.Attributes, Has.Member(Dot.Color));
 }
Exemplo n.º 17
0
 public void VisitEdge_edgeWithConstraing_setsStatementAttributeConstraint()
 {
     var style = new EdgeStyle();
     style.Constraining = false;
     var edge = CreateEdge("start", "finish", style);
     var renderer = new DotRenderer();
     var statement = renderer.VisitEdge(edge);
     Assert.That(statement.Attributes, Has.Member(Dot.EdgeConstraint));
 }
Exemplo n.º 18
0
 public void VisitGraph_missingSubGraphs_throwsException()
 {
     var renderer = new DotRenderer();
     var graph = CreateGraph();
     var nodes = new List<IDotStatement>();
     var edges = new List<IDotStatement>();
     renderer.VisitGraph(graph, nodes, edges, null);
 }
Exemplo n.º 19
0
 public void VisitNode_withNode_returnsDotStatement()
 {
     var renderer = new DotRenderer();
     var node = CreateNode();
     var statement = renderer.VisitNode(node);
     Assert.That(statement, Is.Not.Null);
 }
Exemplo n.º 20
0
 public void VisitNode_withNode_setsStatementAttributeLabel()
 {
     var renderer = new DotRenderer();
     var node = CreateNode();
     var statement = renderer.VisitNode(node);
     Assert.That(statement.Attributes, Has.Member(Dot.Label));
 }
Exemplo n.º 21
0
 public void Constructor_suppliedGraph_setsImage()
 {
     var graph = CreateGraph();
     var renderer = new DotRenderer(graph);
     Assert.That(renderer.RenderImage(), Is.Not.Null);
 }
Exemplo n.º 22
0
 public void VisitNode_withNode_setsStatementText()
 {
     var renderer = new DotRenderer();
     var node = CreateNode();
     var statement = renderer.VisitNode(node);
     Assert.That(statement.Text, Is.StringContaining(node.Name));
 }
        public void VisitEdge_missingEdge_throwsException()
        {
            var renderer = new DotRenderer();

            renderer.VisitEdge(null);
        }
Exemplo n.º 24
0
 public void VisitEdge_withEdge_includesStartInText()
 {
     var edge = CreateEdge("start", "finish");
     var renderer = new DotRenderer();
     var statement = renderer.VisitEdge(edge);
     Assert.That(statement.Text, Is.StringContaining(edge.Start.Name));
 }
Exemplo n.º 25
0
 public void VisitEdge_withEdge_returnsDotStatement()
 {
     var edge = CreateEdge("start", "finish");
     var renderer = new DotRenderer();
     var statement = renderer.VisitEdge(edge);
     Assert.That(statement, Is.Not.Null);
 }
Exemplo n.º 26
0
 public void VisitGraph_missingGraph_throwsException()
 {
     var renderer = new DotRenderer();
     var nodes = new List<IDotStatement>();
     var edges = new List<IDotStatement>();
     var subGraphs = new List<IDotStatement>();
     renderer.VisitGraph(null, nodes, edges, subGraphs);
 }