コード例 #1
0
        public void Constructor_ExpectedValues()
        {
            // Setup
            const string content             = "test";
            Color        fillColor           = Colors.Blue;
            Color        lineColor           = Colors.Gray;
            const int    lineWidth           = 3;
            const PointedTreeVertexType type = PointedTreeVertexType.None;
            const bool isSelectable          = true;

            // Call
            var vertex = new PointedTreeElementVertex(content, fillColor, lineColor, lineWidth, type, isSelectable);

            // Assert
            Assert.IsInstanceOf <INotifyPropertyChanged>(vertex);
            Assert.AreEqual(content, vertex.Content);
            Assert.IsInstanceOf <SolidColorBrush>(vertex.FillColor);
            Assert.AreEqual(fillColor, ((SolidColorBrush)vertex.FillColor).Color);
            Assert.IsInstanceOf <SolidColorBrush>(vertex.LineColor);
            Assert.AreEqual(lineColor, ((SolidColorBrush)vertex.LineColor).Color);
            Assert.AreEqual(lineWidth, vertex.LineWidth);
            Assert.AreEqual(type, vertex.Type);
            Assert.AreEqual(isSelectable, vertex.IsSelectable);
            Assert.IsFalse(vertex.IsSelected);
            Assert.IsInstanceOf <VertexSelectedCommand>(vertex.VertexSelectedCommand);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        /// <summary>
        /// Creates a new instance of <see cref="PointedTreeElementVertex"/>.
        /// </summary>
        /// <param name="content">The content of the vertex.</param>
        /// <param name="fillColor">The fill color of the vertex.</param>
        /// <param name="lineColor">The line color of the vertex.</param>
        /// <param name="lineWidth">The line width of the vertex.</param>
        /// <param name="type">The type of the vertex.</param>
        /// <param name="isSelectable">Indicator whether the vertex is selectable.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="content"/> is <c>null</c>.</exception>
        public PointedTreeElementVertex(string content, Color fillColor, Color lineColor, int lineWidth,
                                        PointedTreeVertexType type, bool isSelectable)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            Content      = content;
            FillColor    = new SolidColorBrush(fillColor);
            LineColor    = new SolidColorBrush(lineColor);
            LineWidth    = lineWidth;
            Type         = type;
            IsSelectable = isSelectable;
        }