public void Convert_WithGraphNode_ReturnPointedTreeElementVertex(GraphNodeShape graphNodeShape, PointedTreeVertexType expectedVertexType) { // Setup var random = new Random(21); const string content = "<text>Node</text>"; bool isSelectable = random.NextBoolean(); int lineWidth = random.Next(); Color fillColor = Color.Aquamarine; Color lineColor = Color.Coral; var graphNode = new GraphNode(content, new GraphNode[0], isSelectable, new GraphNodeStyle(graphNodeShape, fillColor, lineColor, lineWidth)); // Call PointedTreeElementVertex vertex = GraphNodeConverter.Convert(graphNode); // Assert Assert.AreEqual(content, vertex.Content); Assert.AreEqual(isSelectable, vertex.IsSelectable); Assert.AreEqual(expectedVertexType, vertex.Type); Assert.AreEqual(lineWidth, vertex.LineWidth); AssertColors(fillColor, vertex.FillColor); AssertColors(lineColor, vertex.LineColor); }
public void Convert_GraphNodeNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => GraphNodeConverter.Convert(null); // Assert var exception = Assert.Throws <ArgumentNullException>(call); Assert.AreEqual("graphNode", exception.ParamName); }
public void Convert_InvalidShapeType_ThrowsInvalidEnumArgumentException() { // Setup const int shapeAsInteger = 99; var graphNode = new GraphNode("<text>test</text>", new GraphNode[0], false, new GraphNodeStyle((GraphNodeShape)shapeAsInteger, Color.AliceBlue, Color.AntiqueWhite, 2)); // Call TestDelegate test = () => GraphNodeConverter.Convert(graphNode); // Assert string message = $"The value of argument 'shape' ({shapeAsInteger}) is invalid for Enum type '{typeof(GraphNodeShape).Name}'."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(test, message); }
private void DrawNode(GraphNode node, PointedTreeElementVertex parentVertex = null) { PointedTreeElementVertex vertex = GraphNodeConverter.Convert(node); vertex.PropertyChanged += VertexOnPropertyChanged; var drawnGraphNode = new DrawnGraphNode { GraphNode = node, Vertex = vertex }; drawnGraphNodeList.Add(drawnGraphNode); graph.AddVertex(vertex); node.ChildNodes.ForEachElementDo(cn => DrawNode(cn, vertex)); if (parentVertex != null) { graph.AddEdge(new PointedTreeEdge(parentVertex, vertex)); } }