Beispiel #1
0
        public void ConvertSeriesProperties_DataNull_ThrowsArgumentNullException()
        {
            // Call
            TestDelegate test = () => RowChartDataConverter.ConvertSeriesProperties(null, new ColumnSeries());

            // Assert
            const string expectedMessage = "Null data cannot be converted into series data.";
            var          exception       = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(test, expectedMessage);

            Assert.AreEqual("data", exception.ParamName);
        }
Beispiel #2
0
        /// <summary>
        /// Creates a new instance of <see cref="RowChartDataSeries"/>.
        /// </summary>
        /// <param name="rowChartData">The <see cref="RowChartData"/> which the series is based upon.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="rowChartData"/> is <c>null</c>.</exception>
        public RowChartDataSeries(RowChartData rowChartData)
        {
            if (rowChartData == null)
            {
                throw new ArgumentNullException(nameof(rowChartData));
            }

            IsStacked       = true;
            StrokeThickness = 1;

            RowChartDataConverter.ConvertSeriesData(rowChartData, this);
            RowChartDataConverter.ConvertSeriesProperties(rowChartData, this);
        }
Beispiel #3
0
        public void ConvertSeriesData_SeriesNull_ThrowsArgumentNullException()
        {
            // Setup
            var rowData = new RowChartData("data", new double[0], null);

            // Call
            TestDelegate test = () => RowChartDataConverter.ConvertSeriesData(rowData, null);

            // Assert
            const string expectedMessage = "Null data cannot be used as conversion target.";
            var          exception       = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentNullException>(test, expectedMessage);

            Assert.AreEqual("series", exception.ParamName);
        }
Beispiel #4
0
        public void ConvertSeriesData_DataWithValues_ColumnItemsAddedToSeries()
        {
            // Setup
            var values = new[]
            {
                0.2,
                0.7,
                0.1
            };

            var rowData = new RowChartData("data", values, null);
            var series  = new ColumnSeries();

            // Call
            RowChartDataConverter.ConvertSeriesData(rowData, series);

            // Assert
            CollectionAssert.AreEqual(values, series.Items.Select(i => i.Value));
        }
Beispiel #5
0
        public void ConvertSeriesProperties_WithData_SetPropertiesOfSeries(bool withColor)
        {
            // Setup
            const string name  = "data";
            Color?       color = withColor
                               ? (Color?)Color.Red
                               : null;

            var rowData = new RowChartData(name, new double[0], color);
            var series  = new ColumnSeries();

            // Call
            RowChartDataConverter.ConvertSeriesProperties(rowData, series);

            // Assert
            Assert.AreEqual(name, series.Title);

            OxyColor actualColor = withColor
                                       ? OxyColor.FromArgb(color.Value.A, color.Value.R, color.Value.G, color.Value.B)
                                       : OxyColors.Automatic;

            Assert.AreEqual(actualColor, series.FillColor);
        }