Index: Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs =================================================================== diff -u -rf8b4c597194c61e15dcbb0f70f7d4a97bc3c6403 -rbf790921e622ee49149a92e6b52668fb30d6e3a6 --- Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision f8b4c597194c61e15dcbb0f70f7d4a97bc3c6403) +++ Core/Components/src/Core.Components.OxyPlot.Forms/ChartControl.cs (.../ChartControl.cs) (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -28,6 +28,7 @@ using Core.Components.Chart.Data; using Core.Components.Chart.Forms; using Core.Components.OxyPlot.DataSeries; +using Core.Components.OxyPlot.DataSeries.Chart; using OxyPlot.Series; namespace Core.Components.OxyPlot.Forms Index: Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartAreaDataConverter.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartAreaDataConverter.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartAreaDataConverter.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,56 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Converter.Chart +{ + /// + /// The converter that converts data into data. + /// + public class ChartAreaDataConverter : ChartDataConverter + { + protected override void SetSeriesData(ChartAreaData data, AreaSeries series) + { + series.Points.Clear(); + series.Points2.Clear(); + + series.Points.AddRange(data.Points.Select(p => new DataPoint(p.X, p.Y))); + + if (series.Points.Count > 0) + { + series.Points2.Add(series.Points[0]); + } + } + + protected override void SetSeriesStyle(ChartAreaData data, AreaSeries series) + { + ChartAreaStyle style = data.Style; + series.Fill = ChartDataHelper.Convert(style.FillColor); + series.Color = ChartDataHelper.Convert(style.StrokeColor); + series.StrokeThickness = style.StrokeThickness; + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartDataConverter.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartDataConverter.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartDataConverter.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,94 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Components.Chart.Data; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Converter.Chart +{ + /// + /// Abstract base class for transforming data into data. + /// + /// The type of chart data to convert. + /// The type of series to set the converted data to. + public abstract class ChartDataConverter + where TChartData : ChartData + where TSeries : Series + { + /// + /// Converts all chart data from to . + /// + /// The chart data to create the series from. + /// The series to set the converted data to. + /// Thrown when or is null. + public void ConvertSeriesData(TChartData data, TSeries series) + { + ValidateParameters(data, series); + + SetSeriesData(data, series); + } + + /// + /// Converts all general properties (like and ) + /// from to . + /// + /// The chart data to convert the general properties from. + /// The series to convert the general properties to. + /// Thrown when or is null. + public void ConvertSeriesProperties(TChartData data, TSeries series) + { + ValidateParameters(data, series); + + series.Title = data.Name; + series.IsVisible = data.IsVisible; + + SetSeriesStyle(data, series); + } + + /// + /// Sets data to based on . + /// + /// The chart data to create the series from. + /// The series to set the converted data to. + protected abstract void SetSeriesData(TChartData data, TSeries series); + + /// + /// Set a style to based on . + /// + /// The chart data to create the style from. + /// The series to set the style to. + protected abstract void SetSeriesStyle(TChartData data, TSeries series); + + private static void ValidateParameters(TChartData data, TSeries series) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data), @"Null data cannot be converted into series data."); + } + + if (series == null) + { + throw new ArgumentNullException(nameof(series), @"Null data cannot be used as conversion target."); + } + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartLineDataConverter.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartLineDataConverter.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartLineDataConverter.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,48 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Converter.Chart +{ + /// + /// The converter that converts data into data. + /// + public class ChartLineDataConverter : ChartDataConverter + { + protected override void SetSeriesData(ChartLineData data, LineSeries series) + { + series.ItemsSource = data.Points.Select(p => new DataPoint(p.X, p.Y)); + } + + protected override void SetSeriesStyle(ChartLineData data, LineSeries series) + { + ChartLineStyle style = data.Style; + series.Color = ChartDataHelper.Convert(style.Color); + series.StrokeThickness = style.Width; + series.LineStyle = ChartDataHelper.Convert(style.DashStyle); + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartMultipleAreaDataConverter.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartMultipleAreaDataConverter.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartMultipleAreaDataConverter.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,54 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.CustomSeries; +using OxyPlot; + +namespace Core.Components.OxyPlot.Converter.Chart +{ + /// + /// The converter that converts data into data. + /// + public class ChartMultipleAreaDataConverter : ChartDataConverter + { + protected override void SetSeriesData(ChartMultipleAreaData data, MultipleAreaSeries series) + { + series.Areas.Clear(); + + foreach (Point2D[] area in data.Areas) + { + series.Areas.Add(area.Select(p => new DataPoint(p.X, p.Y)).ToArray()); + } + } + + protected override void SetSeriesStyle(ChartMultipleAreaData data, MultipleAreaSeries series) + { + ChartAreaStyle style = data.Style; + series.Fill = ChartDataHelper.Convert(style.FillColor); + series.Color = ChartDataHelper.Convert(style.StrokeColor); + series.StrokeThickness = style.StrokeThickness; + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartMultipleLineDataConverter.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartMultipleLineDataConverter.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartMultipleLineDataConverter.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,55 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.CustomSeries; +using OxyPlot; + +namespace Core.Components.OxyPlot.Converter.Chart +{ + /// + /// The converter that converts data into data. + /// + public class ChartMultipleLineDataConverter : ChartDataConverter + { + protected override void SetSeriesData(ChartMultipleLineData data, MultipleLineSeries series) + { + series.Lines.Clear(); + + foreach (Point2D[] line in data.Lines) + { + series.Lines.Add(line.Select(p => new DataPoint(p.X, p.Y)).ToArray()); + } + } + + protected override void SetSeriesStyle(ChartMultipleLineData data, MultipleLineSeries series) + { + ChartLineStyle lineStyle = data.Style; + + series.Color = ChartDataHelper.Convert(lineStyle.Color); + series.StrokeThickness = lineStyle.Width; + series.LineStyle = ChartDataHelper.Convert(lineStyle.DashStyle); + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartPointDataConverter.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartPointDataConverter.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/Converter/Chart/ChartPointDataConverter.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,51 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Linq; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Converter.Chart +{ + /// + /// The converter that converts data into data. + /// + public class ChartPointDataConverter : ChartDataConverter + { + protected override void SetSeriesData(ChartPointData data, LineSeries series) + { + series.ItemsSource = data.Points.Select(p => new DataPoint(p.X, p.Y)); + } + + protected override void SetSeriesStyle(ChartPointData data, LineSeries series) + { + series.LineStyle = LineStyle.None; + ChartPointStyle style = data.Style; + series.MarkerFill = ChartDataHelper.Convert(style.Color); + series.MarkerSize = style.Size; + series.MarkerType = ChartDataHelper.Convert(style.Symbol); + series.MarkerStroke = ChartDataHelper.Convert(style.StrokeColor); + series.MarkerStrokeThickness = style.StrokeThickness; + } + } +} \ No newline at end of file Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartAreaDataConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartDataConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartLineDataConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartMultipleAreaDataConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartMultipleLineDataConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/Converter/ChartPointDataConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj =================================================================== diff -u -r4a60f6ca9a08736cfaf0fac6e6f2e89e9fa59aae -rbf790921e622ee49149a92e6b52668fb30d6e3a6 --- Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj (.../Core.Components.OxyPlot.csproj) (revision 4a60f6ca9a08736cfaf0fac6e6f2e89e9fa59aae) +++ Core/Components/src/Core.Components.OxyPlot/Core.Components.OxyPlot.csproj (.../Core.Components.OxyPlot.csproj) (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -48,24 +48,24 @@ Properties\GlobalAssembly.cs - + - - - - + + + + - - - - + + + + - - - + + + Index: Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartAreaDataSeries.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartAreaDataSeries.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartAreaDataSeries.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.OxyPlot.Converter.Chart; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.DataSeries.Chart +{ + /// + /// A based on and updated according to the wrapped . + /// + public class ChartAreaDataSeries : AreaSeries, IChartDataSeries + { + private readonly ChartAreaData chartAreaData; + private readonly ChartAreaDataConverter converter = new ChartAreaDataConverter(); + + private Point2D[] drawnPoints; + + /// + /// Creates a new instance of . + /// + /// The which the chart area data series is based upon. + /// Thrown when is null. + public ChartAreaDataSeries(ChartAreaData chartAreaData) + { + if (chartAreaData == null) + { + throw new ArgumentNullException(nameof(chartAreaData)); + } + + this.chartAreaData = chartAreaData; + + Update(); + } + + public void Update() + { + if (!ReferenceEquals(chartAreaData.Points, drawnPoints)) + { + converter.ConvertSeriesData(chartAreaData, this); + + drawnPoints = chartAreaData.Points; + } + + converter.ConvertSeriesProperties(chartAreaData, this); + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartDataSeriesFactory.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartDataSeriesFactory.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartDataSeriesFactory.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,80 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Globalization; +using Core.Components.Chart.Data; + +namespace Core.Components.OxyPlot.DataSeries.Chart +{ + /// + /// A factory to create based on . + /// + internal static class ChartDataSeriesFactory + { + /// + /// Creates a based on . + /// + /// The to create a from. + /// A instance. + /// Thrown when the given is null. + /// Thrown when the given type is not supported. + public static IChartDataSeries Create(ChartData data) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + var chartPointData = data as ChartPointData; + if (chartPointData != null) + { + return new ChartPointDataSeries(chartPointData); + } + + var chartLineData = data as ChartLineData; + if (chartLineData != null) + { + return new ChartLineDataSeries(chartLineData); + } + + var chartAreaData = data as ChartAreaData; + if (chartAreaData != null) + { + return new ChartAreaDataSeries(chartAreaData); + } + + var chartMultipleAreaData = data as ChartMultipleAreaData; + if (chartMultipleAreaData != null) + { + return new ChartMultipleAreaDataSeries(chartMultipleAreaData); + } + + var chartMultipleLineData = data as ChartMultipleLineData; + if (chartMultipleLineData != null) + { + return new ChartMultipleLineDataSeries(chartMultipleLineData); + } + + throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "ChartData of type {0} is not supported.", data.GetType().Name)); + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartLineDataSeries.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartLineDataSeries.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartLineDataSeries.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.OxyPlot.Converter.Chart; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.DataSeries.Chart +{ + /// + /// A based on and updated according to the wrapped . + /// + public class ChartLineDataSeries : LineSeries, IChartDataSeries + { + private readonly ChartLineData chartLineData; + private readonly ChartLineDataConverter converter = new ChartLineDataConverter(); + + private Point2D[] drawnPoints; + + /// + /// Creates a new instance of . + /// + /// The which the chart line data series is based upon. + /// Thrown when is null. + public ChartLineDataSeries(ChartLineData chartLineData) + { + if (chartLineData == null) + { + throw new ArgumentNullException(nameof(chartLineData)); + } + + this.chartLineData = chartLineData; + + Update(); + } + + public void Update() + { + if (!ReferenceEquals(chartLineData.Points, drawnPoints)) + { + converter.ConvertSeriesData(chartLineData, this); + + drawnPoints = chartLineData.Points; + } + + converter.ConvertSeriesProperties(chartLineData, this); + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartMultipleAreaDataSeries.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartMultipleAreaDataSeries.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartMultipleAreaDataSeries.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,70 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.OxyPlot.Converter.Chart; +using Core.Components.OxyPlot.CustomSeries; + +namespace Core.Components.OxyPlot.DataSeries.Chart +{ + /// + /// A based on and updated according to the wrapped . + /// + public class ChartMultipleAreaDataSeries : MultipleAreaSeries, IChartDataSeries + { + private readonly ChartMultipleAreaData chartMultipleAreaData; + private readonly ChartMultipleAreaDataConverter converter = new ChartMultipleAreaDataConverter(); + + private IEnumerable drawnAreas; + + /// + /// Creates a new instance of . + /// + /// The which the chart multiple area data series is based upon. + /// Thrown when is null. + public ChartMultipleAreaDataSeries(ChartMultipleAreaData chartMultipleAreaData) + { + if (chartMultipleAreaData == null) + { + throw new ArgumentNullException(nameof(chartMultipleAreaData)); + } + + this.chartMultipleAreaData = chartMultipleAreaData; + + Update(); + } + + public void Update() + { + if (!ReferenceEquals(chartMultipleAreaData.Areas, drawnAreas)) + { + converter.ConvertSeriesData(chartMultipleAreaData, this); + + drawnAreas = chartMultipleAreaData.Areas; + } + + converter.ConvertSeriesProperties(chartMultipleAreaData, this); + } + } +} \ No newline at end of file Index: Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartMultipleLineDataSeries.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartMultipleLineDataSeries.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartMultipleLineDataSeries.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,72 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.OxyPlot.Converter.Chart; +using Core.Components.OxyPlot.CustomSeries; + +namespace Core.Components.OxyPlot.DataSeries.Chart +{ + /// + /// A based on and updated according to the wrapped . + /// + public class ChartMultipleLineDataSeries : MultipleLineSeries, IChartDataSeries + { + private readonly ChartMultipleLineData chartMultipleLineData; + private readonly ChartMultipleLineDataConverter converter = new ChartMultipleLineDataConverter(); + + private IEnumerable drawnLines; + + /// + /// Creates a new instance of . + /// + /// The + /// which the chart multiple line data series is based upon. + /// Thrown when + /// is null. + public ChartMultipleLineDataSeries(ChartMultipleLineData chartMultipleLineData) + { + if (chartMultipleLineData == null) + { + throw new ArgumentNullException(nameof(chartMultipleLineData)); + } + + this.chartMultipleLineData = chartMultipleLineData; + + Update(); + } + + public void Update() + { + if (!ReferenceEquals(chartMultipleLineData.Lines, drawnLines)) + { + converter.ConvertSeriesData(chartMultipleLineData, this); + + drawnLines = chartMultipleLineData.Lines; + } + + converter.ConvertSeriesProperties(chartMultipleLineData, this); + } + } +} Index: Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartPointDataSeries.cs =================================================================== diff -u --- Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartPointDataSeries.cs (revision 0) +++ Core/Components/src/Core.Components.OxyPlot/DataSeries/Chart/ChartPointDataSeries.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.OxyPlot.Converter.Chart; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.DataSeries.Chart +{ + /// + /// A based on and updated according to the wrapped . + /// + public class ChartPointDataSeries : LineSeries, IChartDataSeries + { + private readonly ChartPointData chartPointData; + private readonly ChartPointDataConverter converter = new ChartPointDataConverter(); + + private Point2D[] drawnPoints; + + /// + /// Creates a new instance of . + /// + /// The which the chart point data series is based upon. + /// Thrown when is null. + public ChartPointDataSeries(ChartPointData chartPointData) + { + if (chartPointData == null) + { + throw new ArgumentNullException(nameof(chartPointData)); + } + + this.chartPointData = chartPointData; + + Update(); + } + + public void Update() + { + if (!ReferenceEquals(chartPointData.Points, drawnPoints)) + { + converter.ConvertSeriesData(chartPointData, this); + + drawnPoints = chartPointData.Points; + } + + converter.ConvertSeriesProperties(chartPointData, this); + } + } +} \ No newline at end of file Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/DataSeries/ChartAreaDataSeries.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/DataSeries/ChartDataSeriesFactory.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/DataSeries/ChartLineDataSeries.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/DataSeries/ChartMultipleAreaDataSeries.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/DataSeries/ChartMultipleLineDataSeries.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/src/Core.Components.OxyPlot/DataSeries/ChartPointDataSeries.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Components/src/Core.Components.Stack/Data/RowChartData.cs =================================================================== diff -u -rf84603903b35f1b130fc86de39dbb8fb8120ac05 -rbf790921e622ee49149a92e6b52668fb30d6e3a6 --- Core/Components/src/Core.Components.Stack/Data/RowChartData.cs (.../RowChartData.cs) (revision f84603903b35f1b130fc86de39dbb8fb8120ac05) +++ Core/Components/src/Core.Components.Stack/Data/RowChartData.cs (.../RowChartData.cs) (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using System.Drawing; -using System.Linq; namespace Core.Components.Stack.Data { Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartAreaDataConverterTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartAreaDataConverterTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartAreaDataConverterTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,156 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.Converter.Chart; +using NUnit.Framework; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Test.Converter.Chart +{ + [TestFixture] + public class ChartAreaDataConverterTest + { + [Test] + public void DefaultConstructor_IsChartDataConverter() + { + // Call + var converter = new ChartAreaDataConverter(); + + // Assert + Assert.IsInstanceOf>(converter); + } + + [Test] + public void ConvertSeriesItems_ChartAreaDataWithRandomPointData_ConvertsAllPointsToAreaSeries() + { + // Setup + var converter = new ChartAreaDataConverter(); + var areaSeries = new AreaSeries(); + var random = new Random(21); + int randomCount = random.Next(5, 10); + var points = new Collection(); + for (var i = 0; i < randomCount; i++) + { + points.Add(new Point2D(random.NextDouble(), random.NextDouble())); + } + + var areaData = new ChartAreaData("test data") + { + Points = points.ToArray() + }; + + // Call + converter.ConvertSeriesData(areaData, areaSeries); + + // Assert + DataPoint[] expectedPoints = points.Select(t => new DataPoint(t.X, t.Y)).ToArray(); + CollectionAssert.AreEqual(expectedPoints, areaSeries.Points); + CollectionAssert.AreEqual(new Collection + { + expectedPoints.First() + }, areaSeries.Points2); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void ConvertSeriesProperties_WithDifferentFillColors_AppliesStyleToSeries(KnownColor color) + { + // Setup + var converter = new ChartAreaDataConverter(); + var areaSeries = new AreaSeries(); + Color expectedColor = Color.FromKnownColor(color); + var data = new ChartAreaData("test", new ChartAreaStyle + { + FillColor = expectedColor, + StrokeColor = Color.Red, + StrokeThickness = 3 + }); + + // Call + converter.ConvertSeriesProperties(data, areaSeries); + + // Assert + AssertColors(expectedColor, areaSeries.Fill); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void ConvertSeriesProperties_WithDifferentStrokeColors_AppliesStyleToSeries(KnownColor color) + { + // Setup + var converter = new ChartAreaDataConverter(); + var areaSeries = new AreaSeries(); + Color expectedColor = Color.FromKnownColor(color); + var data = new ChartAreaData("test", new ChartAreaStyle + { + FillColor = Color.Red, + StrokeColor = expectedColor, + StrokeThickness = 3 + }); + + // Call + converter.ConvertSeriesProperties(data, areaSeries); + + // Assert + AssertColors(expectedColor, areaSeries.Color); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void ConvertSeriesProperties_WithDifferentStrokeWidths_AppliesStyleToSeries(int width) + { + // Setup + var converter = new ChartAreaDataConverter(); + var areaSeries = new AreaSeries(); + var data = new ChartAreaData("test", new ChartAreaStyle + { + FillColor = Color.Red, + StrokeColor = Color.Red, + StrokeThickness = width + }); + + // Call + converter.ConvertSeriesProperties(data, areaSeries); + + // Assert + Assert.AreEqual(width, areaSeries.StrokeThickness); + } + + private static void AssertColors(Color color, OxyColor oxyColor) + { + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), oxyColor); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartDataConverterTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartDataConverterTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartDataConverterTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,138 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Common.TestUtil; +using Core.Components.Chart.TestUtil; +using Core.Components.OxyPlot.Converter.Chart; +using NUnit.Framework; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Test.Converter.Chart +{ + [TestFixture] + public class ChartDataConverterTest + { + [Test] + public void ConvertSeriesItems_DataNull_ThrowsArgumentNullException() + { + // Setup + var testConverter = new TestChartDataConverter(); + var series = new TestSeries(); + + // Call + TestDelegate test = () => testConverter.ConvertSeriesData(null, series); + + // Assert + const string expectedMessage = "Null data cannot be converted into series data."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void ConvertSeriesItems_TargetSeriesNull_ThrowsArgumentNullException() + { + // Setup + var testConverter = new TestChartDataConverter(); + var chartData = new TestChartData("test data"); + + // Call + TestDelegate test = () => testConverter.ConvertSeriesData(chartData, null); + + // Assert + const string expectedMessage = "Null data cannot be used as conversion target."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void ConvertSeriesProperties_DataNull_ThrowsArgumentNullException() + { + // Setup + var testConverter = new TestChartDataConverter(); + var series = new TestSeries(); + + // Call + TestDelegate test = () => testConverter.ConvertSeriesProperties(null, series); + + // Assert + const string expectedMessage = "Null data cannot be converted into series data."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void ConvertSeriesProperties_TargetSeriesNull_ThrowsArgumentNullException() + { + // Setup + var testConverter = new TestChartDataConverter(); + var chartData = new TestChartData("test data"); + + // Call + TestDelegate test = () => testConverter.ConvertSeriesProperties(chartData, null); + + // Assert + const string expectedMessage = "Null data cannot be used as conversion target."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] + public void ConvertSeriesProperties_ChartData_NameSetToSeries() + { + // Setup + const string name = ""; + var testConverter = new TestChartDataConverter(); + var chartData = new TestChartData(name); + var chartSeries = new TestSeries(); + + // Call + testConverter.ConvertSeriesProperties(chartData, chartSeries); + + // Assert + Assert.AreEqual(name, chartSeries.Title); + } + + [TestCase(true)] + [TestCase(false)] + public void ConvertSeriesProperties_ChartData_IsVisibleSetToSeries(bool isVisible) + { + // Setup + var testConverter = new TestChartDataConverter(); + var chartData = new TestChartData("test data") + { + IsVisible = isVisible + }; + var chartSeries = new TestSeries(); + + // Call + testConverter.ConvertSeriesProperties(chartData, chartSeries); + + // Assert + Assert.AreEqual(isVisible, chartSeries.IsVisible); + } + + private class TestSeries : LineSeries {} + + private class TestChartDataConverter : ChartDataConverter + { + protected override void SetSeriesData(TestChartData data, TestSeries series) {} + + protected override void SetSeriesStyle(TestChartData data, TestSeries series) {} + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartLineDataConverterTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartLineDataConverterTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartLineDataConverterTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,153 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.Converter.Chart; +using NUnit.Framework; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Test.Converter.Chart +{ + [TestFixture] + public class ChartLineDataConverterTest + { + [Test] + public void DefaultConstructor_IsChartDataConverter() + { + // Call + var converter = new ChartLineDataConverter(); + + // Assert + Assert.IsInstanceOf>(converter); + } + + [Test] + public void ConvertSeriesItems_ChartLineDataWithRandomPointData_ConvertsAllPointsToLineSeries() + { + // Setup + var converter = new ChartLineDataConverter(); + var lineSeries = new LineSeries(); + var random = new Random(21); + int randomCount = random.Next(5, 10); + var points = new Collection(); + + for (var i = 0; i < randomCount; i++) + { + points.Add(new Point2D(random.NextDouble(), random.NextDouble())); + } + + var lineData = new ChartLineData("test data") + { + Points = points.ToArray() + }; + + // Call + converter.ConvertSeriesData(lineData, lineSeries); + + // Assert + CollectionAssert.AreEqual(points.Select(p => new DataPoint(p.X, p.Y)), lineSeries.ItemsSource); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void ConvertSeriesProperties_ChartLineStyleSetWithDifferentColors_AppliesStyleToSeries(KnownColor color) + { + // Setup + var converter = new ChartLineDataConverter(); + var lineSeries = new LineSeries(); + Color expectedColor = Color.FromKnownColor(color); + var data = new ChartLineData("test", new ChartLineStyle + { + Color = expectedColor, + Width = 3, + DashStyle = ChartLineDashStyle.Solid + }); + + // Call + converter.ConvertSeriesProperties(data, lineSeries); + + // Assert + AssertColors(expectedColor, lineSeries.Color); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void ConvertSeriesProperties_ChartLineStyleSetWithDifferentWidths_AppliesStyleToSeries(int width) + { + // Setup + var converter = new ChartLineDataConverter(); + var lineSeries = new LineSeries(); + var data = new ChartLineData("test", new ChartLineStyle + { + Color = Color.Red, + Width = width, + DashStyle = ChartLineDashStyle.Solid + }); + + // Call + converter.ConvertSeriesProperties(data, lineSeries); + + // Assert + Assert.AreEqual(width, lineSeries.StrokeThickness); + } + + [Test] + [TestCase(ChartLineDashStyle.Solid, LineStyle.Solid)] + [TestCase(ChartLineDashStyle.Dash, LineStyle.Dash)] + [TestCase(ChartLineDashStyle.Dot, LineStyle.Dot)] + [TestCase(ChartLineDashStyle.DashDot, LineStyle.DashDot)] + [TestCase(ChartLineDashStyle.DashDotDot, LineStyle.DashDotDot)] + public void ConvertSeriesProperties_ChartLineStyleSetWithDifferentDashStyles_AppliesStyleToSeries(ChartLineDashStyle dashStyle, LineStyle expectedLineStyle) + { + // Setup + var converter = new ChartLineDataConverter(); + var lineSeries = new LineSeries(); + var data = new ChartLineData("test", new ChartLineStyle + { + Color = Color.Red, + Width = 3, + DashStyle = dashStyle + }); + + // Call + converter.ConvertSeriesProperties(data, lineSeries); + + // Assert + Assert.AreEqual(expectedLineStyle, lineSeries.LineStyle); + } + + private static void AssertColors(Color color, OxyColor oxyColor) + { + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), oxyColor); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartMultipleAreaDataConverterTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartMultipleAreaDataConverterTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartMultipleAreaDataConverterTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,164 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.Converter.Chart; +using Core.Components.OxyPlot.CustomSeries; +using NUnit.Framework; +using OxyPlot; + +namespace Core.Components.OxyPlot.Test.Converter.Chart +{ + [TestFixture] + public class ChartMultipleAreaDataConverterTest + { + [Test] + public void DefaultConstructor_IsChartDataConverter() + { + // Call + var converter = new ChartMultipleAreaDataConverter(); + + // Assert + Assert.IsInstanceOf>(converter); + } + + [Test] + public void ConvertSeriesItems_ChartMultipleAreaDataWithRandomAreaData_ConvertsAllAreasToMultipleAreaSeries() + { + // Setup + var converter = new ChartMultipleAreaDataConverter(); + var multipleAreaSeries = new MultipleAreaSeries(); + var random = new Random(21); + int randomCount = random.Next(5, 10); + + var points1 = new Collection(); + var points2 = new Collection(); + + for (var i = 0; i < randomCount; i++) + { + points1.Add(new Point2D(random.NextDouble(), random.NextDouble())); + points2.Add(new Point2D(random.NextDouble(), random.NextDouble())); + } + + var areas = new List + { + points1.ToArray(), + points2.ToArray() + }; + + var areaData = new ChartMultipleAreaData("test data") + { + Areas = areas + }; + + // Call + converter.ConvertSeriesData(areaData, multipleAreaSeries); + + // Assert + Assert.AreEqual(2, multipleAreaSeries.Areas.Count); + CollectionAssert.AreEqual(areas.ElementAt(0).Select(t => new DataPoint(t.X, t.Y)), multipleAreaSeries.Areas[0]); + CollectionAssert.AreEqual(areas.ElementAt(1).Select(t => new DataPoint(t.X, t.Y)), multipleAreaSeries.Areas[1]); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void ConvertSeriesProperties_ChartAreaStyleSetWithDifferentFillColors_AppliesStyleToSeries(KnownColor color) + { + // Setup + var converter = new ChartMultipleAreaDataConverter(); + var multipleAreaSeries = new MultipleAreaSeries(); + Color expectedColor = Color.FromKnownColor(color); + var data = new ChartMultipleAreaData("test", new ChartAreaStyle + { + FillColor = expectedColor, + StrokeColor = Color.Red, + StrokeThickness = 3 + }); + + // Call + converter.ConvertSeriesProperties(data, multipleAreaSeries); + + // Assert + AssertColors(expectedColor, multipleAreaSeries.Fill); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void ConvertSeriesProperties_ChartAreaStyleSetWithDifferentStrokeColors_AppliesStyleToSeries(KnownColor color) + { + // Setup + var converter = new ChartMultipleAreaDataConverter(); + var multipleAreaSeries = new MultipleAreaSeries(); + Color expectedColor = Color.FromKnownColor(color); + var data = new ChartMultipleAreaData("test", new ChartAreaStyle + { + FillColor = Color.Red, + StrokeColor = expectedColor, + StrokeThickness = 3 + }); + + // Call + converter.ConvertSeriesProperties(data, multipleAreaSeries); + + // Assert + AssertColors(expectedColor, multipleAreaSeries.Color); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void ConvertSeriesProperties_ChartAreaStyleSetWithDifferentStrokeWidths_AppliesStyleToSeries(int width) + { + // Setup + var converter = new ChartMultipleAreaDataConverter(); + var multipleAreaSeries = new MultipleAreaSeries(); + var data = new ChartMultipleAreaData("test", new ChartAreaStyle + { + FillColor = Color.Red, + StrokeColor = Color.Red, + StrokeThickness = width + }); + + // Call + converter.ConvertSeriesProperties(data, multipleAreaSeries); + + // Assert + Assert.AreEqual(width, multipleAreaSeries.StrokeThickness); + } + + private static void AssertColors(Color color, OxyColor oxyColor) + { + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), oxyColor); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartMultipleLineDataConverterTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartMultipleLineDataConverterTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartMultipleLineDataConverterTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,161 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.Converter.Chart; +using Core.Components.OxyPlot.CustomSeries; +using NUnit.Framework; +using OxyPlot; + +namespace Core.Components.OxyPlot.Test.Converter.Chart +{ + [TestFixture] + public class ChartMultipleLineDataConverterTest + { + [Test] + public void DefaultConstructor_IsChartDataConverter() + { + // Call + var converter = new ChartMultipleLineDataConverter(); + + // Assert + Assert.IsInstanceOf>(converter); + } + + [Test] + public void ConvertSeriesItems_ChartMultipleLineDataWithRandomLineData_ConvertsAllLinesToMultipleLineSeries() + { + // Setup + var converter = new ChartMultipleLineDataConverter(); + var multipleLineSeries = new MultipleLineSeries(); + var random = new Random(21); + int randomCount = random.Next(5, 10); + + var points1 = new Collection(); + var points2 = new Collection(); + + for (var i = 0; i < randomCount; i++) + { + points1.Add(new Point2D(random.NextDouble(), random.NextDouble())); + points2.Add(new Point2D(random.NextDouble(), random.NextDouble())); + } + + var lines = new List + { + points1.ToArray(), + points2.ToArray() + }; + + var lineData = new ChartMultipleLineData("test data") + { + Lines = lines + }; + + // Call + converter.ConvertSeriesData(lineData, multipleLineSeries); + + // Assert + Assert.AreEqual(2, multipleLineSeries.Lines.Count); + CollectionAssert.AreEqual(lines.ElementAt(0).Select(t => new DataPoint(t.X, t.Y)), multipleLineSeries.Lines[0]); + CollectionAssert.AreEqual(lines.ElementAt(1).Select(t => new DataPoint(t.X, t.Y)), multipleLineSeries.Lines[1]); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void ConvertSeriesProperties_ChartLineStyleSetWithDifferentStrokeColors_AppliesStyleToSeries(KnownColor color) + { + // Setup + var converter = new ChartMultipleLineDataConverter(); + var multipleLineSeries = new MultipleLineSeries(); + Color expectedColor = Color.FromKnownColor(color); + var data = new ChartMultipleLineData("test", new ChartLineStyle + { + Color = expectedColor, + Width = 3, + DashStyle = ChartLineDashStyle.Solid + }); + + // Call + converter.ConvertSeriesProperties(data, multipleLineSeries); + + // Assert + Assert.AreEqual(OxyColor.FromArgb(expectedColor.A, expectedColor.R, expectedColor.G, expectedColor.B), multipleLineSeries.Color); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void ConvertSeriesProperties_ChartLineStyleSetWithDifferentStrokeWidths_AppliesStyleToSeries(int width) + { + // Setup + var converter = new ChartMultipleLineDataConverter(); + var multipleLineSeries = new MultipleLineSeries(); + var data = new ChartMultipleLineData("test", new ChartLineStyle + { + Color = Color.Red, + Width = width, + DashStyle = ChartLineDashStyle.Solid + }); + + // Call + converter.ConvertSeriesProperties(data, multipleLineSeries); + + // Assert + Assert.AreEqual(width, multipleLineSeries.StrokeThickness); + } + + [Test] + [TestCase(ChartLineDashStyle.Solid, LineStyle.Solid)] + [TestCase(ChartLineDashStyle.Dash, LineStyle.Dash)] + [TestCase(ChartLineDashStyle.Dot, LineStyle.Dot)] + [TestCase(ChartLineDashStyle.DashDot, LineStyle.DashDot)] + [TestCase(ChartLineDashStyle.DashDotDot, LineStyle.DashDotDot)] + 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); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartPointDataConverterTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartPointDataConverterTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/Converter/Chart/ChartPointDataConverterTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,211 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.ObjectModel; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.Converter.Chart; +using NUnit.Framework; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Test.Converter.Chart +{ + [TestFixture] + public class ChartPointDataConverterTest + { + [Test] + public void DefaultConstructor_IsChartDataConverter() + { + // Call + var converter = new ChartPointDataConverter(); + + // Assert + Assert.IsInstanceOf>(converter); + } + + [Test] + public void ConvertSeriesItems_ChartPointDataWithRandomPointData_ConvertsAllPointsToPointSeries() + { + // Setup + var converter = new ChartPointDataConverter(); + var lineSeries = new LineSeries(); + var random = new Random(21); + int randomCount = random.Next(5, 10); + + var points = new Collection(); + + for (var i = 0; i < randomCount; i++) + { + points.Add(new Point2D(random.NextDouble(), random.NextDouble())); + } + + var pointData = new ChartPointData("test data") + { + Points = points.ToArray() + }; + + // Call + converter.ConvertSeriesData(pointData, lineSeries); + + // Assert + CollectionAssert.AreEqual(points.Select(p => new DataPoint(p.X, p.Y)), lineSeries.ItemsSource); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void ConvertSeriesProperties_ChartPointStyleSetWithDifferentColors_AppliesStyleToSeries(KnownColor color) + { + // Setup + var converter = new ChartPointDataConverter(); + var lineSeries = new LineSeries(); + Color expectedColor = Color.FromKnownColor(color); + var data = new ChartPointData("test", new ChartPointStyle + { + Color = expectedColor, + StrokeColor = Color.Red, + Size = 3, + StrokeThickness = 2, + Symbol = ChartPointSymbol.Circle + }); + + // Call + converter.ConvertSeriesProperties(data, lineSeries); + + // Assert + AssertColors(expectedColor, lineSeries.MarkerFill); + } + + [Test] + [TestCase(KnownColor.AliceBlue)] + [TestCase(KnownColor.Azure)] + [TestCase(KnownColor.Beige)] + public void ConvertSeriesProperties_ChartPointStyleSetWithDifferentStrokeColors_AppliesStyleToSeries(KnownColor color) + { + // Setup + var converter = new ChartPointDataConverter(); + var lineSeries = new LineSeries(); + Color expectedColor = Color.FromKnownColor(color); + var data = new ChartPointData("test", new ChartPointStyle + { + Color = Color.Red, + StrokeColor = expectedColor, + Size = 3, + StrokeThickness = 2, + Symbol = ChartPointSymbol.Circle + }); + + // Call + converter.ConvertSeriesProperties(data, lineSeries); + + // Assert + AssertColors(expectedColor, lineSeries.MarkerStroke); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void ConvertSeriesProperties_ChartPointStyleSetWithDifferentWidths_AppliesStyleToSeries(int width) + { + // Setup + var converter = new ChartPointDataConverter(); + var lineSeries = new LineSeries(); + var data = new ChartPointData("test", new ChartPointStyle + { + Color = Color.Red, + StrokeColor = Color.Red, + Size = width, + StrokeThickness = 2, + Symbol = ChartPointSymbol.Circle + }); + + // Call + converter.ConvertSeriesProperties(data, lineSeries); + + // Assert + Assert.AreEqual(width, lineSeries.MarkerSize); + } + + [Test] + [TestCase(1)] + [TestCase(5)] + [TestCase(7)] + public void ConvertSeriesProperties_ChartPointStyleSetWithDifferentStrokeThickness_AppliesStyleToSeries(int strokeThickness) + { + // 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 = strokeThickness, + Symbol = ChartPointSymbol.Circle + }); + + // Call + converter.ConvertSeriesProperties(data, lineSeries); + + // Assert + Assert.AreEqual(strokeThickness, lineSeries.MarkerStrokeThickness); + } + + [Test] + [TestCase(ChartPointSymbol.Circle, MarkerType.Circle)] + [TestCase(ChartPointSymbol.Square, MarkerType.Square)] + [TestCase(ChartPointSymbol.Diamond, MarkerType.Diamond)] + [TestCase(ChartPointSymbol.Triangle, MarkerType.Triangle)] + [TestCase(ChartPointSymbol.Star, MarkerType.Star)] + 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); + } + + private static void AssertColors(Color color, OxyColor oxyColor) + { + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), oxyColor); + } + } +} \ No newline at end of file Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartAreaDataConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartDataConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartLineDataConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartMultipleAreaDataConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartMultipleLineDataConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/Converter/ChartPointDataConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj =================================================================== diff -u -r4a60f6ca9a08736cfaf0fac6e6f2e89e9fa59aae -rbf790921e622ee49149a92e6b52668fb30d6e3a6 --- Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj (.../Core.Components.OxyPlot.Test.csproj) (revision 4a60f6ca9a08736cfaf0fac6e6f2e89e9fa59aae) +++ Core/Components/test/Core.Components.OxyPlot.Test/Core.Components.OxyPlot.Test.csproj (.../Core.Components.OxyPlot.Test.csproj) (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -58,23 +58,23 @@ Properties\GlobalAssembly.cs - - - + + + - - - + + + - - - - - + + + + + - + Index: Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartAreaDataSeriesTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartAreaDataSeriesTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartAreaDataSeriesTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,180 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.DataSeries; +using Core.Components.OxyPlot.DataSeries.Chart; +using NUnit.Framework; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Test.DataSeries.Chart +{ + [TestFixture] + public class ChartAreaDataSeriesTest + { + private static readonly Color fillColor = Color.Red; + private static readonly Color strokeColor = Color.Blue; + + [Test] + public void Constructor_WithoutChartAreaData_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ChartAreaDataSeries(null); + + // Assert + string parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("chartAreaData", parameter); + } + + [Test] + public void Constructor_ChartAreaDataWithTestProperties_ChartAreaDataSeriesCreatedAccordingly() + { + // Setup + var chartAreaData = new ChartAreaData("Test name", new ChartAreaStyle + { + FillColor = fillColor, + StrokeColor = strokeColor, + StrokeThickness = 3 + }); + + SetChartAreaDataTestProperties(chartAreaData); + + // Call + var chartAreaDataSeries = new ChartAreaDataSeries(chartAreaData); + + // Assert + Assert.IsInstanceOf(chartAreaDataSeries); + Assert.IsInstanceOf(chartAreaDataSeries); + AssertChartAreaDataSeriesTestProperties(chartAreaDataSeries); + } + + [Test] + public void Update_ChartAreaDataWithTestProperties_ChartAreaDataSeriesUpdatedAccordingly() + { + // Setup + var chartAreaData = new ChartAreaData("Test name", new ChartAreaStyle + { + FillColor = fillColor, + StrokeColor = strokeColor, + StrokeThickness = 3 + }); + var chartAreaDataSeries = new ChartAreaDataSeries(chartAreaData); + + SetChartAreaDataTestProperties(chartAreaData); + + // Precondition + AssertChartAreaDataSeriesDefaultProperties(chartAreaDataSeries); + + // Call + chartAreaDataSeries.Update(); + + // Assert + AssertChartAreaDataSeriesTestProperties(chartAreaDataSeries); + } + + [Test] + public void GivenChartAreaDataSeries_WhenUpdatedAfterChartAreaDataPointsChanged_ChartAreaDataSeriesPointsChanged() + { + // Given + var chartAreaData = new ChartAreaData("Test name") + { + Points = new[] + { + new Point2D(1.1, 2.2) + } + }; + + var chartAreaDataSeries = new ChartAreaDataSeries(chartAreaData); + DataPoint[] drawnPoints = chartAreaDataSeries.Points.ToArray(); + + // When + chartAreaData.Points = new[] + { + new Point2D(3.3, 4.4) + }; + chartAreaDataSeries.Update(); + + // Then + CollectionAssert.AreNotEqual(drawnPoints, chartAreaDataSeries.Points); + } + + [Test] + public void GivenChartAreaDataSeries_WhenUpdatedAndChartAreaDataPointsNotChanged_PreviousChartAreaDataSeriesPointsPreserved() + { + // Given + var chartAreaData = new ChartAreaData("Test name") + { + Points = new[] + { + new Point2D(1.1, 2.2) + } + }; + + var chartAreaDataSeries = new ChartAreaDataSeries(chartAreaData); + DataPoint[] drawnPoints = chartAreaDataSeries.Points.ToArray(); + + // When + chartAreaDataSeries.Update(); + + // Then + CollectionAssert.AreEqual(drawnPoints, chartAreaDataSeries.Points); + } + + private static void SetChartAreaDataTestProperties(ChartAreaData chartAreaData) + { + chartAreaData.Name = "Another name"; + chartAreaData.IsVisible = false; + chartAreaData.Points = new[] + { + new Point2D(1.1, 2.2) + }; + } + + private static void AssertChartAreaDataSeriesTestProperties(ChartAreaDataSeries chartAreaDataSeries) + { + Assert.AreEqual("Another name", chartAreaDataSeries.Title); + Assert.IsFalse(chartAreaDataSeries.IsVisible); + + Assert.AreEqual(3, chartAreaDataSeries.StrokeThickness); + Assert.AreEqual(OxyColor.FromArgb(fillColor.A, fillColor.R, fillColor.G, fillColor.B), chartAreaDataSeries.Fill); + Assert.AreEqual(OxyColor.FromArgb(strokeColor.A, strokeColor.R, strokeColor.G, strokeColor.B), chartAreaDataSeries.Color); + + Assert.AreEqual(1, chartAreaDataSeries.Points.Count); + } + + private static void AssertChartAreaDataSeriesDefaultProperties(ChartAreaDataSeries chartAreaDataSeries) + { + Assert.AreEqual("Test name", chartAreaDataSeries.Title); + Assert.IsTrue(chartAreaDataSeries.IsVisible); + + Assert.AreEqual(3, chartAreaDataSeries.StrokeThickness); + Assert.AreEqual(OxyColor.FromArgb(fillColor.A, fillColor.R, fillColor.G, fillColor.B), chartAreaDataSeries.Fill); + Assert.AreEqual(OxyColor.FromArgb(strokeColor.A, strokeColor.R, strokeColor.G, strokeColor.B), chartAreaDataSeries.Color); + + Assert.AreEqual(0, chartAreaDataSeries.Points.Count); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartDataSeriesFactoryTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartDataSeriesFactoryTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartDataSeriesFactoryTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,107 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Core.Components.Chart.Data; +using Core.Components.Chart.TestUtil; +using Core.Components.OxyPlot.DataSeries; +using Core.Components.OxyPlot.DataSeries.Chart; +using NUnit.Framework; + +namespace Core.Components.OxyPlot.Test.DataSeries.Chart +{ + [TestFixture] + public class ChartDataSeriesFactoryTest + { + [Test] + public void Create_ChartPointData_ReturnChartPointDataSeries() + { + // Call + IChartDataSeries series = ChartDataSeriesFactory.Create(new ChartPointData("test data")); + + // Assert + Assert.IsInstanceOf(series); + } + + [Test] + public void Create_ChartLineData_ReturnChartLineDataSeries() + { + // Call + IChartDataSeries series = ChartDataSeriesFactory.Create(new ChartLineData("test data")); + + // Assert + Assert.IsInstanceOf(series); + } + + [Test] + public void Create_ChartAreaData_ReturnChartAreaDataSeries() + { + // Call + IChartDataSeries series = ChartDataSeriesFactory.Create(new ChartAreaData("test data")); + + // Assert + Assert.IsInstanceOf(series); + } + + [Test] + public void Create_ChartMultipleAreaData_ReturnChartMultipleAreaDataSeries() + { + // Call + IChartDataSeries series = ChartDataSeriesFactory.Create(new ChartMultipleAreaData("test data")); + + // Assert + Assert.IsInstanceOf(series); + } + + [Test] + public void Create_ChartMultipleLineData_ReturnChartMultipleLineDataSeries() + { + // Call + IChartDataSeries series = ChartDataSeriesFactory.Create(new ChartMultipleLineData("test data")); + + // Assert + Assert.IsInstanceOf(series); + } + + [Test] + public void Create_OtherData_ThrowsNotSupportedException() + { + // Setup + var testData = new TestChartData("test data"); + + // Call + TestDelegate test = () => ChartDataSeriesFactory.Create(testData); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Create_NullData_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => ChartDataSeriesFactory.Create(null); + + // Assert + Assert.Throws(test); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartLineDataSeriesTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartLineDataSeriesTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartLineDataSeriesTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,181 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.DataSeries; +using Core.Components.OxyPlot.DataSeries.Chart; +using NUnit.Framework; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Test.DataSeries.Chart +{ + [TestFixture] + public class ChartLineDataSeriesTest + { + private static readonly Color color = Color.Blue; + + [Test] + public void Constructor_WithoutChartLineData_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ChartLineDataSeries(null); + + // Assert + string parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("chartLineData", parameter); + } + + [Test] + public void Constructor_ChartLineDataWithTestProperties_ChartLineDataSeriesCreatedAccordingly() + { + // Setup + var chartLineData = new ChartLineData("Test name", new ChartLineStyle + { + Color = color, + Width = 3, + DashStyle = ChartLineDashStyle.DashDot + }); + + SetChartLineDataTestProperties(chartLineData); + + // Call + var chartLineDataSeries = new ChartLineDataSeries(chartLineData); + + // Assert + Assert.IsInstanceOf(chartLineDataSeries); + Assert.IsInstanceOf(chartLineDataSeries); + AssertChartLineDataSeriesTestProperties(chartLineDataSeries); + } + + [Test] + public void Update_ChartLineDataWithTestProperties_ChartLineDataSeriesUpdatedAccordingly() + { + // Setup + var chartLineData = new ChartLineData("Test name", new ChartLineStyle + { + Color = color, + Width = 3, + DashStyle = ChartLineDashStyle.DashDot + }); + var chartLineDataSeries = new ChartLineDataSeries(chartLineData); + + SetChartLineDataTestProperties(chartLineData); + + // Precondition + AssertChartLineDataSeriesDefaultProperties(chartLineDataSeries); + + // Call + chartLineDataSeries.Update(); + + // Assert + AssertChartLineDataSeriesTestProperties(chartLineDataSeries); + } + + [Test] + public void GivenChartLineDataSeries_WhenUpdatedAfterChartLineDataPointsChanged_ChartLineDataSeriesPointsChanged() + { + // Given + var chartLineData = new ChartLineData("Test name") + { + Points = new[] + { + new Point2D(1.1, 2.2) + } + }; + + var chartLineDataSeries = new ChartLineDataSeries(chartLineData); + IEnumerable drawnPoints = chartLineDataSeries.ItemsSource.Cast(); + + // When + chartLineData.Points = new[] + { + new Point2D(3.3, 4.4) + }; + chartLineDataSeries.Update(); + + // Then + CollectionAssert.AreNotEqual(drawnPoints, chartLineDataSeries.ItemsSource.Cast()); + } + + [Test] + public void GivenChartLineDataSeries_WhenUpdatedAndChartLineDataPointsNotChanged_PreviousChartLineDataSeriesPointsPreserved() + { + // Given + var chartLineData = new ChartLineData("Test name") + { + Points = new[] + { + new Point2D(1.1, 2.2) + } + }; + + var chartLineDataSeries = new ChartLineDataSeries(chartLineData); + IEnumerable drawnPoints = chartLineDataSeries.ItemsSource.Cast(); + + // When + chartLineDataSeries.Update(); + + // Then + CollectionAssert.AreEqual(drawnPoints, chartLineDataSeries.ItemsSource.Cast()); + } + + private static void SetChartLineDataTestProperties(ChartLineData chartLineData) + { + chartLineData.Name = "Another name"; + chartLineData.IsVisible = false; + chartLineData.Points = new[] + { + new Point2D(1.1, 2.2) + }; + } + + private static void AssertChartLineDataSeriesTestProperties(ChartLineDataSeries chartLineDataSeries) + { + Assert.AreEqual("Another name", chartLineDataSeries.Title); + Assert.IsFalse(chartLineDataSeries.IsVisible); + + Assert.AreEqual(3, chartLineDataSeries.StrokeThickness); + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), chartLineDataSeries.Color); + Assert.AreEqual(LineStyle.DashDot, chartLineDataSeries.LineStyle); + + Assert.AreEqual(1, chartLineDataSeries.ItemsSource.Cast().Count()); + } + + private static void AssertChartLineDataSeriesDefaultProperties(ChartLineDataSeries chartLineDataSeries) + { + Assert.AreEqual("Test name", chartLineDataSeries.Title); + Assert.IsTrue(chartLineDataSeries.IsVisible); + + Assert.AreEqual(3, chartLineDataSeries.StrokeThickness); + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), chartLineDataSeries.Color); + Assert.AreEqual(LineStyle.DashDot, chartLineDataSeries.LineStyle); + + Assert.AreEqual(0, chartLineDataSeries.ItemsSource.Cast().Count()); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartMultipleAreaDataSeriesTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartMultipleAreaDataSeriesTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartMultipleAreaDataSeriesTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,193 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.CustomSeries; +using Core.Components.OxyPlot.DataSeries; +using Core.Components.OxyPlot.DataSeries.Chart; +using NUnit.Framework; +using OxyPlot; + +namespace Core.Components.OxyPlot.Test.DataSeries.Chart +{ + [TestFixture] + public class ChartMultipleAreaDataSeriesTest + { + private static readonly Color fillColor = Color.Red; + private static readonly Color strokeColor = Color.Blue; + + [Test] + public void Constructor_WithoutChartMultipleAreaData_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ChartMultipleAreaDataSeries(null); + + // Assert + string parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("chartMultipleAreaData", parameter); + } + + [Test] + public void Constructor_ChartMultipleAreaDataWithTestProperties_ChartMultipleAreaDataSeriesCreatedAccordingly() + { + // Setup + var chartMultipleAreaData = new ChartMultipleAreaData("Test name", new ChartAreaStyle + { + FillColor = fillColor, + StrokeColor = strokeColor, + StrokeThickness = 3 + }); + + SetChartMultipleAreaDataTestProperties(chartMultipleAreaData); + + // Call + var chartMultipleAreaDataSeries = new ChartMultipleAreaDataSeries(chartMultipleAreaData); + + // Assert + Assert.IsInstanceOf(chartMultipleAreaDataSeries); + Assert.IsInstanceOf(chartMultipleAreaDataSeries); + AssertChartMultipleAreaDataSeriesTestProperties(chartMultipleAreaDataSeries); + } + + [Test] + public void Update_ChartMultipleAreaDataWithTestProperties_ChartMultipleAreaDataSeriesUpdatedAccordingly() + { + // Setup + var chartMultipleAreaData = new ChartMultipleAreaData("Test name", new ChartAreaStyle + { + FillColor = fillColor, + StrokeColor = strokeColor, + StrokeThickness = 3 + }); + var chartMultipleAreaDataSeries = new ChartMultipleAreaDataSeries(chartMultipleAreaData); + + SetChartMultipleAreaDataTestProperties(chartMultipleAreaData); + + // Precondition + AssertChartMultipleAreaDataSeriesDefaultProperties(chartMultipleAreaDataSeries); + + // Call + chartMultipleAreaDataSeries.Update(); + + // Assert + AssertChartMultipleAreaDataSeriesTestProperties(chartMultipleAreaDataSeries); + } + + [Test] + public void GivenChartMultipleAreaDataSeries_WhenUpdatedAfterChartMultipleAreaDataAreasChanged_ChartMultipleAreaDataSeriesAreasChanged() + { + // Given + var chartMultipleAreaData = new ChartMultipleAreaData("Test name") + { + Areas = new[] + { + new[] + { + new Point2D(1.1, 2.2) + } + } + }; + + var chartMultipleAreaDataSeries = new ChartMultipleAreaDataSeries(chartMultipleAreaData); + DataPoint[][] drawnAreas = chartMultipleAreaDataSeries.Areas.ToArray(); + + // When + chartMultipleAreaData.Areas = new[] + { + new[] + { + new Point2D(3.3, 4.4) + } + }; + chartMultipleAreaDataSeries.Update(); + + // Then + CollectionAssert.AreNotEqual(drawnAreas, chartMultipleAreaDataSeries.Areas); + } + + [Test] + public void GivenChartMultipleAreaDataSeries_WhenUpdatedAndChartMultipleAreaDataAreasNotChanged_PreviousChartMultipleAreaDataSeriesAreasPreserved() + { + // Given + var chartMultipleAreaData = new ChartMultipleAreaData("Test name") + { + Areas = new[] + { + new[] + { + new Point2D(1.1, 2.2) + } + } + }; + + var chartMultipleAreaDataSeries = new ChartMultipleAreaDataSeries(chartMultipleAreaData); + DataPoint[][] drawnAreas = chartMultipleAreaDataSeries.Areas.ToArray(); + + // When + chartMultipleAreaDataSeries.Update(); + + // Then + CollectionAssert.AreEqual(drawnAreas, chartMultipleAreaDataSeries.Areas); + } + + private static void SetChartMultipleAreaDataTestProperties(ChartMultipleAreaData chartMultipleAreaData) + { + chartMultipleAreaData.Name = "Another name"; + chartMultipleAreaData.IsVisible = false; + chartMultipleAreaData.Areas = new[] + { + new[] + { + new Point2D(1.1, 2.2) + } + }; + } + + private static void AssertChartMultipleAreaDataSeriesTestProperties(ChartMultipleAreaDataSeries chartMultipleAreaDataSeries) + { + Assert.AreEqual("Another name", chartMultipleAreaDataSeries.Title); + Assert.IsFalse(chartMultipleAreaDataSeries.IsVisible); + + Assert.AreEqual(3, chartMultipleAreaDataSeries.StrokeThickness); + Assert.AreEqual(OxyColor.FromArgb(fillColor.A, fillColor.R, fillColor.G, fillColor.B), chartMultipleAreaDataSeries.Fill); + Assert.AreEqual(OxyColor.FromArgb(strokeColor.A, strokeColor.R, strokeColor.G, strokeColor.B), chartMultipleAreaDataSeries.Color); + + Assert.AreEqual(1, chartMultipleAreaDataSeries.Areas.Count); + } + + private static void AssertChartMultipleAreaDataSeriesDefaultProperties(ChartMultipleAreaDataSeries chartMultipleAreaDataSeries) + { + Assert.AreEqual("Test name", chartMultipleAreaDataSeries.Title); + Assert.IsTrue(chartMultipleAreaDataSeries.IsVisible); + + Assert.AreEqual(3, chartMultipleAreaDataSeries.StrokeThickness); + Assert.AreEqual(OxyColor.FromArgb(fillColor.A, fillColor.R, fillColor.G, fillColor.B), chartMultipleAreaDataSeries.Fill); + Assert.AreEqual(OxyColor.FromArgb(strokeColor.A, strokeColor.R, strokeColor.G, strokeColor.B), chartMultipleAreaDataSeries.Color); + + Assert.AreEqual(0, chartMultipleAreaDataSeries.Areas.Count); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartMultipleLineDataSeriesTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartMultipleLineDataSeriesTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartMultipleLineDataSeriesTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,192 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.CustomSeries; +using Core.Components.OxyPlot.DataSeries; +using Core.Components.OxyPlot.DataSeries.Chart; +using NUnit.Framework; +using OxyPlot; + +namespace Core.Components.OxyPlot.Test.DataSeries.Chart +{ + [TestFixture] + public class ChartMultipleLineDataSeriesTest + { + private static readonly Color color = Color.Red; + + [Test] + public void Constructor_ChartMultipleLineDataNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ChartMultipleLineDataSeries(null); + + // Assert + string parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("chartMultipleLineData", parameter); + } + + [Test] + public void Constructor_ChartMultipleLineDataWithTestProperties_ChartMultipleLineDataSeriesCreatedAccordingly() + { + // Setup + var chartMultipleLineData = new ChartMultipleLineData("Test name", new ChartLineStyle + { + Color = color, + Width = 3, + DashStyle = ChartLineDashStyle.Dash + }); + + SetChartMultipleLineDataTestProperties(chartMultipleLineData); + + // Call + var chartMultipleLineDataSeries = new ChartMultipleLineDataSeries(chartMultipleLineData); + + // Assert + Assert.IsInstanceOf(chartMultipleLineDataSeries); + Assert.IsInstanceOf(chartMultipleLineDataSeries); + AssertChartMultipleLineDataSeriesTestProperties(chartMultipleLineDataSeries); + } + + [Test] + public void Update_ChartMultipleLineDataWithTestProperties_ChartMultipleLineDataSeriesUpdatedAccordingly() + { + // Setup + var chartMultipleLineData = new ChartMultipleLineData("Test name", new ChartLineStyle + { + Color = color, + Width = 3, + DashStyle = ChartLineDashStyle.Dash + }); + var chartMultipleLineDataSeries = new ChartMultipleLineDataSeries(chartMultipleLineData); + + SetChartMultipleLineDataTestProperties(chartMultipleLineData); + + // Precondition + AssertChartMultipleLineDataSeriesDefaultProperties(chartMultipleLineDataSeries); + + // Call + chartMultipleLineDataSeries.Update(); + + // Assert + AssertChartMultipleLineDataSeriesTestProperties(chartMultipleLineDataSeries); + } + + [Test] + public void GivenChartMultipleLineDataSeries_WhenUpdatedAfterChartMultipleLineDataLinesChanged_ChartMultipleLineDataSeriesLinesChanged() + { + // Given + var chartMultipleLineData = new ChartMultipleLineData("Test name") + { + Lines = new[] + { + new[] + { + new Point2D(1.1, 2.2) + } + } + }; + + var chartMultipleLineDataSeries = new ChartMultipleLineDataSeries(chartMultipleLineData); + DataPoint[][] drawnLines = chartMultipleLineDataSeries.Lines.ToArray(); + + // When + chartMultipleLineData.Lines = new[] + { + new[] + { + new Point2D(3.3, 4.4) + } + }; + chartMultipleLineDataSeries.Update(); + + // Then + CollectionAssert.AreNotEqual(drawnLines, chartMultipleLineDataSeries.Lines); + } + + [Test] + public void GivenChartMultipleLineDataSeries_WhenUpdatedAndChartMultipleLineDataLinesNotChanged_PreviousChartMultipleLineDataSeriesLinesPreserved() + { + // Given + var chartMultipleLineData = new ChartMultipleLineData("Test name") + { + Lines = new[] + { + new[] + { + new Point2D(1.1, 2.2) + } + } + }; + + var chartMultipleLineDataSeries = new ChartMultipleLineDataSeries(chartMultipleLineData); + DataPoint[][] drawnLines = chartMultipleLineDataSeries.Lines.ToArray(); + + // When + chartMultipleLineDataSeries.Update(); + + // Then + CollectionAssert.AreEqual(drawnLines, chartMultipleLineDataSeries.Lines); + } + + private static void SetChartMultipleLineDataTestProperties(ChartMultipleLineData chartMultipleLineData) + { + chartMultipleLineData.Name = "Another name"; + chartMultipleLineData.IsVisible = false; + chartMultipleLineData.Lines = new[] + { + new[] + { + new Point2D(1.1, 2.2) + } + }; + } + + private static void AssertChartMultipleLineDataSeriesTestProperties(ChartMultipleLineDataSeries chartMultipleLineDataSeries) + { + Assert.AreEqual("Another name", chartMultipleLineDataSeries.Title); + Assert.IsFalse(chartMultipleLineDataSeries.IsVisible); + + Assert.AreEqual(3, chartMultipleLineDataSeries.StrokeThickness); + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), chartMultipleLineDataSeries.Color); + Assert.AreEqual(LineStyle.Dash, chartMultipleLineDataSeries.LineStyle); + + Assert.AreEqual(1, chartMultipleLineDataSeries.Lines.Count); + } + + private static void AssertChartMultipleLineDataSeriesDefaultProperties(ChartMultipleLineDataSeries chartMultipleLineDataSeries) + { + Assert.AreEqual("Test name", chartMultipleLineDataSeries.Title); + Assert.IsTrue(chartMultipleLineDataSeries.IsVisible); + + Assert.AreEqual(3, chartMultipleLineDataSeries.StrokeThickness); + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), chartMultipleLineDataSeries.Color); + Assert.AreEqual(LineStyle.Dash, chartMultipleLineDataSeries.LineStyle); + + Assert.AreEqual(0, chartMultipleLineDataSeries.Lines.Count); + } + } +} \ No newline at end of file Index: Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartPointDataSeriesTest.cs =================================================================== diff -u --- Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartPointDataSeriesTest.cs (revision 0) +++ Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/Chart/ChartPointDataSeriesTest.cs (revision bf790921e622ee49149a92e6b52668fb30d6e3a6) @@ -0,0 +1,190 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Chart.Data; +using Core.Components.Chart.Styles; +using Core.Components.OxyPlot.DataSeries; +using Core.Components.OxyPlot.DataSeries.Chart; +using NUnit.Framework; +using OxyPlot; +using OxyPlot.Series; + +namespace Core.Components.OxyPlot.Test.DataSeries.Chart +{ + [TestFixture] + public class ChartPointDataSeriesTest + { + private static readonly Color color = Color.Red; + private static readonly Color strokeColor = Color.Blue; + + [Test] + public void Constructor_WithoutChartPointData_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new ChartPointDataSeries(null); + + // Assert + string parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("chartPointData", parameter); + } + + [Test] + public void Constructor_ChartPointDataWithTestProperties_ChartPointDataSeriesCreatedAccordingly() + { + // Setup + var chartPointData = new ChartPointData("Test name", new ChartPointStyle + { + Color = color, + StrokeColor = strokeColor, + Size = 4, + StrokeThickness = 2, + Symbol = ChartPointSymbol.Circle + }); + + SetChartPointDataTestProperties(chartPointData); + + // Call + var chartPointDataSeries = new ChartPointDataSeries(chartPointData); + + // Assert + Assert.IsInstanceOf(chartPointDataSeries); + Assert.IsInstanceOf(chartPointDataSeries); + AssertChartPointDataSeriesTestProperties(chartPointDataSeries); + } + + [Test] + public void Update_ChartPointDataWithTestProperties_ChartPointDataSeriesUpdatedAccordingly() + { + // Setup + var chartPointData = new ChartPointData("Test name", new ChartPointStyle + { + Color = color, + StrokeColor = strokeColor, + Size = 4, + StrokeThickness = 2, + Symbol = ChartPointSymbol.Circle + }); + var chartPointDataSeries = new ChartPointDataSeries(chartPointData); + + SetChartPointDataTestProperties(chartPointData); + + // Precondition + AssertChartPointDataSeriesDefaultProperties(chartPointDataSeries); + + // Call + chartPointDataSeries.Update(); + + // Assert + AssertChartPointDataSeriesTestProperties(chartPointDataSeries); + } + + [Test] + public void GivenChartPointDataSeries_WhenUpdatedAfterChartPointDataPointsChanged_ChartPointDataSeriesPointsChanged() + { + // Given + var chartPointData = new ChartPointData("Test name") + { + Points = new[] + { + new Point2D(1.1, 2.2) + } + }; + + var chartPointDataSeries = new ChartPointDataSeries(chartPointData); + IEnumerable drawnPoints = chartPointDataSeries.ItemsSource.Cast(); + + // When + chartPointData.Points = new[] + { + new Point2D(3.3, 4.4) + }; + chartPointDataSeries.Update(); + + // Then + CollectionAssert.AreNotEqual(drawnPoints, chartPointDataSeries.ItemsSource.Cast()); + } + + [Test] + public void GivenChartPointDataSeries_WhenUpdatedAndChartPointDataPointsNotChanged_PreviousChartPointDataSeriesPointsPreserved() + { + // Given + var chartPointData = new ChartPointData("Test name") + { + Points = new[] + { + new Point2D(1.1, 2.2) + } + }; + + var chartPointDataSeries = new ChartPointDataSeries(chartPointData); + IEnumerable drawnPoints = chartPointDataSeries.ItemsSource.Cast(); + + // When + chartPointDataSeries.Update(); + + // Then + CollectionAssert.AreEqual(drawnPoints, chartPointDataSeries.ItemsSource.Cast()); + } + + private static void SetChartPointDataTestProperties(ChartPointData chartPointData) + { + chartPointData.Name = "Another name"; + chartPointData.IsVisible = false; + chartPointData.Points = new[] + { + new Point2D(1.1, 2.2) + }; + } + + private static void AssertChartPointDataSeriesTestProperties(ChartPointDataSeries chartPointDataSeries) + { + Assert.AreEqual("Another name", chartPointDataSeries.Title); + Assert.IsFalse(chartPointDataSeries.IsVisible); + + Assert.AreEqual(4, chartPointDataSeries.MarkerSize); + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), chartPointDataSeries.MarkerFill); + Assert.AreEqual(OxyColor.FromArgb(strokeColor.A, strokeColor.R, strokeColor.G, strokeColor.B), chartPointDataSeries.MarkerStroke); + Assert.AreEqual(2, chartPointDataSeries.MarkerStrokeThickness); + Assert.AreEqual(MarkerType.Circle, chartPointDataSeries.MarkerType); + + Assert.AreEqual(1, chartPointDataSeries.ItemsSource.Cast().Count()); + } + + private static void AssertChartPointDataSeriesDefaultProperties(ChartPointDataSeries chartPointDataSeries) + { + Assert.AreEqual("Test name", chartPointDataSeries.Title); + Assert.IsTrue(chartPointDataSeries.IsVisible); + + Assert.AreEqual(4, chartPointDataSeries.MarkerSize); + Assert.AreEqual(OxyColor.FromArgb(color.A, color.R, color.G, color.B), chartPointDataSeries.MarkerFill); + Assert.AreEqual(OxyColor.FromArgb(strokeColor.A, strokeColor.R, strokeColor.G, strokeColor.B), chartPointDataSeries.MarkerStroke); + Assert.AreEqual(2, chartPointDataSeries.MarkerStrokeThickness); + Assert.AreEqual(MarkerType.Circle, chartPointDataSeries.MarkerType); + + Assert.AreEqual(0, chartPointDataSeries.ItemsSource.Cast().Count()); + } + } +} \ No newline at end of file Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/ChartAreaDataSeriesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/ChartDataSeriesFactoryTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/ChartLineDataSeriesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/ChartMultipleAreaDataSeriesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/ChartMultipleLineDataSeriesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag bf790921e622ee49149a92e6b52668fb30d6e3a6 refers to a dead (removed) revision in file `Core/Components/test/Core.Components.OxyPlot.Test/DataSeries/ChartPointDataSeriesTest.cs'. Fisheye: No comparison available. Pass `N' to diff?