Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj =================================================================== diff -u -rad336f3e677b270df42fe7754c1cc5a68c76f287 -r86c456355aa32d442be661be2a6de1a2d2ae63e0 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision ad336f3e677b270df42fe7754c1cc5a68c76f287) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 86c456355aa32d442be661be2a6de1a2d2ae63e0) @@ -112,7 +112,6 @@ - @@ -155,14 +154,6 @@ {E02482C7-F12B-42F0-BB2B-C7EC17503A72} Core.Components.BruTile - - {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 @@ -295,22 +286,6 @@ {955E574D-67CE-4347-AA6B-7DF8A04ED754} Ringtoets.Piping.Data.TestUtil - - {87c2c553-c0bc-40bf-b1ea-b83bff357f27} - Ringtoets.Revetment.Data - - - {AF1ACFA2-AEE5-4DB7-98CA-8B3720E46AD9} - Ringtoets.Revetment.Forms - - - {3706200E-48C6-4B86-B48C-4E45C69ABE95} - Ringtoets.Revetment.Data.TestUtil - - - {DF0BED5E-1BB0-469F-A15C-ACBF6767C193} - Ringtoets.Revetment.Forms.TestUtil - {3d4b9740-8348-4434-8d77-b611fc6ee57f} Ringtoets.StabilityPointStructures.Data Fisheye: Tag 86c456355aa32d442be661be2a6de1a2d2ae63e0 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveConditionsInputViewInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test.csproj =================================================================== diff -u -rad336f3e677b270df42fe7754c1cc5a68c76f287 -r86c456355aa32d442be661be2a6de1a2d2ae63e0 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.Plugin.Test.csproj) (revision ad336f3e677b270df42fe7754c1cc5a68c76f287) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test.csproj (.../Ringtoets.WaveImpactAsphaltCover.Plugin.Test.csproj) (revision 86c456355aa32d442be661be2a6de1a2d2ae63e0) @@ -39,6 +39,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/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs =================================================================== diff -u --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs (revision 0) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Plugin.Test/ViewInfos/WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest.cs (revision 86c456355aa32d442be661be2a6de1a2d2ae63e0) @@ -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.WaveImpactAsphaltCover.Data; +using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Ringtoets.WaveImpactAsphaltCover.Forms.Views; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.WaveImpactAsphaltCover.Plugin.Test.ViewInfos +{ + [TestFixture] + public class WaveImpactAsphaltCoverWaveConditionsInputViewInfoTest : 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 WaveImpactAsphaltCoverPlugin plugin; + + [SetUp] + public void SetUp() + { + plugin = new WaveImpactAsphaltCoverPlugin(); + 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(WaveImpactAsphaltCoverWaveConditionsInputContext), 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 WaveImpactAsphaltCoverWaveConditionsCalculation(); + var context = new WaveImpactAsphaltCoverWaveConditionsInputContext(calculation.InputParameters, + calculation, + new AssessmentSectionStub(), + new ForeshoreProfile[0]); + + // Call + object viewData = info.GetViewData(context); + + // Assert + Assert.AreSame(calculation, viewData); + } + + [Test] + public void CreateInstance_WaveImpactAsphaltCoverWaveConditionsInputContext_ReturnViewWithStylingApplied() + { + // Setup + var context = new WaveImpactAsphaltCoverWaveConditionsInputContext( + new AssessmentSectionCategoryWaveConditionsInput(), + new WaveImpactAsphaltCoverWaveConditionsCalculation(), + 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_WaveImpactAsphaltCoverWaveConditionsInputContext_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 WaveImpactAsphaltCoverWaveConditionsInputContext( + new AssessmentSectionCategoryWaveConditionsInput + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation + }, + new WaveImpactAsphaltCoverWaveConditionsCalculation + { + 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 WaveImpactAsphaltCoverWaveConditionsInputViewStyle(), + () => (RoundedDouble) 1.1) + { + Data = data + }; + } + + protected override ICalculation GetCalculation() + { + return new WaveImpactAsphaltCoverWaveConditionsCalculation(); + } + + protected override ICalculationContext GetCalculationContextWithCalculation() + { + return new WaveImpactAsphaltCoverWaveConditionsCalculationContext( + new WaveImpactAsphaltCoverWaveConditionsCalculation(), + new CalculationGroup(), + new WaveImpactAsphaltCoverFailureMechanism(), + new AssessmentSectionStub()); + } + + protected override ICalculationContext GetCalculationGroupContextWithCalculation() + { + return new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext( + new CalculationGroup + { + Children = + { + new WaveImpactAsphaltCoverWaveConditionsCalculation() + } + }, + null, + new WaveImpactAsphaltCoverFailureMechanism(), + new AssessmentSectionStub()); + } + + protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() + { + return new WaveImpactAsphaltCoverFailureMechanismContext( + new WaveImpactAsphaltCoverFailureMechanism + { + WaveConditionsCalculationGroup = + { + Children = + { + new WaveImpactAsphaltCoverWaveConditionsCalculation() + } + } + }, new AssessmentSectionStub()); + } + + #endregion + } +} \ No newline at end of file