Beispiel #1
0
        public void Constructor_WithAllParameters_SetsProperties()
        {
            // Setup
            Color     color               = Color.AliceBlue;
            const int size                = 3;
            Color     strokeColor         = Color.AntiqueWhite;
            const int strokeThickness     = 2;
            const ChartPointSymbol symbol = ChartPointSymbol.Circle;

            // Call
            var pointStyle = new ChartPointStyle
            {
                Color           = color,
                StrokeColor     = strokeColor,
                Size            = size,
                StrokeThickness = strokeThickness,
                Symbol          = symbol,
                IsEditable      = true
            };

            // Assert
            Assert.AreEqual(color, pointStyle.Color);
            Assert.AreEqual(size, pointStyle.Size);
            Assert.AreEqual(strokeColor, pointStyle.StrokeColor);
            Assert.AreEqual(strokeThickness, pointStyle.StrokeThickness);
            Assert.AreEqual(symbol, pointStyle.Symbol);
            Assert.IsTrue(pointStyle.IsEditable);
        }
        public void Data_SetNewChartPointDataInstance_ReturnCorrectPropertyValues()
        {
            // Setup
            Color     color               = Color.Aqua;
            Color     strokeColor         = Color.Crimson;
            const int size                = 4;
            const int strokeThickness     = 2;
            const ChartPointSymbol symbol = ChartPointSymbol.Circle;

            var chartPointData = new ChartPointData("Test", new ChartPointStyle
            {
                Color           = color,
                StrokeColor     = strokeColor,
                Size            = size,
                StrokeThickness = strokeThickness,
                Symbol          = symbol
            });
            var properties = new ChartPointDataProperties();

            // Call
            properties.Data = chartPointData;

            // Assert
            Assert.AreEqual(color, properties.Color);
            Assert.AreEqual(strokeColor, properties.StrokeColor);
            Assert.AreEqual(strokeThickness, properties.StrokeThickness);
            Assert.AreEqual(size, properties.Size);
            Assert.AreEqual(symbol, properties.Symbol);
        }
Beispiel #3
0
        public void Convert_ValidChartPointSymbol_ReturnsExpectedMarkerType(ChartPointSymbol chartPointSymbol,
                                                                            MarkerType expectedMarkerType)
        {
            // Call
            MarkerType markerType = ChartDataHelper.Convert(chartPointSymbol);

            // Assert
            Assert.AreEqual(expectedMarkerType, markerType);
        }
 private static ChartPointStyle GetGridStyle(Color color, ChartPointSymbol symbol)
 {
     return(new ChartPointStyle
     {
         Color = color,
         StrokeColor = color,
         Size = 6,
         StrokeThickness = color == Color.Transparent
                               ? 0
                               : 2,
         Symbol = symbol,
         IsEditable = true
     });
 }
Beispiel #5
0
        /// <summary>
        /// Converts <see cref="ChartPointSymbol"/> to <see cref="MarkerType"/>.
        /// </summary>
        /// <param name="symbol">The <see cref="ChartPointSymbol"/> to convert.</param>
        /// <returns>The converted <see cref="MarkerType"/>.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="symbol"/>
        /// is not a valid enum value of <see cref="ChartPointSymbol"/>.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="symbol"/>
        /// is not supported for the conversion.</exception>
        public static MarkerType Convert(ChartPointSymbol symbol)
        {
            if (!Enum.IsDefined(typeof(ChartPointSymbol), symbol))
            {
                throw new InvalidEnumArgumentException(nameof(symbol),
                                                       (int)symbol,
                                                       typeof(ChartPointSymbol));
            }

            MarkerType markerType;

            switch (symbol)
            {
            case ChartPointSymbol.Circle:
                markerType = MarkerType.Circle;
                break;

            case ChartPointSymbol.Square:
                markerType = MarkerType.Square;
                break;

            case ChartPointSymbol.Diamond:
                markerType = MarkerType.Diamond;
                break;

            case ChartPointSymbol.Triangle:
                markerType = MarkerType.Triangle;
                break;

            case ChartPointSymbol.Star:
                markerType = MarkerType.Star;
                break;

            case ChartPointSymbol.Cross:
                markerType = MarkerType.Cross;
                break;

            case ChartPointSymbol.Plus:
                markerType = MarkerType.Plus;
                break;

            default:
                throw new NotSupportedException();
            }

            return(markerType);
        }
        public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
        {
            // Setup
            const int numberOfChangedProperties = 5;
            var       mocks    = new MockRepository();
            var       observer = mocks.StrictMock <IObserver>();

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

            var chartPointData = new ChartPointData("Test", new ChartPointStyle
            {
                Color           = Color.AliceBlue,
                StrokeColor     = Color.Fuchsia,
                Size            = 3,
                StrokeThickness = 1,
                Symbol          = ChartPointSymbol.Circle
            });

            chartPointData.Attach(observer);

            var properties = new ChartPointDataProperties
            {
                Data = chartPointData
            };

            Color     newColor               = Color.Blue;
            Color     newStrokeColor         = Color.Aquamarine;
            const int newSize                = 6;
            const ChartPointSymbol newSymbol = ChartPointSymbol.Diamond;
            const int newStrokeThickness     = 4;

            // Call
            properties.Color           = newColor;
            properties.Size            = newSize;
            properties.Symbol          = newSymbol;
            properties.StrokeColor     = newStrokeColor;
            properties.StrokeThickness = newStrokeThickness;

            // Assert
            Assert.AreEqual(newColor, chartPointData.Style.Color);
            Assert.AreEqual(newSize, chartPointData.Style.Size);
            Assert.AreEqual(newSymbol, chartPointData.Style.Symbol);
            Assert.AreEqual(newStrokeColor, chartPointData.Style.StrokeColor);
            Assert.AreEqual(newStrokeThickness, chartPointData.Style.StrokeThickness);
            mocks.VerifyAll();
        }
Beispiel #7
0
        public void ConvertSeriesProperties_ChartPointStyleSetWithDifferentChartPointSymbols_AppliesStyleToSeries(ChartPointSymbol symbol, MarkerType expectedMarkerType)
        {
            // Setup
            var converter  = new ChartPointDataConverter();
            var lineSeries = new LineSeries();
            var data       = new ChartPointData("test", new ChartPointStyle
            {
                Color           = Color.Red,
                StrokeColor     = Color.Red,
                Size            = 3,
                StrokeThickness = 2,
                Symbol          = symbol
            });

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

            // Assert
            Assert.AreEqual(expectedMarkerType, lineSeries.MarkerType);
        }
Beispiel #8
0
 private static void AssertEqualStyle(ChartPointStyle pointStyle, Color fillColor, int size, Color strokeColor, int strokeThickness, ChartPointSymbol symbol)
 {
     Assert.AreEqual(fillColor, pointStyle.Color);
     Assert.AreEqual(size, pointStyle.Size);
     Assert.AreEqual(strokeColor, pointStyle.StrokeColor);
     Assert.AreEqual(strokeThickness, pointStyle.StrokeThickness);
     Assert.AreEqual(symbol, pointStyle.Symbol);
     Assert.IsTrue(pointStyle.IsEditable);
 }
 private static ChartPointStyle GetCharacteristicPointStyle(Color fillColor, Color strokeColor, ChartPointSymbol symbol)
 {
     return(new ChartPointStyle
     {
         Color = fillColor,
         StrokeColor = strokeColor,
         Size = 8,
         StrokeThickness = strokeColor == Color.Transparent
                               ? 0
                               : 1,
         Symbol = symbol,
         IsEditable = true
     });
 }