Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/Ringtoets.StabilityStoneCover.Plugin.Test.csproj
===================================================================
diff -u -rad336f3e677b270df42fe7754c1cc5a68c76f287 -r12eb4df5de341fb318093517a33d805caef22b1a
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/Ringtoets.StabilityStoneCover.Plugin.Test.csproj (.../Ringtoets.StabilityStoneCover.Plugin.Test.csproj) (revision ad336f3e677b270df42fe7754c1cc5a68c76f287)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/Ringtoets.StabilityStoneCover.Plugin.Test.csproj (.../Ringtoets.StabilityStoneCover.Plugin.Test.csproj) (revision 12eb4df5de341fb318093517a33d805caef22b1a)
@@ -43,6 +43,7 @@
+
@@ -79,6 +80,14 @@
{d749ee4c-ce50-4c17-bf01-9a953028c126}
Core.Common.TestUtil
+
+ {2465CCA1-C505-4827-9454-4FD5FD9194CD}
+ Core.Components.Chart.Forms
+
+
+ {516EBC95-B8F2-428C-B7F6-733F01BF8FDD}
+ Core.Components.Chart
+
{4a06df0d-5d75-4bad-a95a-a3db9b7c4ad5}
Core.Components.Gis.Forms
@@ -95,6 +104,10 @@
{4843D6E5-066F-4795-94F5-1D53932DD03C}
Ringtoets.Common.Data.TestUtil
+
+ {6346BADF-D331-4948-9772-08E8CD1E1FC9}
+ Ringtoets.Common.Plugin.TestUtil
+
{52093DA6-D545-476A-ADFD-12F56625E36B}
Ringtoets.Common.Service.TestUtil
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs
===================================================================
diff -u
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs (revision 0)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/ViewInfos/StabilityStoneCoverWaveConditionsInputViewInfoTest.cs (revision 12eb4df5de341fb318093517a33d805caef22b1a)
@@ -0,0 +1,240 @@
+// 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 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.Drawing;
+using System.Linq;
+using Core.Common.Base.Data;
+using Core.Common.Controls.Views;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using Core.Components.Chart.Data;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.Common.Plugin.TestUtil;
+using Ringtoets.Revetment.Data;
+using Ringtoets.Revetment.Forms.Views;
+using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.StabilityStoneCover.Forms.PresentationObjects;
+using Ringtoets.StabilityStoneCover.Forms.Views;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.StabilityStoneCover.Plugin.Test.ViewInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverWaveConditionsInputViewInfoTest : ShouldCloseViewWithCalculationDataTester
+ {
+ private const int lowerBoundaryRevetmentChartDataIndex = 1;
+ private const int upperBoundaryRevetmentChartDataIndex = 2;
+ private const int designWaterLevelChartDataIndex = 5;
+ private const int revetmentBaseChartDataIndex = 7;
+ private const int revetmentChartDataIndex = 8;
+
+ private ViewInfo info;
+ private StabilityStoneCoverPlugin plugin;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new StabilityStoneCoverPlugin();
+ info = plugin.GetViewInfos().First(tni => tni.ViewType == typeof(WaveConditionsInputView));
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ plugin.Dispose();
+ }
+
+ [Test]
+ public void Initialized_Always_ExpectedPropertiesSet()
+ {
+ // Assert
+ Assert.AreEqual(typeof(StabilityStoneCoverWaveConditionsInputContext), info.DataType);
+ Assert.AreEqual(typeof(ICalculation), info.ViewDataType);
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, info.Image);
+ }
+
+ [Test]
+ public void GetViewName_Always_ReturnsInputResourceName()
+ {
+ // Call
+ string viewName = info.GetViewName(null, null);
+
+ // Assert
+ Assert.AreEqual("Invoer", viewName);
+ }
+
+ [Test]
+ public void GetViewData_Always_ReturnsWrappedCalculation()
+ {
+ // Setup
+ var calculation = new StabilityStoneCoverWaveConditionsCalculation();
+ var context = new StabilityStoneCoverWaveConditionsInputContext(calculation.InputParameters,
+ calculation,
+ new AssessmentSectionStub(),
+ new ForeshoreProfile[0]);
+
+ // Call
+ object viewData = info.GetViewData(context);
+
+ // Assert
+ Assert.AreSame(calculation, viewData);
+ }
+
+ [Test]
+ public void CreateInstance_StabilityStoneCoverWaveConditionsInputContext_ReturnViewWithStylingApplied()
+ {
+ // Setup
+ var context = new StabilityStoneCoverWaveConditionsInputContext(
+ new AssessmentSectionCategoryWaveConditionsInput(),
+ new StabilityStoneCoverWaveConditionsCalculation(),
+ new AssessmentSectionStub(),
+ new ForeshoreProfile[0]);
+
+ // Call
+ var view = (WaveConditionsInputView) info.CreateInstance(context);
+ view.Data = context.Calculation;
+
+ // Assert
+ ChartDataCollection chartData = view.Chart.Data;
+
+ var lowerBoundaryRevetmentChartData = (ChartLineData) chartData.Collection.ElementAt(lowerBoundaryRevetmentChartDataIndex);
+ var upperBoundaryRevetmentChartData = (ChartLineData) chartData.Collection.ElementAt(upperBoundaryRevetmentChartDataIndex);
+ var designWaterLevelChartData = (ChartLineData) chartData.Collection.ElementAt(designWaterLevelChartDataIndex);
+ var revetmentBaseChartData = (ChartLineData) chartData.Collection.ElementAt(revetmentBaseChartDataIndex);
+ var revetmentChartData = (ChartLineData) chartData.Collection.ElementAt(revetmentChartDataIndex);
+
+ Color revetmentLineColor = Color.Gray;
+ Assert.AreEqual(revetmentLineColor, lowerBoundaryRevetmentChartData.Style.Color);
+ Assert.AreEqual(revetmentLineColor, upperBoundaryRevetmentChartData.Style.Color);
+ Assert.AreEqual("Toetspeil", designWaterLevelChartData.Name);
+ Assert.AreEqual(Color.FromArgb(120, revetmentLineColor), revetmentBaseChartData.Style.Color);
+ Assert.AreEqual(revetmentLineColor, revetmentChartData.Style.Color);
+ }
+
+ [Test]
+ public void CreateInstance_StabilityStoneCoverWaveConditionsInputContext_ReturnViewWithCorrespondingAssessmentLevel()
+ {
+ // Setup
+ const double assessmentLevel = 2.2;
+
+ var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
+
+ var assessmentSection = new AssessmentSectionStub();
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
+ {
+ hydraulicBoundaryLocation
+ });
+
+ assessmentSection.WaterLevelCalculationsForLowerLimitNorm.First().Output = new TestHydraulicBoundaryLocationCalculationOutput(assessmentLevel);
+
+ var context = new StabilityStoneCoverWaveConditionsInputContext(
+ new AssessmentSectionCategoryWaveConditionsInput
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation
+ },
+ new StabilityStoneCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation
+ }
+ },
+ assessmentSection,
+ new ForeshoreProfile[0]);
+
+ // Call
+ var view = (WaveConditionsInputView) info.CreateInstance(context);
+ view.Data = context.Calculation;
+
+ // Assert
+ ChartDataCollection chartData = view.Chart.Data;
+ var designWaterLevelChartData = (ChartLineData) chartData.Collection.ElementAt(designWaterLevelChartDataIndex);
+ Assert.AreEqual(assessmentLevel, designWaterLevelChartData.Points.First().Y);
+ }
+
+ #region ShouldCloseViewWithCalculationDataTester
+
+ protected override bool ShouldCloseMethod(IView view, object o)
+ {
+ return info.CloseForData(view, o);
+ }
+
+ protected override IView GetView(ICalculation data)
+ {
+ return new WaveConditionsInputView(new StabilityStoneCoverWaveConditionsInputViewStyle(),
+ () => (RoundedDouble) 1.1)
+ {
+ Data = data
+ };
+ }
+
+ protected override ICalculation GetCalculation()
+ {
+ return new StabilityStoneCoverWaveConditionsCalculation();
+ }
+
+ protected override ICalculationContext GetCalculationContextWithCalculation()
+ {
+ return new StabilityStoneCoverWaveConditionsCalculationContext(
+ new StabilityStoneCoverWaveConditionsCalculation(),
+ new CalculationGroup(),
+ new StabilityStoneCoverFailureMechanism(),
+ new AssessmentSectionStub());
+ }
+
+ protected override ICalculationContext GetCalculationGroupContextWithCalculation()
+ {
+ return new StabilityStoneCoverWaveConditionsCalculationGroupContext(
+ new CalculationGroup
+ {
+ Children =
+ {
+ new StabilityStoneCoverWaveConditionsCalculation()
+ }
+ },
+ null,
+ new StabilityStoneCoverFailureMechanism(),
+ new AssessmentSectionStub());
+ }
+
+ protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation()
+ {
+ return new StabilityStoneCoverFailureMechanismContext(
+ new StabilityStoneCoverFailureMechanism
+ {
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ new StabilityStoneCoverWaveConditionsCalculation()
+ }
+ }
+ }, new AssessmentSectionStub());
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file