Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj
===================================================================
diff -u -rec15ff35b39f333c422b8ca6988c34bd8573f134 -r16ffb4842cab4a8c457638eef546fd87bea3f0f6
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision ec15ff35b39f333c422b8ca6988c34bd8573f134)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision 16ffb4842cab4a8c457638eef546fd87bea3f0f6)
@@ -94,6 +94,11 @@
Core.Common.Utils
False
+
+ {2465cca1-c505-4827-9454-4fd5fd9194cd}
+ Core.Components.Charting.Forms
+ False
+
{4a06df0d-5d75-4bad-a95a-a3db9b7c4ad5}
Core.Components.Gis.Forms
@@ -133,6 +138,11 @@
Ringtoets.DuneErosion.Plugin
False
+
+ {87C2C553-C0BC-40BF-B1EA-B83BFF357F27}
+ Ringtoets.Revetment.Data
+ False
+
{AF1ACFA2-AEE5-4DB7-98CA-8B3720E46AD9}
Ringtoets.Revetment.Forms
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -rec15ff35b39f333c422b8ca6988c34bd8573f134 -r16ffb4842cab4a8c457638eef546fd87bea3f0f6
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision ec15ff35b39f333c422b8ca6988c34bd8573f134)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 16ffb4842cab4a8c457638eef546fd87bea3f0f6)
@@ -83,7 +83,9 @@
using Ringtoets.Integration.Service.MessageProviders;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.Forms.PresentationObjects;
+using Ringtoets.Revetment.Data;
using Ringtoets.Revetment.Forms.PresentationObjects;
+using Ringtoets.Revetment.Forms.Views;
using Ringtoets.StabilityPointStructures.Data;
using Ringtoets.StabilityPointStructures.Forms.PresentationObjects;
using Ringtoets.StabilityStoneCover.Data;
@@ -398,6 +400,14 @@
Image = RingtoetsCommonFormsResources.EditDocumentIcon,
CloseForData = CloseCommentViewForData
};
+
+ yield return new ViewInfo
+ {
+ Image = RingtoetsCommonFormsResources.GenericInputOutputIcon,
+ GetViewName = (view, context) => RingtoetsCommonFormsResources.Calculation_Input,
+ GetViewData = context => context.Calculation,
+ CloseForData = CloseWaveConditionsInputViewForData
+ };
}
public override IEnumerable GetImportInfos()
@@ -770,6 +780,30 @@
}
}
+ private class FailureMechanismContextAssociation
+ {
+ private readonly Func createFailureMechanismContext;
+ private readonly Type failureMechanismType;
+
+ public FailureMechanismContextAssociation(Type failureMechanismType, Func createFailureMechanismContext)
+ {
+ this.createFailureMechanismContext = createFailureMechanismContext;
+ this.failureMechanismType = failureMechanismType;
+ }
+
+ public bool Match(IFailureMechanism failureMechanism)
+ {
+ return failureMechanism.GetType() == failureMechanismType;
+ }
+
+ public object Create(IFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ {
+ return createFailureMechanismContext(failureMechanism, assessmentSection);
+ }
+ }
+
+ #region ViewInfos
+
#region FailureMechanismView ViewInfo
private static bool CloseFailureMechanismViewForData(FailureMechanismView view, object o)
@@ -851,39 +885,204 @@
#endregion
- #region FailureMechanismSectionsContext TreeNodeInfo
+ #region Comment ViewInfo
- private ContextMenuStrip FailureMechanismSectionsContextMenuStrip(FailureMechanismSectionsContext nodeData, object parentData, TreeViewControl treeViewControl)
+ private static bool CloseCommentViewForData(CommentView commentView, object o)
{
- return Gui.Get(nodeData, treeViewControl)
- .AddImportItem()
- .Build();
+ var calculationGroupContext = o as ICalculationContext;
+ if (calculationGroupContext != null)
+ {
+ return GetCommentElements(calculationGroupContext.WrappedData)
+ .Any(commentElement => ReferenceEquals(commentView.Data, commentElement));
+ }
+
+ var calculationContext = o as ICalculationContext;
+ var calculation = calculationContext?.WrappedData as ICalculation;
+ if (calculation != null)
+ {
+ return ReferenceEquals(commentView.Data, calculation.Comments);
+ }
+
+ var failureMechanism = o as IFailureMechanism;
+
+ var failureMechanismContext = o as IFailureMechanismContext;
+ if (failureMechanismContext != null)
+ {
+ failureMechanism = failureMechanismContext.WrappedData;
+ }
+
+ if (failureMechanism != null)
+ {
+ return GetCommentElements(failureMechanism)
+ .Any(commentElement => ReferenceEquals(commentView.Data, commentElement));
+ }
+
+ var assessmentSection = o as IAssessmentSection;
+ if (assessmentSection != null)
+ {
+ return GetCommentElements(assessmentSection)
+ .Any(commentElement => ReferenceEquals(commentView.Data, commentElement));
+ }
+
+ return false;
}
+ private static IEnumerable GetCommentElements(CalculationGroup calculationGroup)
+ {
+ return calculationGroup.GetCalculations().Select(c => c.Comments);
+ }
+
+ private static IEnumerable GetCommentElements(IAssessmentSection assessmentSection)
+ {
+ yield return assessmentSection.Comments;
+ foreach (Comment comment in assessmentSection.GetFailureMechanisms().SelectMany(GetCommentElements))
+ {
+ yield return comment;
+ }
+ }
+
+ private static IEnumerable GetCommentElements(IFailureMechanism failureMechanism)
+ {
+ yield return failureMechanism.InputComments;
+ yield return failureMechanism.OutputComments;
+ yield return failureMechanism.NotRelevantComments;
+ foreach (ICalculation calculation in failureMechanism.Calculations)
+ {
+ yield return calculation.Comments;
+ }
+ }
+
#endregion
- private class FailureMechanismContextAssociation
+ #region WaveConditionsInputViewInfo
+
+ private static bool CloseWaveConditionsInputViewForData(WaveConditionsInputView view, object o)
{
- private readonly Func createFailureMechanismContext;
- private readonly Type failureMechanismType;
+ var context = o as WaveConditionsInputContext;
+ if (context != null)
+ {
+ return ReferenceEquals(view.Data, context.Calculation);
+ }
+ var calculation = o as IWaveConditionsCalculation;
+ if (calculation != null)
+ {
+ return ReferenceEquals(view.Data, calculation);
+ }
- public FailureMechanismContextAssociation(Type failureMechanismType, Func createFailureMechanismContext)
+ IEnumerable calculations = GetCalculationsFromCalculationGroupContexts(o);
+
+ IEnumerable failureMechanismCalculations = GetCalculationsFromFailureMechanisms(o);
+ if (failureMechanismCalculations != null)
{
- this.createFailureMechanismContext = createFailureMechanismContext;
- this.failureMechanismType = failureMechanismType;
+ calculations = failureMechanismCalculations;
}
- public bool Match(IFailureMechanism failureMechanism)
+ return calculations != null && calculations.Any(c => ReferenceEquals(view.Data, c));
+ }
+
+ private static IEnumerable GetCalculationsFromFailureMechanisms(object o)
+ {
+ IEnumerable grassCoverErosionOutwardsCalculations = GetCalculationsFromFailureMechanism<
+ GrassCoverErosionOutwardsFailureMechanismContext,
+ GrassCoverErosionOutwardsFailureMechanism>(o);
+
+ if (grassCoverErosionOutwardsCalculations != null && grassCoverErosionOutwardsCalculations.Any())
{
- return failureMechanism.GetType() == failureMechanismType;
+ return grassCoverErosionOutwardsCalculations;
}
- public object Create(IFailureMechanism failureMechanism, IAssessmentSection assessmentSection)
+ IEnumerable stabilityStoneCoverCalculations = GetCalculationsFromFailureMechanism<
+ StabilityStoneCoverFailureMechanismContext,
+ StabilityStoneCoverFailureMechanism>(o);
+
+ if (stabilityStoneCoverCalculations != null && stabilityStoneCoverCalculations.Any())
{
- return createFailureMechanismContext(failureMechanism, assessmentSection);
+ return stabilityStoneCoverCalculations;
}
+
+ IEnumerable waveImpactAsphaltCoverCalculations = GetCalculationsFromFailureMechanism<
+ WaveImpactAsphaltCoverFailureMechanismContext,
+ WaveImpactAsphaltCoverFailureMechanism>(o);
+
+ return waveImpactAsphaltCoverCalculations;
}
+ private static IEnumerable GetCalculationsFromFailureMechanism(object o)
+ where TContext : class, IFailureMechanismContext
+ where TFailureMechanism : class, IFailureMechanism
+ {
+ IEnumerable calculations = null;
+
+ var failureMechanism = o as TFailureMechanism;
+
+ var context = o as TContext;
+ if (context != null)
+ {
+ failureMechanism = context.WrappedData;
+ }
+
+ var assessmentSection = o as IAssessmentSection;
+ if (assessmentSection != null)
+ {
+ failureMechanism = assessmentSection.GetFailureMechanisms()
+ .OfType()
+ .FirstOrDefault();
+ }
+
+ if (failureMechanism != null)
+ {
+ calculations = (IEnumerable)failureMechanism.Calculations;
+ }
+
+ return calculations;
+ }
+
+ private static IEnumerable GetCalculationsFromCalculationGroupContexts(object o)
+ {
+ IEnumerable calculations = null;
+
+ var grassCoverErosionOutwardsCalculationGroupContext = o as GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext;
+ if (grassCoverErosionOutwardsCalculationGroupContext != null)
+ {
+ calculations = grassCoverErosionOutwardsCalculationGroupContext.WrappedData
+ .GetCalculations()
+ .OfType();
+ }
+ var stabilityStoneCoverCalculationGroupContext = o as StabilityStoneCoverWaveConditionsCalculationGroupContext;
+ if (stabilityStoneCoverCalculationGroupContext != null)
+ {
+ calculations = stabilityStoneCoverCalculationGroupContext.WrappedData
+ .GetCalculations()
+ .OfType();
+ }
+ var waveImpactAsphaltCoverCalculationGroupContext = o as WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext;
+ if (waveImpactAsphaltCoverCalculationGroupContext != null)
+ {
+ calculations = waveImpactAsphaltCoverCalculationGroupContext.WrappedData
+ .GetCalculations()
+ .OfType();
+ }
+
+ return calculations;
+ }
+
+ #endregion
+
+ #endregion
+
+ #region TreeNodeInfos
+
+ #region FailureMechanismSectionsContext TreeNodeInfo
+
+ private ContextMenuStrip FailureMechanismSectionsContextMenuStrip(FailureMechanismSectionsContext nodeData, object parentData, TreeViewControl treeViewControl)
+ {
+ return Gui.Get(nodeData, treeViewControl)
+ .AddImportItem()
+ .Build();
+ }
+
+ #endregion
+
#region BackgroundData treeNodeInfo
private ContextMenuStrip BackgroundDataMenuStrip(BackgroundData nodeData, object parentData, TreeViewControl treeViewControl)
@@ -1010,75 +1209,6 @@
#endregion
- #region Comment ViewInfo
-
- private static bool CloseCommentViewForData(CommentView commentView, object o)
- {
- var calculationGroupContext = o as ICalculationContext;
- if (calculationGroupContext != null)
- {
- return GetCommentElements(calculationGroupContext.WrappedData)
- .Any(commentElement => ReferenceEquals(commentView.Data, commentElement));
- }
-
- var calculationContext = o as ICalculationContext;
- var calculation = calculationContext?.WrappedData as ICalculation;
- if (calculation != null)
- {
- return ReferenceEquals(commentView.Data, calculation.Comments);
- }
-
- var failureMechanism = o as IFailureMechanism;
-
- var failureMechanismContext = o as IFailureMechanismContext;
- if (failureMechanismContext != null)
- {
- failureMechanism = failureMechanismContext.WrappedData;
- }
-
- if (failureMechanism != null)
- {
- return GetCommentElements(failureMechanism)
- .Any(commentElement => ReferenceEquals(commentView.Data, commentElement));
- }
-
- var assessmentSection = o as IAssessmentSection;
- if (assessmentSection != null)
- {
- return GetCommentElements(assessmentSection)
- .Any(commentElement => ReferenceEquals(commentView.Data, commentElement));
- }
-
- return false;
- }
-
- private static IEnumerable GetCommentElements(CalculationGroup calculationGroup)
- {
- return calculationGroup.GetCalculations().Select(c => c.Comments);
- }
-
- private static IEnumerable GetCommentElements(IAssessmentSection assessmentSection)
- {
- yield return assessmentSection.Comments;
- foreach (Comment comment in assessmentSection.GetFailureMechanisms().SelectMany(GetCommentElements))
- {
- yield return comment;
- }
- }
-
- private static IEnumerable GetCommentElements(IFailureMechanism failureMechanism)
- {
- yield return failureMechanism.InputComments;
- yield return failureMechanism.OutputComments;
- yield return failureMechanism.NotRelevantComments;
- foreach (ICalculation calculation in failureMechanism.Calculations)
- {
- yield return calculation.Comments;
- }
- }
-
- #endregion
-
#region AssessmentSection TreeNodeInfo
private static object[] AssessmentSectionChildNodeObjects(AssessmentSection nodeData)
@@ -1534,5 +1664,7 @@
}
#endregion
+
+ #endregion
}
}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj
===================================================================
diff -u -r0c889cff16b60d497640a21c3c9a2ede888dd263 -r16ffb4842cab4a8c457638eef546fd87bea3f0f6
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 0c889cff16b60d497640a21c3c9a2ede888dd263)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/Ringtoets.Integration.Plugin.Test.csproj (.../Ringtoets.Integration.Plugin.Test.csproj) (revision 16ffb4842cab4a8c457638eef546fd87bea3f0f6)
@@ -123,6 +123,7 @@
+
@@ -166,6 +167,10 @@
{E02482C7-F12B-42F0-BB2B-C7EC17503A72}
Core.Components.BruTile
+
+ {2465CCA1-C505-4827-9454-4FD5FD9194CD}
+ Core.Components.Charting.Forms
+
{4a06df0d-5d75-4bad-a95a-a3db9b7c4ad5}
Core.Components.Gis.Forms
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs
===================================================================
diff -u -rec15ff35b39f333c422b8ca6988c34bd8573f134 -r16ffb4842cab4a8c457638eef546fd87bea3f0f6
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision ec15ff35b39f333c422b8ca6988c34bd8573f134)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/RingtoetsPluginTest.cs (.../RingtoetsPluginTest.cs) (revision 16ffb4842cab4a8c457638eef546fd87bea3f0f6)
@@ -38,6 +38,7 @@
using NUnit.Extensions.Forms;
using NUnit.Framework;
using Rhino.Mocks;
+using Rhino.Mocks.Constraints;
using Ringtoets.Common.Data;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
@@ -55,7 +56,9 @@
using Ringtoets.Integration.Forms.PropertyClasses;
using Ringtoets.Integration.Forms.Views;
using Ringtoets.Integration.Forms.Views.SectionResultViews;
+using Ringtoets.Revetment.Data;
using Ringtoets.Revetment.Forms.PresentationObjects;
+using Ringtoets.Revetment.Forms.Views;
using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources;
namespace Ringtoets.Integration.Plugin.Test
@@ -302,7 +305,7 @@
ViewInfo[] viewInfos = plugin.GetViewInfos().ToArray();
// Assert
- Assert.AreEqual(15, viewInfos.Length);
+ Assert.AreEqual(16, viewInfos.Length);
PluginTestHelper.AssertViewInfoDefined(
viewInfos,
@@ -390,6 +393,12 @@
viewInfos,
typeof(Comment),
typeof(CommentView));
+
+ PluginTestHelper.AssertViewInfoDefined(
+ viewInfos,
+ typeof(WaveConditionsInputContext),
+ typeof(IWaveConditionsCalculation),
+ typeof(WaveConditionsInputView));
}
}
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveConditionsInputViewInfoTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveConditionsInputViewInfoTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ViewInfos/WaveConditionsInputViewInfoTest.cs (revision 16ffb4842cab4a8c457638eef546fd87bea3f0f6)
@@ -0,0 +1,672 @@
+// 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.Collections.Generic;
+using System.Linq;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.PresentationObjects;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects;
+using Ringtoets.Integration.Data;
+using Ringtoets.Revetment.Data;
+using Ringtoets.Revetment.Forms.PresentationObjects;
+using Ringtoets.Revetment.Forms.TestUtil;
+using Ringtoets.Revetment.Forms.Views;
+using Ringtoets.Revetment.TestUtil;
+using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.StabilityStoneCover.Forms.PresentationObjects;
+using Ringtoets.WaveImpactAsphaltCover.Data;
+using Ringtoets.WaveImpactAsphaltCover.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Plugin.Test.ViewInfos
+{
+ [TestFixture]
+ public class WaveConditionsInputViewInfoTest
+ {
+ private RingtoetsPlugin plugin;
+ private ViewInfo info;
+
+ [SetUp]
+ public void SetUp()
+ {
+ plugin = new RingtoetsPlugin();
+ 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(WaveConditionsInputContext), info.DataType);
+ Assert.AreEqual(typeof(IWaveConditionsCalculation), info.ViewDataType);
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.GenericInputOutputIcon, info.Image);
+ }
+
+ [Test]
+ public void GetViewName_Always_ReturnsInputResourceName()
+ {
+ // Setup
+ using (var view = new WaveConditionsInputView())
+ {
+ var calculation = new TestWaveConditionsCalculation();
+
+ // Call
+ string viewName = info.GetViewName(view, calculation);
+
+ // Assert
+ Assert.AreEqual("Invoer", viewName);
+ }
+ }
+
+ [Test]
+ public void GetViewData_Always_ReturnsWrappedCalculation()
+ {
+ // Setup
+ var input = new WaveConditionsInput();
+ var calculation = new TestWaveConditionsCalculation();
+ var context = new TestWaveConditionsInputContext(input, calculation,
+ new ForeshoreProfile[0],
+ new HydraulicBoundaryLocation[0]);
+
+ // Call
+ object viewData = info.GetViewData(context);
+
+ // Assert
+ Assert.AreEqual(calculation, viewData);
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedCalculationInputContext_ReturnsTrue()
+ {
+ // Setup
+ var input = new WaveConditionsInput();
+ var calculation = new TestWaveConditionsCalculation();
+ var context = new TestWaveConditionsInputContext(input, calculation,
+ new ForeshoreProfile[0],
+ new HydraulicBoundaryLocation[0]);
+
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, context);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedCalculationInputContext_ReturnsFalse()
+ {
+ // Setup
+ var input = new WaveConditionsInput();
+ var calculation = new TestWaveConditionsCalculation();
+ var calculationToRemove = new TestWaveConditionsCalculation();
+ var context = new TestWaveConditionsInputContext(input, calculationToRemove,
+ new ForeshoreProfile[0],
+ new HydraulicBoundaryLocation[0]);
+
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, context);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+
+ [Test]
+ public void CloseForData_ViewCorrespondingToRemovedCalculation_ReturnsTrue()
+ {
+ // Setup
+ var calculation = new TestWaveConditionsCalculation();
+
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, calculation);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ public void CloseForData_ViewNotCorrespondingToRemovedCalculation_ReturnsFalse()
+ {
+ // Setup
+ var calculation = new TestWaveConditionsCalculation();
+ var calculationToRemove = new TestWaveConditionsCalculation();
+
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, calculationToRemove);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetCalculationGroupDatas),
+ new object[]
+ {
+ "CloseForData_CorrespondingWithCalculationGroupContext_ReturnTrue({0})"
+ })]
+ public void CloseForData_ViewCorrespondingWithRemovedCalculationGroupContext_ReturnsTrue(
+ ICalculationContext context,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, context);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetCalculationGroupDatas),
+ new object[]
+ {
+ "CloseForData_NotCorrespondingWithCalculationGroupContext_ReturnFalse({0})"
+ })]
+ public void CloseForData_ViewNotCorrespondingWithRemovedCalculationGroupContext_ReturnsFalse(
+ ICalculationContext context,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ var contextToRemove = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(new CalculationGroup(),
+ new GrassCoverErosionOutwardsFailureMechanism(),
+ new AssessmentSection(AssessmentSectionComposition.Dike));
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, contextToRemove);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetfailureMechanismContextDatas),
+ new object[]
+ {
+ "CloseForData_CorrespondingWithFailureMechanismContext_ReturnTrue({0})"
+ })]
+ public void CloseForData_ViewCorrespondingWithRemovedFailureMechanismContext_ReturnsTrue(
+ IFailureMechanismContext context,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, context);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetfailureMechanismContextDatas),
+ new object[]
+ {
+ "CloseForData_NotCorrespondingWithFailureMechanismContext_ReturnFalse({0})"
+ })]
+ public void CloseForData_ViewNotCorrespondingWithRemovedFailureMechanismContext_ReturnsFalse(
+ IFailureMechanismContext context,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view,
+ new FailureMechanismContext(
+ new TestFailureMechanism(),
+ new AssessmentSection(AssessmentSectionComposition.Dike)));
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetfailureMechanismDatas),
+ new object[]
+ {
+ "CloseForData_CorrespondingWithFailureMechanismContext_ReturnTrue({0})"
+ })]
+ public void CloseForData_ViewCorrespondingWithRemovedFailureMechanism_ReturnsTrue(
+ IFailureMechanism failureMechanism,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, failureMechanism);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetfailureMechanismDatas),
+ new object[]
+ {
+ "CloseForData_NotCorrespondingWithFailureMechanismContext_ReturnFalse({0})"
+ })]
+ public void CloseForData_ViewNotCorrespondingWithRemovedFailureMechanism_ReturnsFalse(
+ IFailureMechanism failureMechanism,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, new TestFailureMechanism());
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetAssessmentSectionDatas),
+ new object[]
+ {
+ "CloseForData_CorrespondingWithAssessmentSection_ReturnTrue({0})"
+ })]
+ public void CloseForData_ViewCorrespondingToRemovedAssessmentSection_ReturnsTrue(AssessmentSection assessmentSection,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetAssessmentSectionDatas),
+ new object[]
+ {
+ "CloseForData_NotCorrespondingWithAssessmentSection_ReturnFalse({0})"
+ })]
+ public void CloseForData_ViewNotCorrespondingToRemovedAssessmentSection_ReturnsFalse(AssessmentSection assessmentSection,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ using (var view = new WaveConditionsInputView
+ {
+ Data = new TestWaveConditionsCalculation()
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, assessmentSection);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetCalculationGroupDatas),
+ new object[]
+ {
+ "CloseForData_NestedCorrespondingWithCalculationGroupContext_ReturnTrue({0})"
+ })]
+ public void CloseForData_NestedViewCorrespondingWithRemovedCalculationGroupContext_ReturnsTrue(
+ ICalculationContext context,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ context.WrappedData.Children.RemoveAt(0);
+ context.WrappedData.Children.Add(new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ });
+
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, context);
+
+ // Assert
+ Assert.IsTrue(closeForData);
+ }
+ }
+
+ [Test]
+ [TestCaseSource(nameof(GetCalculationGroupDatas),
+ new object[]
+ {
+ "CloseForData_NestedNotCorrespondingWithCalculationGroupContext_ReturnFalse({0})"
+ })]
+ public void CloseForData_NestedViewNotCorrespondingWithRemovedCalculationGroupContext_ReturnsFalse(
+ ICalculationContext context,
+ IWaveConditionsCalculation calculation)
+ {
+ // Setup
+ context.WrappedData.Children.RemoveAt(0);
+ context.WrappedData.Children.Add(new CalculationGroup
+ {
+ Children =
+ {
+ calculation
+ }
+ });
+
+ var contextToRemove = new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(new CalculationGroup(),
+ new GrassCoverErosionOutwardsFailureMechanism(),
+ new AssessmentSection(AssessmentSectionComposition.Dike));
+ using (var view = new WaveConditionsInputView
+ {
+ Data = calculation
+ })
+ {
+ // Call
+ bool closeForData = info.CloseForData(view, contextToRemove);
+
+ // Assert
+ Assert.IsFalse(closeForData);
+ }
+ }
+
+ #region TestCaseData
+
+ private static IEnumerable GetfailureMechanismDatas(string testNameFormat)
+ {
+ var grassCoverErosionOutwardsWaveConditionsCalculation = new GrassCoverErosionOutwardsWaveConditionsCalculation();
+ yield return new TestCaseData(
+ GetFailureMechanism(grassCoverErosionOutwardsWaveConditionsCalculation),
+ grassCoverErosionOutwardsWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(GrassCoverErosionOutwardsFailureMechanism)));
+
+ var stabilityStoneCoverWaveConditionsCalculation = new StabilityStoneCoverWaveConditionsCalculation();
+ yield return new TestCaseData(
+ GetFailureMechanism(stabilityStoneCoverWaveConditionsCalculation),
+ stabilityStoneCoverWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(StabilityStoneCoverFailureMechanism)));
+
+ var waveImpactAsphaltCoverWaveConditionsCalculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
+ yield return new TestCaseData(
+ GetFailureMechanism(waveImpactAsphaltCoverWaveConditionsCalculation),
+ waveImpactAsphaltCoverWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(WaveImpactAsphaltCoverFailureMechanism)));
+ }
+
+ private static IEnumerable GetfailureMechanismContextDatas(string testNameFormat)
+ {
+ var grassCoverErosionOutwardsWaveConditionsCalculation = new GrassCoverErosionOutwardsWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new GrassCoverErosionOutwardsFailureMechanismContext(
+ GetFailureMechanism(grassCoverErosionOutwardsWaveConditionsCalculation),
+ new AssessmentSection(AssessmentSectionComposition.Dike)),
+ grassCoverErosionOutwardsWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(GrassCoverErosionOutwardsFailureMechanismContext)));
+
+ var stabilityStoneCoverWaveConditionsCalculation = new StabilityStoneCoverWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new StabilityStoneCoverFailureMechanismContext(
+ GetFailureMechanism(stabilityStoneCoverWaveConditionsCalculation),
+ new AssessmentSection(AssessmentSectionComposition.Dike)),
+ stabilityStoneCoverWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(StabilityStoneCoverFailureMechanismContext)));
+
+ var waveImpactAsphaltCoverWaveConditionsCalculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new WaveImpactAsphaltCoverFailureMechanismContext(
+ GetFailureMechanism(waveImpactAsphaltCoverWaveConditionsCalculation),
+ new AssessmentSection(AssessmentSectionComposition.Dike)),
+ waveImpactAsphaltCoverWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(WaveImpactAsphaltCoverFailureMechanismContext)));
+ }
+
+ private static IEnumerable GetCalculationGroupDatas(string testNameFormat)
+ {
+ var grassCoverErosionOutwardsWaveConditionsCalculation = new GrassCoverErosionOutwardsWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext(
+ new CalculationGroup
+ {
+ Children =
+ {
+ grassCoverErosionOutwardsWaveConditionsCalculation
+ }
+ },
+ new GrassCoverErosionOutwardsFailureMechanism(),
+ new AssessmentSection(AssessmentSectionComposition.Dike)),
+ grassCoverErosionOutwardsWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(GrassCoverErosionOutwardsWaveConditionsCalculationGroupContext)));
+
+ var stabilityStoneCoverWaveConditionsCalculation = new StabilityStoneCoverWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new StabilityStoneCoverWaveConditionsCalculationGroupContext(
+ new CalculationGroup
+ {
+ Children =
+ {
+ stabilityStoneCoverWaveConditionsCalculation
+ }
+ },
+ new StabilityStoneCoverFailureMechanism(),
+ new AssessmentSection(AssessmentSectionComposition.Dike)),
+ stabilityStoneCoverWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(StabilityStoneCoverWaveConditionsCalculationGroupContext)));
+
+ var waveImpactAsphaltCoverWaveConditionsCalculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext(
+ new CalculationGroup
+ {
+ Children =
+ {
+ waveImpactAsphaltCoverWaveConditionsCalculation
+ }
+ },
+ new WaveImpactAsphaltCoverFailureMechanism(),
+ new AssessmentSection(AssessmentSectionComposition.Dike)),
+ waveImpactAsphaltCoverWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ nameof(WaveImpactAsphaltCoverWaveConditionsCalculationGroupContext)));
+ }
+
+ private static IEnumerable GetAssessmentSectionDatas(string testNameFormat)
+ {
+ var grassCoverErosionOutwardsWaveConditionsCalculation = new GrassCoverErosionOutwardsWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ GrassCoverErosionOutwards =
+ {
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ grassCoverErosionOutwardsWaveConditionsCalculation
+ }
+ }
+ }
+ },
+ grassCoverErosionOutwardsWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ "assessmentSectionGrassCoverErosionOutwards"));
+
+ var stabilityStoneCoverWaveConditionsCalculation = new StabilityStoneCoverWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ StabilityStoneCover =
+ {
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ stabilityStoneCoverWaveConditionsCalculation
+ }
+ }
+ }
+ },
+ stabilityStoneCoverWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ "assessmentSectionStabilityStoneCover"));
+
+ var waveImpactAsphaltCoverWaveConditionsCalculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
+ yield return new TestCaseData(
+ new AssessmentSection(AssessmentSectionComposition.Dike)
+ {
+ WaveImpactAsphaltCover =
+ {
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ waveImpactAsphaltCoverWaveConditionsCalculation
+ }
+ }
+ }
+ }, waveImpactAsphaltCoverWaveConditionsCalculation)
+ .SetName(string.Format(testNameFormat,
+ "assessmentSectionWaveImpactAsphaltCover"));
+ }
+
+ private static GrassCoverErosionOutwardsFailureMechanism GetFailureMechanism(GrassCoverErosionOutwardsWaveConditionsCalculation calculation)
+ {
+ return new GrassCoverErosionOutwardsFailureMechanism
+ {
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ calculation
+ }
+ }
+ };
+ }
+
+ private static StabilityStoneCoverFailureMechanism GetFailureMechanism(StabilityStoneCoverWaveConditionsCalculation calculation)
+ {
+ return new StabilityStoneCoverFailureMechanism
+ {
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ calculation
+ }
+ }
+ };
+ }
+
+ private static WaveImpactAsphaltCoverFailureMechanism GetFailureMechanism(WaveImpactAsphaltCoverWaveConditionsCalculation calculation)
+ {
+ return new WaveImpactAsphaltCoverFailureMechanism
+ {
+ WaveConditionsCalculationGroup =
+ {
+ Children =
+ {
+ calculation
+ }
+ }
+ };
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file