public void TestOneDateSeries()
        {
            int n = 10;
            IEnumerable <DateTime> x = Enumerable.Range(2, n).Select(i => new DateTime(1900, i, 1));

            double[] y = Enumerable.Range(100, n).Select(i => Convert.ToDouble(i)).ToArray();

            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, false, x.Cast <object>(), y.Cast <object>(), line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(n, series.ItemsSource.Count());
            double[] expectedX = new double[] { 33, 61, 92, 122, 153, 183, 214, 245, 275, 306 };
            int      i         = 0;

            foreach (DataPoint point in series.ItemsSource)
            {
                Assert.AreEqual(expectedX[i], point.X);
                Assert.AreEqual(y[i], point.Y);
                i++;
            }
        }
        public void TestSimpleCase()
        {
            IEnumerable <object> x = new object[] { 0d, 1d, 2d, 4d };
            IEnumerable <object> y = new object[] { 1d, 2d, 4d, 8d };
            Line   line            = new Line(LineType.Solid, LineThickness.Thin);
            Marker marker          = new Marker(MarkerType.Square, MarkerSize.Normal, 1);

            string     title  = "asdf";
            LineSeries input  = new LineSeries(title, Color.Blue, true, x, y, line, marker, "", "");
            Series     output = exporter.Export(input, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(title, series.Title);
            Assert.AreEqual(4, series.ItemsSource.Count());

            // Marker style
            Assert.AreEqual(OxyPlot.MarkerType.Square, series.MarkerType);
            Assert.AreEqual(7, series.MarkerSize);

            // Line style
            Assert.AreEqual(OxyPlot.LineStyle.Solid, series.LineStyle);
            Assert.AreEqual(0.25, series.StrokeThickness);

            // Colours
            Assert.AreEqual(OxyColors.Blue, series.Color);
        }
        public void TestTwoDateSeries()
        {
            int n = 10;
            IEnumerable <DateTime> x = Enumerable.Range(1, n).Select(i => new DateTime(2000, 1, i));
            IEnumerable <DateTime> y = Enumerable.Range(2000, n).Select(i => new DateTime(i, 1, 1));

            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, false, x.Cast <object>(), y.Cast <object>(), line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(n, series.ItemsSource.Count());
            double[] expectedX = new double[] { 36526, 36527, 36528, 36529, 36530, 36531, 36532, 36533, 36534, 36535 };
            double[] expectedY = new double[] { 36526, 36892, 37257, 37622, 37987, 38353, 38718, 39083, 39448, 39814 };
            int      i         = 0;

            foreach (DataPoint point in series.ItemsSource)
            {
                Assert.AreEqual(expectedX[i], point.X);
                Assert.AreEqual(expectedY[i], point.Y);
                i++;
            }
        }
        public void TestNoData()
        {
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line   line            = new Line(LineType.Solid, LineThickness.Thin);
            Marker marker          = new Marker(MarkerType.Square, MarkerSize.Normal, 1);

            LineSeries input  = new LineSeries("", Color.Blue, true, x, y, line, marker, "", "");
            Series     output = exporter.Export(input, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(0, series.ItemsSource.Count());
        }
        /// <summary>
        /// Create a series with the given marker size, conver it to an oxyplot
        /// series, and return the generated series' marker size.
        /// </summary>
        /// <param name="markerSize">Desired marker size.</param>
        private double GetExportedMarkerSize(MarkerSize markerSize)
        {
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.Solid, LineThickness.Normal);
            Marker     marker      = new Marker(MarkerType.FilledCircle, markerSize, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, true, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            return(series.MarkerSize);
        }
        /// <summary>
        /// Create a series with the given title and 'show on legend' value.
        /// Then convert to an oxyplot series and ensure that the generated
        /// series' title matches the specified expected value.
        /// </summary>
        /// <param name="title">Input title.</param>
        /// <param name="showOnLegend">Input value for 'show on legend'.</param>
        /// <param name="expectedTitle">Expected title of the oxyplot series.</param>
        private void TestShowOnLegend(string title, bool showOnLegend, string expectedTitle)
        {
            // Create an apsim series with the given inputs.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries(title, Color.Black, false, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.Null(series.Title);
        }
        /// <summary>
        /// Create a series with the given System.Drawing.Color and marker type,
        /// then convert to an oxyplot series and ensure that the generated series'
        /// marker colour matches the given colour.
        /// </summary>
        /// <param name="inputColour">Colour to use when creating the series.</param>
        /// <param name="markerType">Marker type for the created series.</param>
        /// <param name="expectedOutput">Expected colour of the output series.</param>
        private void TestMarkerColour(Color inputColour, MarkerType markerType, OxyColor expectedOutput)
        {
            // Create an apsim series with the given inputs.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(LineType.None, LineThickness.Thin);
            Marker     marker      = new Marker(markerType, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", inputColour, true, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            Assert.AreEqual(expectedOutput, series.MarkerFill);
        }
        /// <summary>
        /// Create an apsim series with the given input line type, then
        /// convert the apsim series to an oxyplot series and ensure that
        /// the output series' line type matches the expected output.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="expectedOutput"></param>
        private void TestLineType(LineType input, LineStyle expectedOutput)
        {
            // Create an apsim series with the given line type.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line       line        = new Line(input, LineThickness.Thin);
            Marker     marker      = new Marker(MarkerType.None, MarkerSize.Normal, 1);
            LineSeries inputSeries = new LineSeries("", Color.Black, true, x, y, line, marker, "", "");

            // Convert the series to an oxyplot series.
            Series output = exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result;

            Assert.NotNull(output);
            Assert.True(output is OxyLineSeries);
            OxyLineSeries series = (OxyLineSeries)output;

            // Ensure that the line type matches the expected line type.
            Assert.AreEqual(expectedOutput, series.LineStyle);
        }
        public void TestTitle()
        {
            // Create an apsim series with the given inputs.
            IEnumerable <object> x = Enumerable.Empty <object>();
            IEnumerable <object> y = Enumerable.Empty <object>();
            Line   line            = new Line(LineType.None, LineThickness.Thin);
            Marker marker          = new Marker(MarkerType.FilledCircle, MarkerSize.Normal, 1);

            string[] titles = new[]
            {
                null,
                "",
                "A somewhat long title containing spaces"
            };
            foreach (string title in titles)
            {
                LineSeries inputSeries = new LineSeries(title, Color.Black, true, x, y, line, marker, "", "");
                Assert.AreEqual(title, exporter.Export(inputSeries, AxisLabelCollection.Empty()).Result.Title);
            }
        }