public void Text()
        {
            var cell = new GraphvizRecordCell();

            if (cell.Text != null)
            {
                throw new InvalidOperationException($"Cell has not null {nameof(GraphvizRecordCell.Text)}.");
            }
            Assert.IsFalse(cell.HasText);

            cell.Port = null;

            Assert.IsFalse(cell.HasText);
            Assert.IsNull(cell.Text);

            cell.Text = string.Empty;

            Assert.IsFalse(cell.HasText);
            Assert.IsEmpty(cell.Text);

            const string text = "TestText";

            cell.Text = text;

            Assert.IsTrue(cell.HasText);
            Assert.AreEqual(text, cell.Text);
        }
        public void Cells_Throws()
        {
            var cell = new GraphvizRecordCell();

            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => cell.Cells = null);
        }
        public void Constructor()
        {
            var cell = new GraphvizRecordCell();

            Assert.IsFalse(cell.HasPort);
            Assert.IsNull(cell.Port);
            Assert.IsFalse(cell.HasText);
            Assert.IsNull(cell.Text);
            CollectionAssert.IsEmpty(cell.Cells);
        }
        public void Cells()
        {
            var cell = new GraphvizRecordCell();

            if (cell.Cells is null)
            {
                throw new InvalidOperationException($"Cell has null {nameof(GraphvizRecordCell.Cells)}.");
            }

            var recordCollection = new GraphvizRecordCellCollection();

            cell.Cells = recordCollection;
            Assert.AreSame(recordCollection, cell.Cells);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Emptry constructor
        /// </summary>
        public EdgeDfsTest()
        {
            m_Vertex = new GraphvizVertex();
            m_Edge = new GraphvizEdge();

            Vertex.Style = GraphvizVertexStyle.Filled;
            Vertex.FillColor = Color.LightSkyBlue;

            GraphvizRecordCell cell = new GraphvizRecordCell();
            Vertex.Record.Cells.Add(cell);

            GraphvizRecordCell child = new GraphvizRecordCell();
            child.Text = "State";
            cell.Cells.Add(child);

            m_Cell = new GraphvizRecordCell();
            cell.Cells.Add(m_Cell);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Formats a <see cref="DataTable"/> (a table).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected virtual void FormatTable([NotNull] object sender, [NotNull] FormatVertexEventArgs <DataTable> args)
        {
            Debug.Assert(sender != null);
            Debug.Assert(args != null);

            DataTable      vertex = args.Vertex;
            GraphvizVertex format = args.VertexFormat;

            format.Shape = GraphvizVertexShape.Record;

            // Create a record with a title and a list of columns
            var title = new GraphvizRecordCell
            {
                Text = vertex.TableName
            };

            var  builder = new StringBuilder();
            bool flag    = true;

            foreach (DataColumn column in vertex.Columns)
            {
                if (flag)
                {
                    flag = false;
                }
                else
                {
                    builder.AppendLine();
                }

                builder.Append($"+ {column.ColumnName} : {column.DataType.Name}");
                if (column.Unique)
                {
                    builder.Append(" unique");
                }
            }
            var columns = new GraphvizRecordCell
            {
                Text = builder.ToString().TrimEnd()
            };

            format.Record.Cells.Add(title);
            format.Record.Cells.Add(columns);
        }
Exemplo n.º 7
0
        private void FormatVertex(object sender, FormatVertexEventArgs <ExpandingNode> e)
        {
            ExpandingNode ent = e.Vertex;

            //e.VertexFormatter.Label = ent.GetName();
            e.VertexFormatter.Shape = GraphvizVertexShape.Record;
            e.VertexFormatter.Style = GraphvizVertexStyle.Filled;

            switch (ent.state)
            {
            case ExpandingNode.STATE.NEW:
                e.VertexFormatter.FillColor = Color.Orange;
                break;

            case ExpandingNode.STATE.EXPANDED:
                e.VertexFormatter.FillColor = Color.Red;
                break;

            case ExpandingNode.STATE.FREEZED:
                e.VertexFormatter.FillColor = Color.LightBlue;
                break;
            }

            GraphvizRecord rec = new GraphvizRecord();

            GraphvizRecordCell name = new GraphvizRecordCell();

            name.Text = ent.GetName();

            GraphvizRecordCell maxScore = new GraphvizRecordCell();

            maxScore.Text = ent.maxVal.ToString();

            GraphvizRecordCell minScore = new GraphvizRecordCell();

            minScore.Text = ent.minVal.ToString();

            rec.Cells.Add(name);
            rec.Cells.Add(maxScore);
            rec.Cells.Add(minScore);

            e.VertexFormatter.Record = rec;
        }
        protected virtual void FormatTable(object sender, FormatVertexEventArgs <DataTable> e)
        {
            Contract.Requires(sender != null);
            Contract.Requires(e != null);

            var v      = e.Vertex;
            var format = e.VertexFormatter;

            format.Shape = GraphvizVertexShape.Record;

            // creating a record with a title and a list of columns.
            var title = new GraphvizRecordCell()
            {
                Text = v.TableName
            };
            var  sb    = new StringBuilder();
            bool first = true;

            foreach (DataColumn column in v.Columns)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    sb.AppendLine();
                }
                sb.AppendFormat("+ {0} : {1}", column.ColumnName, column.DataType.Name);
                if (column.Unique)
                {
                    sb.Append(" unique");
                }
            }
            var columns = new GraphvizRecordCell()
            {
                Text = sb.ToString().TrimEnd()
            };

            format.Record.Cells.Add(title);
            format.Record.Cells.Add(columns);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Emptry constructor
        /// </summary>
        public EdgeDfsTest()
        {
            m_Vertex = new GraphvizVertex();
            m_Edge   = new GraphvizEdge();

            Vertex.Style     = GraphvizVertexStyle.Filled;
            Vertex.FillColor = Color.LightSkyBlue;

            GraphvizRecordCell cell = new GraphvizRecordCell();

            Vertex.Record.Cells.Add(cell);

            GraphvizRecordCell child = new GraphvizRecordCell();

            child.Text = "State";
            cell.Cells.Add(child);

            m_Cell = new GraphvizRecordCell();
            cell.Cells.Add(m_Cell);
        }
        public void Constructor()
        {
            var recordCollection = new GraphvizRecordCellCollection();

            CollectionAssert.IsEmpty(recordCollection);

            var cell1 = new GraphvizRecordCell();

            recordCollection.Add(cell1);
            CollectionAssert.AreEqual(new[] { cell1 }, recordCollection);

            var cell2     = new GraphvizRecordCell();
            var cellArray = new[] { cell1, cell2 };

            recordCollection = new GraphvizRecordCellCollection(cellArray);
            CollectionAssert.AreEqual(cellArray, recordCollection);

            var otherRecordCollection = new GraphvizRecordCellCollection(recordCollection);

            CollectionAssert.AreEqual(recordCollection, otherRecordCollection);
        }
Exemplo n.º 11
0
 public void ToDot([NotNull] GraphvizRecordCell recordCell, [NotNull] string expectedDot)
 {
     Assert.AreEqual(expectedDot, recordCell.ToDot());
     Assert.AreEqual(expectedDot, recordCell.ToString());
 }