Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -r184de624feae0c0a051e34298d66e304d073daf5 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 184de624feae0c0a051e34298d66e304d073daf5) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -72,6 +72,7 @@ + UserControl @@ -128,6 +129,10 @@ Core.Common.Version False + + {516EBC95-B8F2-428C-B7F6-733F01BF8FDD} + Core.Components.Charting + {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/ChartDataFactory.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/ChartDataFactory.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/ChartDataFactory.cs (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -0,0 +1,53 @@ +// Copyright (C) Stichting Deltares 2016. 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 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Charting.Data; + +namespace Ringtoets.Common.Forms.Views +{ + /// + /// Factory for creating based on information used as input in views. + /// + public static class ChartDataFactory + { + /// + /// Create a instance with a name, but without data. + /// + /// The name of the . + /// An empty object. + public static ChartLineData CreateEmptyLineData(string name) + { + return new ChartLineData(Enumerable.Empty(), name); + } + + /// + /// Create a instance with a name, but without data. + /// + /// The name of the . + /// An empty object. + public static ChartPointData CreateEmptyPointData(string name) + { + return new ChartPointData(Enumerable.Empty(), name); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -re1157c221217ef3b5ade6034183a7da0e620eb05 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision e1157c221217ef3b5ade6034183a7da0e620eb05) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -76,6 +76,7 @@ + UserControl @@ -111,6 +112,10 @@ {d749ee4c-ce50-4c17-bf01-9a953028c126} Core.Common.TestUtil + + {516EBC95-B8F2-428C-B7F6-733F01BF8FDD} + Core.Components.Charting + {C540E627-B95B-4CC0-A1B6-A0BDF74936C7} Ringtoets.GrassCoverErosionInwards.Forms Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/ChartDataFactoryTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/ChartDataFactoryTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/ChartDataFactoryTest.cs (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -0,0 +1,59 @@ +// Copyright (C) Stichting Deltares 2016. 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 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 General Public License for more details. +// +// You should have received a copy of the GNU 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 Core.Components.Charting.Data; +using NUnit.Framework; +using Ringtoets.Common.Forms.Views; + +namespace Ringtoets.Common.Forms.Test.Views +{ + [TestFixture] + public class ChartDataFactoryTest + { + [Test] + public void CreateEmptyLineData_Always_ReturnEmptyChartLineDataWithNameSet() + { + // Setup + const string name = ""; + + // Call + ChartLineData chartData = ChartDataFactory.CreateEmptyLineData(name); + + // Assert + Assert.AreEqual(name, chartData.Name); + Assert.IsEmpty(chartData.Points); + } + + [Test] + public void CreateEmptyPointData_Always_ReturnEmptyChartPointDataWithNameSet() + { + // Setup + const string name = ""; + + // Call + ChartPointData chartData = ChartDataFactory.CreateEmptyPointData(name); + + // Assert + Assert.AreEqual(name, chartData.Name); + Assert.IsEmpty(chartData.Points); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/DikeProfile.cs =================================================================== diff -u -r68588fbca4cc848bf72e39ec16940ce96c596bde -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/DikeProfile.cs (.../DikeProfile.cs) (revision 68588fbca4cc848bf72e39ec16940ce96c596bde) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/DikeProfile.cs (.../DikeProfile.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Ringtoets.GrassCoverErosionInwards.Data.Properties; @@ -32,10 +33,10 @@ /// public class DikeProfile { + private readonly List foreshoreGeometry; + private RoughnessPoint[] dikeGeometry; private RoundedDouble orientation; private RoundedDouble dikeHeight; - private readonly List foreshoreGeometry; - private readonly List dikeGeometry; /// /// Creates a new instance of the class. @@ -53,7 +54,7 @@ Name = Resources.DikeProfile_DefaultName; Memo = ""; - dikeGeometry = new List(); + dikeGeometry = new RoughnessPoint[0]; foreshoreGeometry = new List(); WorldReferencePoint = worldCoordinate; } @@ -113,7 +114,8 @@ /// /// Gets the geometry of the foreshore. /// - public List ForeshoreGeometry { + public List ForeshoreGeometry + { get { return foreshoreGeometry; @@ -129,7 +131,8 @@ /// and the succeeding . The roughness of the last /// point is irrelevant. /// - public List DikeGeometry { + public RoughnessPoint[] DikeGeometry + { get { return dikeGeometry; @@ -155,5 +158,26 @@ { return Name; } + + /// + /// Sets the geometry of the dike profile. + /// + /// The collection of defining the dike profile geometry. + /// Thrown when is null. + /// Thrown when any element of is null. + public void SetGeometry(IEnumerable points) + { + if (points == null) + { + throw new ArgumentNullException("points", Resources.DikeProfile_SetGeometry_Collection_of_points_for_geometry_is_null); + } + + if (points.Any(p => p == null)) + { + throw new ArgumentException(Resources.DikeProfile_SetGeometry_A_point_in_the_collection_was_null); + } + + dikeGeometry = points.ToArray(); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Properties/Resources.Designer.cs =================================================================== diff -u -re49a3ca2470c9d28e297149111b9adc0cc672b2c -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e49a3ca2470c9d28e297149111b9adc0cc672b2c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Runtime Version:4.0.30319.17929 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -97,6 +97,24 @@ } /// + /// Looks up a localized string similar to Een punt in de geometrie voor het dijkprofiel heeft geen waarde.. + /// + public static string DikeProfile_SetGeometry_A_point_in_the_collection_was_null { + get { + return ResourceManager.GetString("DikeProfile_SetGeometry_A_point_in_the_collection_was_null", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De geometrie die opgegeven werd voor het dijkprofiel heeft geen waarde.. + /// + public static string DikeProfile_SetGeometry_Collection_of_points_for_geometry_is_null { + get { + return ResourceManager.GetString("DikeProfile_SetGeometry_Collection_of_points_for_geometry_is_null", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Nieuwe berekening. /// public static string GrassCoverErosionInwardsCalculation_DefaultName { Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Properties/Resources.resx =================================================================== diff -u -re49a3ca2470c9d28e297149111b9adc0cc672b2c -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Properties/Resources.resx (.../Resources.resx) (revision e49a3ca2470c9d28e297149111b9adc0cc672b2c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/Properties/Resources.resx (.../Resources.resx) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -141,4 +141,10 @@ Dijkprofiel + + De geometrie die opgegeven werd voor het dijkprofiel heeft geen waarde. + + + Een punt in de geometrie voor het dijkprofiel heeft geen waarde. + \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/GrassCoverErosionInwardsDikeProfileSelectionDialog.cs =================================================================== diff -u -r7d790a82bda0347f47961162de614bacfa8e288c -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/GrassCoverErosionInwardsDikeProfileSelectionDialog.cs (.../GrassCoverErosionInwardsDikeProfileSelectionDialog.cs) (revision 7d790a82bda0347f47961162de614bacfa8e288c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/GrassCoverErosionInwardsDikeProfileSelectionDialog.cs (.../GrassCoverErosionInwardsDikeProfileSelectionDialog.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -1,4 +1,25 @@ -using System; +// Copyright (C) Stichting Deltares 2016. 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 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Windows.Forms; using Core.Common.Controls.Dialogs; Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj =================================================================== diff -u -r9bd00cf5c538409ebb1c1c68f90ca0146e93d155 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 9bd00cf5c538409ebb1c1c68f90ca0146e93d155) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Ringtoets.GrassCoverErosionInwards.Forms.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.csproj) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -75,6 +75,7 @@ + UserControl @@ -134,6 +135,11 @@ Core.Components.Charting.Forms False + + {516ebc95-b8f2-428c-b7f6-733f01bf8fdd} + Core.Components.Charting + False + {dadaa0a5-288c-49cb-9f08-337f16832c86} Core.Components.OxyPlot.Forms Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsChartDataFactory.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsChartDataFactory.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsChartDataFactory.cs (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -0,0 +1,58 @@ +// Copyright (C) Stichting Deltares 2016. 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 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Drawing.Drawing2D; +using System.Linq; +using Core.Components.Charting.Data; +using Core.Components.Charting.Styles; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.Properties; + +namespace Ringtoets.GrassCoverErosionInwards.Forms.Views +{ + /// + /// Factory for creating based on information used as input + /// in the grass cover erosion inwards failure mechanism. + /// + public static class GrassCoverErosionInwardsChartDataFactory + { + /// + /// Create with default styling based on the . + /// + /// The for which to create . + /// based on the . + /// Thrown when is null. + public static ChartData Create(DikeProfile dikeProfile) + { + if (dikeProfile == null) + { + throw new ArgumentNullException("dikeProfile"); + } + + return new ChartLineData(dikeProfile.DikeGeometry.Select(dg => dg.Point), Resources.DikeProfile_DisplayName) + { + Style = new ChartLineStyle(Color.SaddleBrown, 2, DashStyle.Solid) + }; + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsDikeProfileSelectionView.cs =================================================================== diff -u -r7d790a82bda0347f47961162de614bacfa8e288c -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsDikeProfileSelectionView.cs (.../GrassCoverErosionInwardsDikeProfileSelectionView.cs) (revision 7d790a82bda0347f47961162de614bacfa8e288c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsDikeProfileSelectionView.cs (.../GrassCoverErosionInwardsDikeProfileSelectionView.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -1,4 +1,25 @@ -using System; +// Copyright (C) Stichting Deltares 2016. 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 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Linq; using System.Windows.Forms; Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs =================================================================== diff -u -r18a53a9b2a6c09a3af46cb9c023de3f323639f30 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs (.../GrassCoverErosionInwardsInputView.cs) (revision 18a53a9b2a6c09a3af46cb9c023de3f323639f30) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsInputView.cs (.../GrassCoverErosionInwardsInputView.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -21,8 +21,11 @@ using System.Windows.Forms; using Core.Common.Base; +using Core.Components.Charting.Data; using Core.Components.Charting.Forms; +using Ringtoets.Common.Forms.Views; using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.Properties; namespace Ringtoets.GrassCoverErosionInwards.Forms.Views { @@ -31,8 +34,9 @@ /// public partial class GrassCoverErosionInwardsInputView : UserControl, IChartView, IObserver { - private object data; + private GrassCoverErosionInwardsInput data; private GrassCoverErosionInwardsCalculation calculation; + private ChartData dikeProfileData; /// /// Creates a new instance of . @@ -68,7 +72,19 @@ } set { - data = value as GrassCoverErosionInwardsInput; + var newValue = value as GrassCoverErosionInwardsInput; + + DetachFromData(); + data = newValue; + + if (data == null) + { + Chart.ResetChartData(); + return; + } + + SetDataToChart(); + AttachToData(); } } @@ -83,8 +99,46 @@ public void UpdateObserver() { SetChartTitle(); + SetDataToChart(); } + private void SetDataToChart() + { + chartControl.Data.Name = Resources.GrassCoverErosionInwardsInputContext_NodeDisplayName; + + if (data != null) + { + // Bottom most layer + dikeProfileData = AddOrUpdateChartData(dikeProfileData, GetDikeProfileData()); + // Top most layer + } + + chartControl.Data.NotifyObservers(); + } + + private ChartData GetDikeProfileData() + { + if (data == null || data.DikeProfile == null) + { + return ChartDataFactory.CreateEmptyLineData(Resources.DikeProfile_DisplayName); + } + return GrassCoverErosionInwardsChartDataFactory.Create(data.DikeProfile); + } + + private ChartData AddOrUpdateChartData(ChartData oldChartData, ChartData newChartData) + { + if (oldChartData != null) + { + chartControl.Data.Remove(oldChartData); + } + if (newChartData != null) + { + chartControl.Data.Add(newChartData); + } + + return newChartData; + } + private void SetChartTitle() { chartControl.ChartTitle = calculation != null ? calculation.Name : string.Empty; @@ -96,6 +150,11 @@ { calculation.Detach(this); } + + if (data != null) + { + data.Detach(this); + } } private void AttachToData() @@ -104,6 +163,11 @@ { calculation.Attach(this); } + + if (data != null) + { + data.Attach(this); + } } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs =================================================================== diff -u -rcc8aa3f8772a423761212afa95c6497aba211d6f -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision cc8aa3f8772a423761212afa95c6497aba211d6f) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -343,9 +343,7 @@ foreshoreGeometry.Clear(); foreshoreGeometry.AddRange(dikeProfileData.ForeshoreGeometry.Select(r => r.Point)); - List dikeGeometry = dikeProfile.DikeGeometry; - dikeGeometry.Clear(); - dikeGeometry.AddRange(dikeProfileData.DikeGeometry); + dikeProfile.SetGeometry(dikeProfileData.DikeGeometry); switch (dikeProfileData.DamType) { Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs =================================================================== diff -u -r5f0c498962317723017cf965a142e7cf4e67a915 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs (.../DikeProfileTest.cs) (revision 5f0c498962317723017cf965a142e7cf4e67a915) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/DikeProfileTest.cs (.../DikeProfileTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -23,6 +23,7 @@ using Core.Common.Base.Data; using Core.Common.Base.Geometry; using NUnit.Framework; +using Ringtoets.GrassCoverErosionInwards.Data.Properties; namespace Ringtoets.GrassCoverErosionInwards.Data.Test { @@ -220,5 +221,91 @@ // Assert Assert.AreEqual(testName, result); } + + [Test] + public void SetGeometry_GeometryIsNull_ThrowsArgumentNullException() + { + // Setup + var dikeProfile = new DikeProfile(new Point2D(0.0, 0.0)); + + // Call + TestDelegate test = () => dikeProfile.SetGeometry(null); + + // Assert + var exception = Assert.Throws(test); + StringAssert.StartsWith(Resources.DikeProfile_SetGeometry_Collection_of_points_for_geometry_is_null, exception.Message); + Assert.AreEqual("points", exception.ParamName); + } + + [Test] + public void SetGeometry_GeometryContainsNullPoint_ThrowsArgumentException() + { + // Setup + var dikeProfile = new DikeProfile(new Point2D(0.0, 0.0)); + + // Call + TestDelegate test = () => dikeProfile.SetGeometry(new RoughnessPoint[] + { + null + }); + + // Assert + var exception = Assert.Throws(test); + StringAssert.StartsWith(Resources.DikeProfile_SetGeometry_A_point_in_the_collection_was_null, exception.Message); + } + + [Test] + public void SetGeomtry_Collection_SetDikeGeometry() + { + var dikeProfile = new DikeProfile(new Point2D(0.0, 0.0)); + + var roughnessPoints = new[] + { + new RoughnessPoint(new Point2D(2.0, 3.0), 4.0), + new RoughnessPoint(new Point2D(3.0, 4.0), 4.0), + new RoughnessPoint(new Point2D(4.0, 5.0), 4.0) + }; + + // Call + dikeProfile.SetGeometry(roughnessPoints); + + // Assert + CollectionAssert.AreEqual(roughnessPoints, dikeProfile.DikeGeometry); + } + + [Test] + public void SetGeomtry_SetNewCollection_ClearsOldDikeGeometryAndSetNew() + { + var dikeProfile = new DikeProfile(new Point2D(0.0, 0.0)); + + var roughnessPoints = new[] + { + new RoughnessPoint(new Point2D(2.0, 3.0), 4.0), + new RoughnessPoint(new Point2D(3.0, 4.0), 4.0), + new RoughnessPoint(new Point2D(4.0, 5.0), 4.0) + }; + + dikeProfile.SetGeometry(roughnessPoints); + + // Precondition + CollectionAssert.AreEqual(roughnessPoints, dikeProfile.DikeGeometry); + + var roughnessPoints2 = new[] + { + new RoughnessPoint(new Point2D(8.0, 10.0), 1.0), + new RoughnessPoint(new Point2D(9.0, 11.0), 1.0), + new RoughnessPoint(new Point2D(10.0, 12.0), 2.0) + }; + + // Call + dikeProfile.SetGeometry(roughnessPoints2); + + // Assert + foreach (var originalPoint in roughnessPoints) + { + CollectionAssert.DoesNotContain(dikeProfile.DikeGeometry, originalPoint); + } + CollectionAssert.AreEqual(roughnessPoints2, dikeProfile.DikeGeometry); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs =================================================================== diff -u -r04d96e936610eab56e9ddc09c055526efe9b9652 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision 04d96e936610eab56e9ddc09c055526efe9b9652) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -78,12 +78,12 @@ var dikeProfile = new DikeProfile(new Point2D(0, 0)) { Orientation = (RoundedDouble) 1.1, - DikeGeometry = - { - new RoughnessPoint(new Point2D(2.2, 3.3), 0.6) - }, DikeHeight = (RoundedDouble) 4.4 }; + dikeProfile.SetGeometry(new[] + { + new RoughnessPoint(new Point2D(2.2, 3.3), 0.6) + }); if (withBreakWater) { @@ -138,12 +138,12 @@ { new Point2D(3.3, 4.4) }, - DikeGeometry = - { - new RoughnessPoint(new Point2D(5.5, 6.6), 0.7) - }, DikeHeight = (RoundedDouble) 8.8 }; + dikeProfile.SetGeometry(new[] + { + new RoughnessPoint(new Point2D(5.5, 6.6), 0.7) + }); input.DikeProfile = dikeProfile; Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/DikeProfileDikeGeometryPropertiesTest.cs =================================================================== diff -u -r7461afe37bcf85d746168f3fde0ca01947ec888e -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/DikeProfileDikeGeometryPropertiesTest.cs (.../DikeProfileDikeGeometryPropertiesTest.cs) (revision 7461afe37bcf85d746168f3fde0ca01947ec888e) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/DikeProfileDikeGeometryPropertiesTest.cs (.../DikeProfileDikeGeometryPropertiesTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -63,14 +63,13 @@ public void Data_SetDikeProfileInstanceWithData_ReturnCorrectPropertyValues() { // Setup - var dikeProfile = new DikeProfile(new Point2D(0, 0)) + var dikeProfile = new DikeProfile(new Point2D(0, 0)); + + dikeProfile.SetGeometry(new[] { - DikeGeometry = - { - new RoughnessPoint(new Point2D(0, 0), 0.6), - new RoughnessPoint(new Point2D(1, 1), 0.7) - } - }; + new RoughnessPoint(new Point2D(0, 0), 0.6), + new RoughnessPoint(new Point2D(1, 1), 0.7) + }); var properties = new DikeProfileDikeGeometryProperties(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextDikeGeometryPropertiesTest.cs =================================================================== diff -u -rc1125974b0bb4296b2826b6da186e7ce72729f64 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextDikeGeometryPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextDikeGeometryPropertiesTest.cs) (revision c1125974b0bb4296b2826b6da186e7ce72729f64) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextDikeGeometryPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextDikeGeometryPropertiesTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -84,20 +84,21 @@ mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var dikeProfile = new DikeProfile(new Point2D(0, 0)); + dikeProfile.SetGeometry(new[] + { + new RoughnessPoint(new Point2D(1.1, 2.2), 0.6), + new RoughnessPoint(new Point2D(3.3, 4.4), 0.7) + }); + var calculation = new GrassCoverErosionInwardsCalculation { InputParameters = { - DikeProfile = new DikeProfile(new Point2D(0, 0)) - { - DikeGeometry = - { - new RoughnessPoint(new Point2D(1.1, 2.2), 0.6), - new RoughnessPoint(new Point2D(3.3, 4.4), 0.7) - } - } + DikeProfile = dikeProfile } }; + var properties = new GrassCoverErosionInwardsInputContextDikeGeometryProperties(); // Call Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj =================================================================== diff -u -rb448e7f4c3bd3e36176bc4695d27ab8a1921bf57 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision b448e7f4c3bd3e36176bc4695d27ab8a1921bf57) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Forms.Test.csproj) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -95,6 +95,7 @@ + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsChartDataFactoryTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsChartDataFactoryTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsChartDataFactoryTest.cs (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -0,0 +1,93 @@ +// Copyright (C) Stichting Deltares 2016. 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 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 General Public License for more details. +// +// You should have received a copy of the GNU 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.Drawing.Drawing2D; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Components.Charting.Data; +using Core.Components.Charting.Styles; +using NUnit.Framework; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.Properties; +using Ringtoets.GrassCoverErosionInwards.Forms.Views; + +namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.Views +{ + [TestFixture] + public class GrassCoverErosionInwardsChartDataFactoryTest + { + [Test] + public void Create_DikeProfileNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => GrassCoverErosionInwardsChartDataFactory.Create(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("dikeProfile", exception.ParamName); + } + + [Test] + public void Create_GivenDikeProfile_ReturnsChartDataWithDefaultStyling() + { + // Setup + var dikeProfile = new DikeProfile(new Point2D(0.0, 0.0)); + dikeProfile.SetGeometry(CreateDikeProfileGeometry()); + + // Call + ChartData data = GrassCoverErosionInwardsChartDataFactory.Create(dikeProfile); + + // Assert + Assert.IsInstanceOf(data); + ChartLineData chartLineData = (ChartLineData)data; + Assert.AreEqual(3, chartLineData.Points.Count()); + Assert.AreEqual(Resources.DikeProfile_DisplayName, data.Name); + + AssertEqualPointCollections(dikeProfile.DikeGeometry.Select(dg => dg.Point), chartLineData.Points); + AssertEqualStyle(chartLineData.Style, Color.SaddleBrown, 2, DashStyle.Solid); + } + + private void AssertEqualPointCollections(IEnumerable points, IEnumerable chartPoints) + { + CollectionAssert.AreEqual(points, chartPoints); + } + + private void AssertEqualStyle(ChartLineStyle lineStyle, Color color, int width, DashStyle style) + { + Assert.AreEqual(color, lineStyle.Color); + Assert.AreEqual(width, lineStyle.Width); + Assert.AreEqual(style, lineStyle.Style); + } + + private List CreateDikeProfileGeometry() + { + return new List(new[] + { + new RoughnessPoint(new Point2D(2.0, 3.0), 4.0), + new RoughnessPoint(new Point2D(3.0, 4.0), 4.0), + new RoughnessPoint(new Point2D(4.0, 5.0), 4.0) + }); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsInputViewTest.cs =================================================================== diff -u -r18a53a9b2a6c09a3af46cb9c023de3f323639f30 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsInputViewTest.cs (.../GrassCoverErosionInwardsInputViewTest.cs) (revision 18a53a9b2a6c09a3af46cb9c023de3f323639f30) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsInputViewTest.cs (.../GrassCoverErosionInwardsInputViewTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -19,14 +19,18 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Base.Geometry; +using Core.Components.Charting.Data; using Core.Components.Charting.Forms; using Core.Components.OxyPlot.Forms; using NUnit.Framework; using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Forms.Properties; using Ringtoets.GrassCoverErosionInwards.Forms.Views; - using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.GrassCoverErosionInwards.Forms.Test.Views @@ -101,6 +105,32 @@ } [Test] + public void Data_SetToNull_ChartDataCleared() + { + // Setup + using (GrassCoverErosionInwardsInputView view = new GrassCoverErosionInwardsInputView()) + { + DikeProfile dikeProfile = GetDikeProfileWithGeometry(); + var input = new GrassCoverErosionInwardsInput + { + DikeProfile = dikeProfile + }; + + view.Data = input; + + // Precondition + Assert.AreEqual(1, view.Chart.Data.List.Count); + + // Call + view.Data = null; + + // Assert + Assert.IsNull(view.Data); + Assert.IsNull(view.Chart.Data); + } + } + + [Test] public void Calculation_Always_SetsCalculationAndUpdateChartTitle() { // Setup @@ -147,6 +177,59 @@ } [Test] + public void Data_SetChartData_ChartDataSet() + { + // Setup + using (GrassCoverErosionInwardsInputView view = new GrassCoverErosionInwardsInputView()) + { + var dikeProfile = new DikeProfile(new Point2D(0.0, 0.0)); + var input = new GrassCoverErosionInwardsInput + { + DikeProfile = dikeProfile + }; + + // Call + view.Data = input; + + // Assert + Assert.AreSame(input, view.Data); + Assert.IsInstanceOf(view.Chart.Data); + var chartData = view.Chart.Data; + Assert.IsNotNull(chartData); + Assert.AreEqual(Resources.GrassCoverErosionInwardsInputContext_NodeDisplayName, chartData.Name); + + Assert.AreEqual(1, chartData.List.Count); + AssertDikeProfileChartData(dikeProfile, chartData.List[dikeProfileIndex]); + } + } + + [Test] + public void Data_WithoutDikeProfile_CollectionOfEmptyDataSet() + { + // Setup + using (GrassCoverErosionInwardsInputView view = new GrassCoverErosionInwardsInputView()) + { + var input = new GrassCoverErosionInwardsInput(); + + // Call + view.Data = input; + + // Assert + Assert.AreSame(input, view.Data); + Assert.IsInstanceOf(view.Chart.Data); + var chartData = view.Chart.Data; + Assert.IsNotNull(chartData); + Assert.AreEqual(Resources.GrassCoverErosionInwardsInputContext_NodeDisplayName, chartData.Name); + + Assert.AreEqual(1, chartData.List.Count); + var dikeProfileData = (ChartLineData) chartData.List[dikeProfileIndex]; + + CollectionAssert.IsEmpty(dikeProfileData.Points); + Assert.AreEqual(Resources.DikeProfile_DisplayName, dikeProfileData.Name); + } + } + + [Test] public void UpdateObservers_CalculationNameUpdated_ChartTitleUpdated() { // Setup @@ -207,5 +290,199 @@ Assert.AreEqual(initialName, view.Chart.ChartTitle); } } + + [Test] + public void UpdateObservers_CalculationNotSet_ChartTitleSetToEmptyString() + { + // Setup + using (GrassCoverErosionInwardsInputView view = new GrassCoverErosionInwardsInputView()) + { + var input = new GrassCoverErosionInwardsInput(); + view.Data = input; + + // Precondition + Assert.IsNull(view.Chart.ChartTitle); + + // Call + input.NotifyObservers(); + + // Assert + Assert.AreEqual(string.Empty, view.Chart.ChartTitle); + } + } + + [Test] + public void UpdateObservers_CalculationUpdatedNotifyObserversOnOldData_NoUpdateInViewData() + { + // Setup + using (GrassCoverErosionInwardsInputView view = new GrassCoverErosionInwardsInputView()) + { + var initialName = "Initial name"; + var updatedName = "Updated name"; + + var calculation = new GrassCoverErosionInwardsCalculation + { + Name = initialName + }; + + view.Calculation = calculation; + + // Precondition + Assert.AreEqual(initialName, view.Chart.ChartTitle); + + var calculation2 = new GrassCoverErosionInwardsCalculation + { + Name = initialName + }; + + view.Calculation = calculation2; + + calculation.Name = updatedName; + + // Call + calculation.NotifyObservers(); + + // Assert + Assert.AreEqual(initialName, view.Chart.ChartTitle); + } + } + + [Test] + public void UpdateObservers_CalculationDikeProfileUpdated_SetNewChartData() + { + // Setup + using (GrassCoverErosionInwardsInputView view = new GrassCoverErosionInwardsInputView()) + { + DikeProfile dikeProfile = GetDikeProfileWithGeometry(); + + var input = new GrassCoverErosionInwardsInput + { + DikeProfile = dikeProfile + }; + + view.Data = input; + + ChartLineData oldDikeProfileChartData = (ChartLineData) view.Chart.Data.List[dikeProfileIndex]; + + DikeProfile dikeProfile2 = GetSecondDikeProfileWithGeometry(); + + input.DikeProfile = dikeProfile2; + + // Call + input.NotifyObservers(); + + // Assert + ChartLineData newDikeProfileChartData = (ChartLineData)view.Chart.Data.List[dikeProfileIndex]; + Assert.AreNotEqual(oldDikeProfileChartData, newDikeProfileChartData); + AssertDikeProfileChartData(dikeProfile2, newDikeProfileChartData); + } + } + + [Test] + public void UpdateObserver_OtherGrassCoverErosionInwardsInputUpdated_ChartDataNotUpdated() + { + // Setup + using (GrassCoverErosionInwardsInputView view = new GrassCoverErosionInwardsInputView()) + { + DikeProfile dikeProfile = GetDikeProfileWithGeometry(); + var input1 = new GrassCoverErosionInwardsInput + { + DikeProfile = dikeProfile + }; + + var input2 = new GrassCoverErosionInwardsInput + { + DikeProfile = dikeProfile + }; + + view.Data = input1; + + DikeProfile dikeProfile2 = GetSecondDikeProfileWithGeometry(); + + input2.DikeProfile = dikeProfile2; + + // Call + input2.NotifyObservers(); + + // Assert + Assert.AreEqual(input1, view.Data); + } + } + + [Test] + public void NotifyObservers_DataUpdatedNotifyObserversOnOldData_NoUpdateInViewData() + { + // Setup + using (GrassCoverErosionInwardsInputView view = new GrassCoverErosionInwardsInputView()) + { + DikeProfile dikeProfile = GetDikeProfileWithGeometry(); + var input1 = new GrassCoverErosionInwardsInput + { + DikeProfile = dikeProfile + }; + + var input2 = new GrassCoverErosionInwardsInput(); + + view.Data = input1; + ChartData dataBeforeUpdate = view.Chart.Data; + + view.Data = input2; + + DikeProfile dikeProfile2 = GetSecondDikeProfileWithGeometry(); + + input1.DikeProfile = dikeProfile2; + + // Call + input1.NotifyObservers(); + + // Assert + Assert.AreEqual(dataBeforeUpdate, view.Chart.Data); + } + } + + private const int dikeProfileIndex = 0; + + private DikeProfile GetDikeProfileWithGeometry() + { + var points = new List(new[] + { + new RoughnessPoint(new Point2D(2.0, 3.0), 4.0), + new RoughnessPoint(new Point2D(3.0, 4.0), 4.0), + new RoughnessPoint(new Point2D(4.0, 5.0), 4.0) + }); + + return GetDikeProfile(points); + } + + private DikeProfile GetSecondDikeProfileWithGeometry() + { + var points = new List(new[] + { + new RoughnessPoint(new Point2D(8.0, 3.0), 1.0), + new RoughnessPoint(new Point2D(10.0, 4.0), 1.0), + new RoughnessPoint(new Point2D(12.0, 5.0), 1.0) + }); + + return GetDikeProfile(points); + } + + private DikeProfile GetDikeProfile(List points) + { + DikeProfile dikeProfile = new DikeProfile(new Point2D(0.0, 0.0)); + dikeProfile.SetGeometry(points); + + return dikeProfile; + } + + private void AssertDikeProfileChartData(DikeProfile dikeProfile, ChartData chartData) + { + Assert.IsInstanceOf(chartData); + ChartLineData dikeProfileChartData = (ChartLineData)chartData; + + RoughnessPoint[] dikeGeometry = dikeProfile.DikeGeometry; + Assert.AreEqual(dikeGeometry.Length, dikeProfileChartData.Points.Count()); + CollectionAssert.AreEqual(dikeGeometry.Select(dg => dg.Point), dikeProfileChartData.Points); + Assert.AreEqual(Resources.DikeProfile_DisplayName, chartData.Name); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs =================================================================== diff -u -r0f7eb2998561112d0013b667ee39c2316341d2fe -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 0f7eb2998561112d0013b667ee39c2316341d2fe) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -348,22 +348,25 @@ private static DikeProfile CreateDikeProfile() { - return new DikeProfile(new Point2D(0, 0)) + DikeProfile dikeProfile = new DikeProfile(new Point2D(0, 0)) { Orientation = (RoundedDouble) 5.5, BreakWater = new BreakWater(BreakWaterType.Dam, 10.0), - DikeGeometry = - { - new RoughnessPoint(new Point2D(1.1, 2.2), 0.6), - new RoughnessPoint(new Point2D(3.3, 4.4), 0.7) - }, ForeshoreGeometry = { new Point2D(3.3, 4.4), new Point2D(5.5, 6.6) }, DikeHeight = (RoundedDouble) 10 }; + + dikeProfile.SetGeometry(new[] + { + new RoughnessPoint(new Point2D(1.1, 2.2), 0.6), + new RoughnessPoint(new Point2D(3.3, 4.4), 0.7) + }); + + return dikeProfile; } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs =================================================================== diff -u -r0f7eb2998561112d0013b667ee39c2316341d2fe -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs) (revision 0f7eb2998561112d0013b667ee39c2316341d2fe) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -197,21 +197,23 @@ new Point2D(1, 1) })); + DikeProfile dikeProfile = new DikeProfile(new Point2D(0, 0)) + { + Orientation = (RoundedDouble) 5.5, + DikeHeight = (RoundedDouble) 10 + }; + dikeProfile.SetGeometry(new[] + { + new RoughnessPoint(new Point2D(1.1, 2.2), 0.6), + new RoughnessPoint(new Point2D(3.3, 4.4), 0.7) + }); + var calculation = new GrassCoverErosionInwardsCalculation { InputParameters = { HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), - DikeProfile = new DikeProfile(new Point2D(0, 0)) - { - Orientation = (RoundedDouble) 5.5, - DikeGeometry = - { - new RoughnessPoint(new Point2D(1.1, 2.2), 0.6), - new RoughnessPoint(new Point2D(3.3, 4.4), 0.7) - }, - DikeHeight = (RoundedDouble) 10 - } + DikeProfile = dikeProfile } }; Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs =================================================================== diff -u -r82fb4773cc572bc0d49662a54b5c6ca043a10e9b -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs (.../PipingChartDataFactory.cs) (revision 82fb4773cc572bc0d49662a54b5c6ca043a10e9b) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingChartDataFactory.cs (.../PipingChartDataFactory.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -27,6 +27,7 @@ using Core.Common.Base.Geometry; using Core.Components.Charting.Data; using Core.Components.Charting.Styles; +using Ringtoets.Common.Forms.Views; using Ringtoets.Piping.Forms.Properties; using Ringtoets.Piping.Primitives; using PipingDataResources = Ringtoets.Piping.Data.Properties.Resources; @@ -39,26 +40,6 @@ public static class PipingChartDataFactory { /// - /// Create a instance with a name, but without data. - /// - /// The name of the . - /// An empty object. - public static ChartLineData CreateEmptyLineData(string name) - { - return new ChartLineData(Enumerable.Empty(), name); - } - - /// - /// Create a instance with a name, but without data. - /// - /// The name of the . - /// An empty object. - public static ChartPointData CreateEmptyPointData(string name) - { - return new ChartPointData(Enumerable.Empty(), name); - } - - /// /// Create with default styling based on the . /// /// The for which to create . @@ -252,7 +233,7 @@ catch (ArgumentOutOfRangeException) { // TODO Should not have to handle when WTI-673 and WTI-396 are done. - pointWithZatLData = CreateEmptyPointData(name); + pointWithZatLData = ChartDataFactory.CreateEmptyPointData(name); } return pointWithZatLData; Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs =================================================================== diff -u -rf04895089d34bddb618db8c7001c574428be10c6 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision f04895089d34bddb618db8c7001c574428be10c6) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingInputView.cs (.../PipingInputView.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -23,6 +23,7 @@ using Core.Common.Base; using Core.Components.Charting.Data; using Core.Components.Charting.Forms; +using Ringtoets.Common.Forms.Views; using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms.Properties; @@ -143,7 +144,7 @@ { if (data == null || data.SurfaceLine == null) { - return PipingChartDataFactory.CreateEmptyLineData(Resources.RingtoetsPipingSurfaceLine_DisplayName); + return ChartDataFactory.CreateEmptyLineData(Resources.RingtoetsPipingSurfaceLine_DisplayName); } return PipingChartDataFactory.Create(data.SurfaceLine); } @@ -152,7 +153,7 @@ { if (data == null || data.SurfaceLine == null) { - return PipingChartDataFactory.CreateEmptyPointData(Resources.PipingInput_EntryPointL_DisplayName); + return ChartDataFactory.CreateEmptyPointData(Resources.PipingInput_EntryPointL_DisplayName); } return PipingChartDataFactory.CreateEntryPoint(data.EntryPointL, data.SurfaceLine); } @@ -161,7 +162,7 @@ { if (data == null || data.SurfaceLine == null) { - return PipingChartDataFactory.CreateEmptyPointData(Resources.PipingInput_ExitPointL_DisplayName); + return ChartDataFactory.CreateEmptyPointData(Resources.PipingInput_ExitPointL_DisplayName); } return PipingChartDataFactory.CreateExitPoint(data.ExitPointL, data.SurfaceLine); } @@ -170,7 +171,7 @@ { if (data == null || data.SurfaceLine == null || data.SurfaceLine.DitchPolderSide == null) { - return PipingChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_DitchPolderSide); + return ChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_DitchPolderSide); } return PipingChartDataFactory.CreateDitchPolderSide(data.SurfaceLine); } @@ -179,7 +180,7 @@ { if (data == null || data.SurfaceLine == null || data.SurfaceLine.BottomDitchPolderSide == null) { - return PipingChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_BottomDitchPolderSide); + return ChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_BottomDitchPolderSide); } return PipingChartDataFactory.CreateBottomDitchPolderSide(data.SurfaceLine); } @@ -188,7 +189,7 @@ { if (data == null || data.SurfaceLine == null || data.SurfaceLine.BottomDitchDikeSide == null) { - return PipingChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_BottomDitchDikeSide); + return ChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_BottomDitchDikeSide); } return PipingChartDataFactory.CreateBottomDitchDikeSide(data.SurfaceLine); } @@ -197,7 +198,7 @@ { if (data == null || data.SurfaceLine == null || data.SurfaceLine.DitchDikeSide == null) { - return PipingChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_DitchDikeSide); + return ChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_DitchDikeSide); } return PipingChartDataFactory.CreateDitchDikeSide(data.SurfaceLine); } @@ -206,7 +207,7 @@ { if (data == null || data.SurfaceLine == null || data.SurfaceLine.DikeToeAtRiver == null) { - return PipingChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_DikeToeAtRiver); + return ChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_DikeToeAtRiver); } return PipingChartDataFactory.CreateDikeToeAtRiver(data.SurfaceLine); } @@ -215,7 +216,7 @@ { if (data == null || data.SurfaceLine == null || data.SurfaceLine.DikeToeAtPolder == null) { - return PipingChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_DikeToeAtPolder); + return ChartDataFactory.CreateEmptyPointData(PipingDataResources.CharacteristicPoint_DikeToeAtPolder); } return PipingChartDataFactory.CreateDikeToeAtPolder(data.SurfaceLine); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs =================================================================== diff -u -r516f10118109eb4056794904fa280b9df0c7ca1f -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 516f10118109eb4056794904fa280b9df0c7ca1f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -114,6 +114,7 @@ /// Sets the geometry of the surfaceline. /// /// The collection of points defining the surfaceline geometry. + /// Thrown when is null. /// Thrown when any element of is null. public void SetGeometry(IEnumerable points) { Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs =================================================================== diff -u -rdc6c85db19b5d77aec1c4db3fd4ef43a71fdd712 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs (.../PipingChartDataFactoryTest.cs) (revision dc6c85db19b5d77aec1c4db3fd4ef43a71fdd712) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingChartDataFactoryTest.cs (.../PipingChartDataFactoryTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -41,34 +41,6 @@ public class PipingChartDataFactoryTest { [Test] - public void CreateEmptyLineData_Always_ReturnEmptyChartLineDataWithNameSet() - { - // Setup - const string name = ""; - - // Call - ChartLineData chartData = PipingChartDataFactory.CreateEmptyLineData(name); - - // Assert - Assert.AreEqual(name, chartData.Name); - Assert.IsEmpty(chartData.Points); - } - - [Test] - public void CreateEmptyPointData_Always_ReturnEmptyChartPointDataWithNameSet() - { - // Setup - const string name = ""; - - // Call - ChartPointData chartData = PipingChartDataFactory.CreateEmptyPointData(name); - - // Assert - Assert.AreEqual(name, chartData.Name); - Assert.IsEmpty(chartData.Points); - } - - [Test] public void Create_NoSurfaceLine_ThrowsArgumentNullException() { // Call @@ -541,7 +513,7 @@ private void AssertEqualPointCollections(IEnumerable points, IEnumerable chartPoints) { - CollectionAssert.AreEqual(points.Select(p => new Point2D(p.X, p.Y)), chartPoints); + CollectionAssert.AreEqual(points, chartPoints); } private void AssertEqualLocalPointCollection(Point3D point, RingtoetsPipingSurfaceLine surfaceLine, IEnumerable chartPoints) Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs =================================================================== diff -u -r462a9f89d625ca85e6ce2e2ff628db3d83913b99 -r411b50528bbd83c02ffdcae699895529b2b34bf7 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision 462a9f89d625ca85e6ce2e2ff628db3d83913b99) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingInputViewTest.cs (.../PipingInputViewTest.cs) (revision 411b50528bbd83c02ffdcae699895529b2b34bf7) @@ -244,15 +244,15 @@ var dikeToeAtPolderData = (ChartPointData) chartData.List[dikeToeAtPolderIndex]; var dikeToeAtRiverData = (ChartPointData) chartData.List[dikeToeAtRiverIndex]; - Assert.AreEqual(0, lineData.Points.Count()); - Assert.AreEqual(0, entryPointData.Points.Count()); - Assert.AreEqual(0, exitPointData.Points.Count()); - Assert.AreEqual(0, ditchDikeSideData.Points.Count()); - Assert.AreEqual(0, bottomDitchDikeSideData.Points.Count()); - Assert.AreEqual(0, ditchPolderSideData.Points.Count()); - Assert.AreEqual(0, bottomDitchPolderSideData.Points.Count()); - Assert.AreEqual(0, dikeToeAtPolderData.Points.Count()); - Assert.AreEqual(0, dikeToeAtRiverData.Points.Count()); + CollectionAssert.IsEmpty(lineData.Points); + CollectionAssert.IsEmpty(entryPointData.Points); + CollectionAssert.IsEmpty(exitPointData.Points); + CollectionAssert.IsEmpty(ditchDikeSideData.Points); + CollectionAssert.IsEmpty(bottomDitchDikeSideData.Points); + CollectionAssert.IsEmpty(ditchPolderSideData.Points); + CollectionAssert.IsEmpty(bottomDitchPolderSideData.Points); + CollectionAssert.IsEmpty(dikeToeAtPolderData.Points); + CollectionAssert.IsEmpty(dikeToeAtRiverData.Points); Assert.AreEqual(Resources.RingtoetsPipingSurfaceLine_DisplayName, lineData.Name); Assert.AreEqual(Resources.PipingInput_EntryPointL_DisplayName, entryPointData.Name); Assert.AreEqual(Resources.PipingInput_ExitPointL_DisplayName, exitPointData.Name);