Ejemplo n.º 1
0
        public void Convert_ValidChartLineDashStyle_ReturnsExpectedLineStyle(ChartLineDashStyle chartLineDashStyle,
                                                                             LineStyle expectedLineStyle)
        {
            // Call
            LineStyle lineStyle = ChartDataHelper.Convert(chartLineDashStyle);

            // Assert
            Assert.AreEqual(expectedLineStyle, lineStyle);
        }
Ejemplo n.º 2
0
        public void Constructor_WithStyle_SetsProperties()
        {
            // Setup
            Color     color = Color.AliceBlue;
            const int width = 3;
            const ChartLineDashStyle style = ChartLineDashStyle.Solid;

            // Call
            var lineStyle = new ChartLineStyle
            {
                Color      = color,
                Width      = width,
                DashStyle  = style,
                IsEditable = true
            };

            // Assert
            Assert.AreEqual(color, lineStyle.Color);
            Assert.AreEqual(width, lineStyle.Width);
            Assert.AreEqual(style, lineStyle.DashStyle);
            Assert.IsTrue(lineStyle.IsEditable);
        }
Ejemplo n.º 3
0
        public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
        {
            // Setup
            const int numberOfChangedProperties = 3;
            var       mocks    = new MockRepository();
            var       observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties);
            mocks.ReplayAll();

            var chartLineData = new ChartLineData("Test", new ChartLineStyle
            {
                Color     = Color.AliceBlue,
                Width     = 3,
                DashStyle = ChartLineDashStyle.Solid
            });

            chartLineData.Attach(observer);

            var properties = new ChartLineDataProperties
            {
                Data = chartLineData
            };

            Color     newColor = Color.Blue;
            const int newWidth = 6;
            const ChartLineDashStyle newDashStyle = ChartLineDashStyle.DashDot;

            // Call
            properties.Color     = newColor;
            properties.Width     = newWidth;
            properties.DashStyle = newDashStyle;

            // Assert
            Assert.AreEqual(newColor, chartLineData.Style.Color);
            Assert.AreEqual(newWidth, chartLineData.Style.Width);
            Assert.AreEqual(newDashStyle, chartLineData.Style.DashStyle);
            mocks.VerifyAll();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Converts <see cref="ChartLineDashStyle"/> to <see cref="LineStyle"/>.
        /// </summary>
        /// <param name="dashStyle">The <see cref="ChartLineDashStyle"/> to convert.</param>
        /// <returns>The converted <see cref="LineStyle"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="dashStyle"/>
        /// is not a valid enum value of <see cref="ChartLineDashStyle"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="dashStyle"/>
        /// is not supported for the conversion.</exception>
        public static LineStyle Convert(ChartLineDashStyle dashStyle)
        {
            if (!Enum.IsDefined(typeof(ChartLineDashStyle), dashStyle))
            {
                throw new InvalidEnumArgumentException(nameof(dashStyle),
                                                       (int)dashStyle,
                                                       typeof(ChartLineDashStyle));
            }

            var lineStyle = LineStyle.Solid;

            switch (dashStyle)
            {
            case ChartLineDashStyle.Solid:
                break;

            case ChartLineDashStyle.Dash:
                lineStyle = LineStyle.Dash;
                break;

            case ChartLineDashStyle.Dot:
                lineStyle = LineStyle.Dot;
                break;

            case ChartLineDashStyle.DashDot:
                lineStyle = LineStyle.DashDot;
                break;

            case ChartLineDashStyle.DashDotDot:
                lineStyle = LineStyle.DashDotDot;
                break;

            default:
                throw new NotSupportedException();
            }

            return(lineStyle);
        }
Ejemplo n.º 5
0
        public void Data_SetNewChartLineDataInstance_ReturnCorrectPropertyValues()
        {
            // Setup
            Color     color = Color.Aqua;
            const int width = 4;
            const ChartLineDashStyle dashStyle = ChartLineDashStyle.DashDot;

            var chartLineData = new ChartLineData("Test", new ChartLineStyle
            {
                Color     = color,
                Width     = width,
                DashStyle = dashStyle
            });
            var properties = new ChartLineDataProperties();

            // Call
            properties.Data = chartLineData;

            // Assert
            Assert.AreEqual(color, properties.Color);
            Assert.AreEqual(width, properties.Width);
            Assert.AreEqual(dashStyle, properties.DashStyle);
        }
Ejemplo n.º 6
0
 private static void AssertEqualStyle(ChartLineStyle lineStyle, Color color, int width, ChartLineDashStyle style)
 {
     Assert.AreEqual(color, lineStyle.Color);
     Assert.AreEqual(width, lineStyle.Width);
     Assert.AreEqual(style, lineStyle.DashStyle);
     Assert.IsTrue(lineStyle.IsEditable);
 }
 public ChartCrossHairSettings()
 {
     this.Width     = 1;
     this.Color     = "blue";
     this.DashStyle = ChartLineDashStyle.Solid;
 }
Ejemplo n.º 8
0
        public void ConvertSeriesProperties_ChartLineStyleSetWithDifferentDashStyles_AppliesStyleToSeries(ChartLineDashStyle dashStyle, LineStyle expectedLineStyle)
        {
            // Setup
            var converter          = new ChartMultipleLineDataConverter();
            var multipleLineSeries = new MultipleLineSeries();
            var data = new ChartMultipleLineData("test", new ChartLineStyle
            {
                Color     = Color.Red,
                Width     = 3,
                DashStyle = dashStyle
            });

            // Call
            converter.ConvertSeriesProperties(data, multipleLineSeries);

            // Assert
            Assert.AreEqual(expectedLineStyle, multipleLineSeries.LineStyle);
            Assert.IsNull(multipleLineSeries.Dashes);
        }