Index: Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculation.cs
===================================================================
diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculation.cs (.../ICalculation.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculation.cs (.../ICalculation.cs) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -41,4 +41,16 @@
///
void ClearOutput();
}
+
+ ///
+ /// A calculation related object which has input parameters.
+ ///
+ /// The type of input parameter.
+ public interface ICalculation : ICalculation where T : ICalculationInput
+ {
+ ///
+ /// Gets the input parameters of the calculation.
+ ///
+ T InputParameters { get; }
+ }
}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/DikeProfiles/IHasForeshoreProfile.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/DikeProfiles/IHasForeshoreProfile.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/DikeProfiles/IHasForeshoreProfile.cs (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -0,0 +1,34 @@
+// 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.
+
+namespace Ringtoets.Common.Data.DikeProfiles
+{
+ ///
+ /// This interface describes if an object has a foreshore profile.
+ ///
+ public interface IHasForeshoreProfile {
+
+ ///
+ /// Gets or sets the foreshore profile.
+ ///
+ ForeshoreProfile ForeshoreProfile { get; set; }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj
===================================================================
diff -u -r670a5510c7638037a4f7e0c3efea0a261085bfbb -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -56,6 +56,7 @@
+
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresCalculation.cs
===================================================================
diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresCalculation.cs (.../StructuresCalculation.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresCalculation.cs (.../StructuresCalculation.cs) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -29,7 +29,7 @@
///
/// This class holds information about a calculation for a structures failure mechanism.
///
- public class StructuresCalculation : Observable, ICalculation where T : ICalculationInput, new()
+ public class StructuresCalculation : Observable, ICalculation where T : ICalculationInput, new()
{
///
/// Initializes a new instance of the class.
@@ -44,7 +44,7 @@
///
/// Gets the input parameters to perform a structures calculation with.
///
- public T InputParameters { get; private set; }
+ public T InputParameters { get; }
///
/// Gets or sets the ,
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs
===================================================================
diff -u -r12cec002453a1828efc68633fbd25219632c6c47 -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs (.../StructuresInputBase.cs) (revision 12cec002453a1828efc68633fbd25219632c6c47)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs (.../StructuresInputBase.cs) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -35,7 +35,7 @@
///
/// Base class that holds generic structures calculation input parameters.
///
- public abstract class StructuresInputBase : Observable, IStructuresCalculationInput, IUseBreakWater, IUseForeshore
+ public abstract class StructuresInputBase : Observable, IStructuresCalculationInput, IUseBreakWater, IUseForeshore, IHasForeshoreProfile
where T : StructureBase
{
private const int structureNormalOrientationNumberOfDecimals = 2;
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs
===================================================================
diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs (.../StructuresInputBaseTest.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Structures/StructuresInputBaseTest.cs (.../StructuresInputBaseTest.cs) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -48,6 +48,7 @@
Assert.IsInstanceOf>(input);
Assert.IsInstanceOf(input);
Assert.IsInstanceOf(input);
+ Assert.IsInstanceOf(input);
Assert.IsNull(input.Structure);
Assert.IsNull(input.HydraulicBoundaryLocation);
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ForeshoreProfileReplaceDataStrategy.cs
===================================================================
diff -u -rf041e286343be511163e939762223954d4851a4e -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ForeshoreProfileReplaceDataStrategy.cs (.../ForeshoreProfileReplaceDataStrategy.cs) (revision f041e286343be511163e939762223954d4851a4e)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ForeshoreProfileReplaceDataStrategy.cs (.../ForeshoreProfileReplaceDataStrategy.cs) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -23,19 +23,14 @@
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base;
-using Ringtoets.ClosingStructures.Data;
+using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.Exceptions;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.UpdateDataStrategies;
using Ringtoets.Common.IO.FileImporters;
-using Ringtoets.GrassCoverErosionOutwards.Data;
-using Ringtoets.HeightStructures.Data;
using Ringtoets.Integration.Plugin.Properties;
using Ringtoets.Integration.Service;
-using Ringtoets.StabilityPointStructures.Data;
-using Ringtoets.StabilityStoneCover.Data;
-using Ringtoets.WaveImpactAsphaltCover.Data;
namespace Ringtoets.Integration.Plugin.FileImporters
{
@@ -46,35 +41,34 @@
public class ForeshoreProfileReplaceDataStrategy : ReplaceDataStrategyBase,
IForeshoreProfileUpdateDataStrategy
{
+ private readonly ForeshoreProfileCollection foreshoreProfileCollection;
+
///
/// Initializes a .
///
/// The failure mechanism in which the foreshore
/// profiles are updated.
+ /// The collection containing the foreshore profiles.
/// Thrown when
/// is null.
- /// Thrown when
- /// is not supported.
- public ForeshoreProfileReplaceDataStrategy(IFailureMechanism failureMechanism) : base(failureMechanism)
+ public ForeshoreProfileReplaceDataStrategy(IFailureMechanism failureMechanism,
+ ForeshoreProfileCollection foreshoreProfiles) : base(failureMechanism)
{
- if (!(failureMechanism is WaveImpactAsphaltCoverFailureMechanism)
- && !(failureMechanism is StabilityStoneCoverFailureMechanism)
- && !(failureMechanism is GrassCoverErosionOutwardsFailureMechanism)
- && !(failureMechanism is HeightStructuresFailureMechanism)
- && !(failureMechanism is StabilityPointStructuresFailureMechanism)
- && !(failureMechanism is ClosingStructuresFailureMechanism))
+ if (foreshoreProfiles == null)
{
- throw new NotSupportedException($"Can't apply this strategy for {failureMechanism.GetType()}.");
+ throw new ArgumentNullException(nameof(foreshoreProfiles));
}
+
+ foreshoreProfileCollection = foreshoreProfiles;
}
- public IEnumerable UpdateForeshoreProfilesWithImportedData(ForeshoreProfileCollection targetDataCollection,
+ public IEnumerable UpdateForeshoreProfilesWithImportedData(ForeshoreProfileCollection foreshoreProfiles,
IEnumerable importedDataCollection,
string sourceFilePath)
{
try
{
- return ReplaceTargetCollectionWithImportedData(targetDataCollection, importedDataCollection, sourceFilePath);
+ return ReplaceTargetCollectionWithImportedData(foreshoreProfiles, importedDataCollection, sourceFilePath);
}
catch (UpdateDataException e)
{
@@ -88,44 +82,9 @@
protected override IEnumerable ClearData()
{
- // TODO: Clearing the output will be implemented as part of WTI-1116
- var waveImpactAsphaltCoverFailureMechanism = FailureMechanism as WaveImpactAsphaltCoverFailureMechanism;
- if (waveImpactAsphaltCoverFailureMechanism != null)
- {
- return RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(waveImpactAsphaltCoverFailureMechanism);
- }
-
- var stabilityStoneCoverFailureMechanism = FailureMechanism as StabilityStoneCoverFailureMechanism;
- if (stabilityStoneCoverFailureMechanism != null)
- {
- return RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(stabilityStoneCoverFailureMechanism);
- }
-
- var grassCoverErosionOutwardsFailureMechanism = FailureMechanism as GrassCoverErosionOutwardsFailureMechanism;
- if (grassCoverErosionOutwardsFailureMechanism != null)
- {
- return RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(grassCoverErosionOutwardsFailureMechanism);
- }
-
- var heightStructuresFailureMechanism = FailureMechanism as HeightStructuresFailureMechanism;
- if (heightStructuresFailureMechanism != null)
- {
- return RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(heightStructuresFailureMechanism);
- }
-
- var stabilityPointStructuresFailureMechanism = FailureMechanism as StabilityPointStructuresFailureMechanism;
- if (stabilityPointStructuresFailureMechanism != null)
- {
- return RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(stabilityPointStructuresFailureMechanism);
- }
-
- var closingStructuresFailureMechanism = FailureMechanism as ClosingStructuresFailureMechanism;
- if (closingStructuresFailureMechanism != null)
- {
- return RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(closingStructuresFailureMechanism);
- }
-
- return Enumerable.Empty();
+ IEnumerable> calculations = FailureMechanism.Calculations
+ .Cast>();
+ return RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(calculations, foreshoreProfileCollection);
}
}
}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs
===================================================================
diff -u -r91d2618c244882958683e28675970ef50bbf2fe6 -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs (.../RingtoetsDataSynchronizationService.cs) (revision 91d2618c244882958683e28675970ef50bbf2fe6)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs (.../RingtoetsDataSynchronizationService.cs) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -583,203 +583,45 @@
}
///
- /// Removes all from the
- /// and clears all data that depends on it, either directly or indirectly.
+ /// Removes all from the
+ /// and the in addition to clearing all data that depends
+ /// on it, either directly or indirectly.
///
- /// The failure mechanism
- /// containing the .
- /// All observable objects affected by this method.
- /// Thrown when
- /// is null.
- public static IEnumerable RemoveAllForeshoreProfiles(ClosingStructuresFailureMechanism failureMechanism)
+ /// The calculations that need to be updated
+ /// The collection containing the foreshore profiles.
+ /// An with affected objects.
+ /// Thrown when any input argument is
+ /// null.
+ public static IEnumerable RemoveAllForeshoreProfiles(IEnumerable> calculations,
+ ForeshoreProfileCollection foreshoreProfiles)
+ where T : ICalculationInput
{
- if (failureMechanism == null)
+ if (calculations == null)
{
- throw new ArgumentNullException(nameof(failureMechanism));
+ throw new ArgumentNullException(nameof(calculations));
}
-
- IEnumerable> affectedCalculations =
- failureMechanism.Calculations
- .OfType>()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null);
-
- var affectedObjects = new List();
- foreach (StructuresCalculation calculation in affectedCalculations)
+ if (foreshoreProfiles == null)
{
- calculation.InputParameters.ForeshoreProfile = null;
- affectedObjects.Add(calculation.InputParameters);
+ throw new ArgumentNullException(nameof(foreshoreProfiles));
}
- failureMechanism.ForeshoreProfiles.Clear();
- affectedObjects.Add(failureMechanism.ForeshoreProfiles);
- return affectedObjects;
- }
+ IEnumerable> calculationsWithForeshoreProfiles =
+ calculations.Where(calc => ((IHasForeshoreProfile) calc.InputParameters)
+ .ForeshoreProfile != null);
- ///
- /// Removes all from the
- /// and clears all data that depends on it, either directly or indirectly.
- ///
- /// The failure mechanism
- /// containing the .
- /// All observable objects affected by this method.
- /// Thrown when
- /// is null.
- public static IEnumerable RemoveAllForeshoreProfiles(StabilityPointStructuresFailureMechanism failureMechanism)
- {
- if (failureMechanism == null)
- {
- throw new ArgumentNullException(nameof(failureMechanism));
- }
-
- IEnumerable> affectedCalculations =
- failureMechanism.Calculations
- .OfType>()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null);
-
var affectedObjects = new List();
- foreach (StructuresCalculation calculation in affectedCalculations)
+ foreach (ICalculation calculation in calculationsWithForeshoreProfiles)
{
- calculation.InputParameters.ForeshoreProfile = null;
+ ((IHasForeshoreProfile) calculation.InputParameters).ForeshoreProfile = null;
affectedObjects.Add(calculation.InputParameters);
+ affectedObjects.AddRange(RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(calculation));
}
- failureMechanism.ForeshoreProfiles.Clear();
- affectedObjects.Add(failureMechanism.ForeshoreProfiles);
+ foreshoreProfiles.Clear();
+ affectedObjects.Add(foreshoreProfiles);
return affectedObjects;
}
- ///
- /// Removes all from the
- /// and clears all data that depends on it, either directly or indirectly.
- ///
- /// The failure mechanism
- /// containing the .
- /// All observable objects affected by this method.
- /// Thrown when
- /// is null.
- public static IEnumerable RemoveAllForeshoreProfiles(HeightStructuresFailureMechanism failureMechanism)
- {
- if (failureMechanism == null)
- {
- throw new ArgumentNullException(nameof(failureMechanism));
- }
-
- IEnumerable> affectedCalculations =
- failureMechanism.Calculations
- .OfType>()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null);
-
- var affectedObjects = new List();
- foreach (StructuresCalculation calculation in affectedCalculations)
- {
- calculation.InputParameters.ForeshoreProfile = null;
- affectedObjects.Add(calculation.InputParameters);
- }
-
- failureMechanism.ForeshoreProfiles.Clear();
- affectedObjects.Add(failureMechanism.ForeshoreProfiles);
- return affectedObjects;
- }
-
- ///
- /// Removes all from the
- /// and clears all data that depends on it, either directly or indirectly.
- ///
- /// The failure mechanism
- /// containing the .
- /// All observable objects affected by this method.
- /// Thrown when
- /// is null.
- public static IEnumerable RemoveAllForeshoreProfiles(GrassCoverErosionOutwardsFailureMechanism failureMechanism)
- {
- if (failureMechanism == null)
- {
- throw new ArgumentNullException(nameof(failureMechanism));
- }
-
- IEnumerable affectedCalculations =
- failureMechanism.Calculations
- .OfType()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null);
-
- var affectedObjects = new List();
- foreach (GrassCoverErosionOutwardsWaveConditionsCalculation calculation in affectedCalculations)
- {
- calculation.InputParameters.ForeshoreProfile = null;
- affectedObjects.Add(calculation.InputParameters);
- }
-
- failureMechanism.ForeshoreProfiles.Clear();
- affectedObjects.Add(failureMechanism.ForeshoreProfiles);
- return affectedObjects;
- }
-
- ///
- /// Removes all from the
- /// and clears all data that depends on it, either directly or indirectly.
- ///
- /// The failure mechanism
- /// containing the .
- /// All observable objects affected by this method.
- /// Thrown when
- /// is null.
- public static IEnumerable RemoveAllForeshoreProfiles(StabilityStoneCoverFailureMechanism failureMechanism)
- {
- if (failureMechanism == null)
- {
- throw new ArgumentNullException(nameof(failureMechanism));
- }
-
- IEnumerable affectedCalculations =
- failureMechanism.Calculations
- .OfType()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null);
-
- var affectedObjects = new List();
- foreach (StabilityStoneCoverWaveConditionsCalculation calculation in affectedCalculations)
- {
- calculation.InputParameters.ForeshoreProfile = null;
- affectedObjects.Add(calculation.InputParameters);
- }
-
- failureMechanism.ForeshoreProfiles.Clear();
- affectedObjects.Add(failureMechanism.ForeshoreProfiles);
- return affectedObjects;
- }
-
- ///
- /// Removes all from the
- /// and clears all data that depends on it, either directly or indirectly.
- ///
- /// The failure mechanism
- /// containing the .
- /// All observable objects affected by this method.
- /// Thrown when
- /// is null.
- public static IEnumerable RemoveAllForeshoreProfiles(WaveImpactAsphaltCoverFailureMechanism failureMechanism)
- {
- if (failureMechanism == null)
- {
- throw new ArgumentNullException(nameof(failureMechanism));
- }
-
- IEnumerable affectedCalculations =
- failureMechanism.Calculations
- .OfType()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null);
-
- var affectedObjects = new List();
- foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in affectedCalculations)
- {
- calculation.InputParameters.ForeshoreProfile = null;
- affectedObjects.Add(calculation.InputParameters);
- }
-
- failureMechanism.ForeshoreProfiles.Clear();
- affectedObjects.Add(failureMechanism.ForeshoreProfiles);
- return affectedObjects;
- }
-
private static ClearResults GetClearResultsForFailureMechanism(IFailureMechanism failureMechanism)
{
var pipingFailureMechanism = failureMechanism as PipingFailureMechanism;
Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/ForeshoreProfileReplaceDataStrategyTest.cs
===================================================================
diff -u -r91d2618c244882958683e28675970ef50bbf2fe6 -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/ForeshoreProfileReplaceDataStrategyTest.cs (.../ForeshoreProfileReplaceDataStrategyTest.cs) (revision 91d2618c244882958683e28675970ef50bbf2fe6)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/ForeshoreProfileReplaceDataStrategyTest.cs (.../ForeshoreProfileReplaceDataStrategyTest.cs) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -24,23 +24,15 @@
using System.Linq;
using Core.Common.Base;
using NUnit.Framework;
-using Ringtoets.ClosingStructures.Data;
-using Ringtoets.ClosingStructures.Data.TestUtil;
+using Ringtoets.Common.Data;
+using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.Exceptions;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.TestUtil;
using Ringtoets.Common.Data.UpdateDataStrategies;
using Ringtoets.Common.IO.FileImporters;
-using Ringtoets.GrassCoverErosionOutwards.Data;
-using Ringtoets.HeightStructures.Data;
-using Ringtoets.HeightStructures.Data.TestUtil;
using Ringtoets.Integration.Plugin.FileImporters;
-using Ringtoets.Revetment.Data;
-using Ringtoets.StabilityPointStructures.Data;
-using Ringtoets.StabilityPointStructures.Data.TestUtil;
-using Ringtoets.StabilityStoneCover.Data;
-using Ringtoets.WaveImpactAsphaltCover.Data;
namespace Ringtoets.Integration.Plugin.Test.FileImporters
{
@@ -49,97 +41,45 @@
{
private const string sourceFilePath = "path/to/foreshoreProfiles";
- private static IEnumerable SupportedFailureMechanisms
- {
- get
- {
- yield return new TestCaseData(new WaveImpactAsphaltCoverFailureMechanism()).SetName("WaveImpactAsphaltCover");
- yield return new TestCaseData(new GrassCoverErosionOutwardsFailureMechanism()).SetName("GrassCoverErosionOutwards");
- yield return new TestCaseData(new StabilityStoneCoverFailureMechanism()).SetName("StabilityStoneCover");
- yield return new TestCaseData(new HeightStructuresFailureMechanism()).SetName("HeightStructures");
- yield return new TestCaseData(new StabilityPointStructuresFailureMechanism()).SetName("StabilityPointStructures");
- yield return new TestCaseData(new ClosingStructuresFailureMechanism()).SetName("ClosingStructures");
- }
- }
-
- private static IEnumerable SupportedFailureMechanismsAndEmptyForeshoreProfileCollection
- {
- get
- {
- var waveImpactAsphaltCoverFailureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
- waveImpactAsphaltCoverFailureMechanism.WaveConditionsCalculationGroup.Children.Add(new WaveImpactAsphaltCoverWaveConditionsCalculation());
- yield return new TestCaseData(waveImpactAsphaltCoverFailureMechanism,
- waveImpactAsphaltCoverFailureMechanism.ForeshoreProfiles)
- .SetName("WaveImpactAsphaltCover");
-
- var grassCoverErosionOutwardsFailureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
- yield return new TestCaseData(grassCoverErosionOutwardsFailureMechanism,
- grassCoverErosionOutwardsFailureMechanism.ForeshoreProfiles)
- .SetName("GrassCoverErosionOutwards");
-
- var stabilityStoneCoverFailureMechanism = new StabilityStoneCoverFailureMechanism();
- yield return new TestCaseData(stabilityStoneCoverFailureMechanism,
- stabilityStoneCoverFailureMechanism.ForeshoreProfiles)
- .SetName("StabilityStoneCover");
-
- var heightStructuresFailureMechanism = new HeightStructuresFailureMechanism();
- yield return new TestCaseData(heightStructuresFailureMechanism,
- heightStructuresFailureMechanism.ForeshoreProfiles)
- .SetName("HeightStructures");
-
- var stabilityPointStructuresFailureMechanism = new StabilityPointStructuresFailureMechanism();
- yield return new TestCaseData(stabilityPointStructuresFailureMechanism,
- stabilityPointStructuresFailureMechanism.ForeshoreProfiles)
- .SetName("StabilityPointStructures");
-
- var closingStructuresFailureMechanism = new ClosingStructuresFailureMechanism();
- yield return new TestCaseData(closingStructuresFailureMechanism,
- closingStructuresFailureMechanism.ForeshoreProfiles)
- .SetName("ClosingStructures");
- }
- }
-
[Test]
- public void Constructor_UnsupportedFailureMechanism_ThrowsNotSupportedException()
+ public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
{
- // Call
- TestDelegate call = () => new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism());
+ // Call
+ TestDelegate call = () => new ForeshoreProfileReplaceDataStrategy(null, new ForeshoreProfileCollection());
- // Assert
- var exception = Assert.Throws(call);
- Assert.AreEqual($"Can't apply this strategy for {typeof(TestFailureMechanism)}.", exception.Message);
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
}
[Test]
- public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
+ public void Constructor_ForeshoreProfileCollectionNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate call = () => new ForeshoreProfileReplaceDataStrategy(null);
+ TestDelegate call = () => new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), null);
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("failureMechanism", exception.ParamName);
+ Assert.AreEqual("foreshoreProfiles", exception.ParamName);
}
[Test]
- [TestCaseSource(nameof(SupportedFailureMechanisms))]
- public void Constructor_SupportedFailureMechanism_CreatesNewInstance(IFailureMechanism failureMechanism)
+ public void Constructor_SupportedFailureMechanism_CreatesNewInstance()
{
// Call
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
+ var strategy = new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), new ForeshoreProfileCollection());
// Assert
Assert.IsInstanceOf>(strategy);
Assert.IsInstanceOf(strategy);
}
[Test]
- [TestCaseSource(nameof(SupportedFailureMechanisms))]
- public void UpdateForeshoreProfilesWithImportedData_TargetCollectionNull_ThrowsArgumentNullException(
- IFailureMechanism failureMechanism)
+ public void UpdateForeshoreProfilesWithImportedData_TargetDataCollectionNull_ThrowsArgumentNullException()
{
// Setup
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
+ var foreshoreProfileCollection = new ForeshoreProfileCollection();
+ var strategy = new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), foreshoreProfileCollection);
// Call
TestDelegate call = () => strategy.UpdateForeshoreProfilesWithImportedData(null,
@@ -152,15 +92,14 @@
}
[Test]
- [TestCaseSource(nameof(SupportedFailureMechanisms))]
- public void UpdateForeshoreProfilesWithImportedData_ImportedDataCollectionNull_ThrowsArgumentNullException(
- IFailureMechanism failureMechanism)
+ public void UpdateForeshoreProfilesWithImportedData_ImportedDataCollectionNull_ThrowsArgumentNullException()
{
// Setup
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
+ var foreshoreProfileCollection = new ForeshoreProfileCollection();
+ var strategy = new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), foreshoreProfileCollection);
// Call
- TestDelegate call = () => strategy.UpdateForeshoreProfilesWithImportedData(new ForeshoreProfileCollection(),
+ TestDelegate call = () => strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfileCollection,
null,
"path");
@@ -170,15 +109,14 @@
}
[Test]
- [TestCaseSource(nameof(SupportedFailureMechanisms))]
- public void UpdateForeshoreProfilesWithImportedData_SourceFilePathNull_ThrowsArgumentNullException(
- IFailureMechanism failureMechanism)
+ public void UpdateForeshoreProfilesWithImportedData_SourceFilePathNull_ThrowsArgumentNullException()
{
// Setup
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
+ var foreshoreProfileCollection = new ForeshoreProfileCollection();
+ var strategy = new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), foreshoreProfileCollection);
// Call
- TestDelegate call = () => strategy.UpdateForeshoreProfilesWithImportedData(new ForeshoreProfileCollection(),
+ TestDelegate call = () => strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfileCollection,
Enumerable.Empty(),
null);
@@ -188,19 +126,11 @@
}
[Test]
- [TestCaseSource(nameof(SupportedFailureMechanisms))]
- public void UpdateForeshoreProfilesWithImportedData_ImportedDataContainsDuplicateIDs_ThrowsUpdateException(
- IFailureMechanism failureMechanism)
+ public void UpdateForeshoreProfilesWithImportedData_ImportedDataContainsDuplicateIDs_ThrowsUpdateException()
{
// Setup
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
-
- var originalForeshoreProfiles = new[]
- {
- new TestForeshoreProfile("original profile", "original ID")
- };
var foreshoreProfiles = new ForeshoreProfileCollection();
- foreshoreProfiles.AddRange(originalForeshoreProfiles, sourceFilePath);
+ var strategy = new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), foreshoreProfiles);
const string duplicateId = "Just a duplicate ID";
var importedForeshoreProfiles = new[]
@@ -210,8 +140,7 @@
};
// Call
- TestDelegate call = () => strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfiles,
- importedForeshoreProfiles,
+ TestDelegate call = () => strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfiles, importedForeshoreProfiles,
sourceFilePath);
// Assert
@@ -220,18 +149,14 @@
$"Voorlandprofielen moeten een unieke id hebben. Gevonden dubbele elementen: {duplicateId}.";
Assert.AreEqual(expectedMessage, exception.Message);
Assert.IsInstanceOf(exception.InnerException);
-
- CollectionAssert.AreEqual(originalForeshoreProfiles, foreshoreProfiles);
}
[Test]
- [TestCaseSource(nameof(SupportedFailureMechanisms))]
- public void UpdateForeshoreProfilesWithImportedData_DifferentSourcePath_UpdatesSourcePathOfDataCollection(
- IFailureMechanism failureMechanism)
+ public void UpdateForeshoreProfilesWithImportedData_DifferentSourcePath_UpdatesSourcePathOfDataCollection()
{
// Setup
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
var foreshoreProfiles = new ForeshoreProfileCollection();
+ var strategy = new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), foreshoreProfiles);
const string newForeshoreProfilesPath = "new/path";
@@ -249,12 +174,11 @@
}
[Test]
- [TestCaseSource(nameof(SupportedFailureMechanismsAndEmptyForeshoreProfileCollection))]
- public void UpdateForeshoreProfilesWithImportedData_CollectionEmptyAndImportedCollectionNotEmpty_AddsNewForeshoreProfiles(
- IFailureMechanism failureMechanism, ForeshoreProfileCollection foreshoreProfiles)
+ public void UpdateForeshoreProfilesWithImportedData_CollectionEmptyAndImportedCollectionNotEmpty_AddsNewForeshoreProfiles()
{
// Setup
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
+ var foreshoreProfiles = new ForeshoreProfileCollection();
+ var strategy = new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), foreshoreProfiles);
var importedForeshoreProfiles = new[]
{
@@ -275,17 +199,16 @@
}
[Test]
- [TestCaseSource(nameof(SupportedFailureMechanismsAndEmptyForeshoreProfileCollection))]
- public void UpdateForeshoreProfilesWithImportedData_CollectionAndImportedCollectionNotEmpty_ReplaceCurrentWithImportedData(
- IFailureMechanism failureMechanism, ForeshoreProfileCollection foreshoreProfiles)
+ public void UpdateForeshoreProfilesWithImportedData_CollectionAndImportedCollectionNotEmpty_ReplaceCurrentWithImportedData()
{
// Setup
+ var foreshoreProfiles = new ForeshoreProfileCollection();
foreshoreProfiles.AddRange(new[]
{
new TestForeshoreProfile("Profile 1", "ID 1")
}, sourceFilePath);
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
+ var strategy = new ForeshoreProfileReplaceDataStrategy(new TestFailureMechanism(), foreshoreProfiles);
var importedForeshoreProfiles = new[]
{
@@ -305,262 +228,106 @@
}, affectedObjects);
}
- #region Wave Impact Asphalt Cover
-
[Test]
- public void UpdateForeshoreProfilesWithImportedData_WaveImpactAsphaltCoverCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ public void UpdateForeshoreProfilesWithImportedData_CalculationsWithForeshoreProfilesAndOutput_CalculationUpdatedAndReturnsAffectedData()
{
// Setup
- var foreshoreProfile = new TestForeshoreProfile("Profile 1", "ID 1");
-
- var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism();
- ForeshoreProfileCollection foreshoreProfiles = failureMechanism.ForeshoreProfiles;
- foreshoreProfiles.AddRange(new[]
+ var foreshoreProfile = new TestForeshoreProfile();
+ var calculationWithForeshoreProfileAndOutput = new TestCalculationWithForeshoreProfile(true)
{
- foreshoreProfile
- }, sourceFilePath);
-
- var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
- {
InputParameters =
{
ForeshoreProfile = foreshoreProfile
}
};
- failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation);
-
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
-
- // Call
- IEnumerable affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfiles,
- Enumerable.Empty(),
- sourceFilePath);
-
- // Assert
- WaveConditionsInput inputParameters = calculation.InputParameters;
- Assert.IsNull(inputParameters.ForeshoreProfile);
- CollectionAssert.AreEquivalent(new IObservable[]
+ var calculationWithForeshoreProfile = new TestCalculationWithForeshoreProfile(false)
{
- foreshoreProfiles,
- inputParameters
- }, affectedObjects);
- }
-
- #endregion
-
- #region Grass Cover Erosion Outwards
-
- [Test]
- public void UpdateForeshoreProfilesWithImportedData_GrassCoverErosionOutwardsCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
- {
- // Setup
- var foreshoreProfile = new TestForeshoreProfile("Profile 1", "ID 1");
-
- var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
- ForeshoreProfileCollection foreshoreProfiles = failureMechanism.ForeshoreProfiles;
- foreshoreProfiles.AddRange(new[]
- {
- foreshoreProfile
- }, sourceFilePath);
-
- var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
- {
InputParameters =
{
ForeshoreProfile = foreshoreProfile
}
};
- failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation);
+ var calculationWithoutForeshoreProfile = new TestCalculationWithForeshoreProfile(false);
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
-
- // Call
- IEnumerable affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfiles,
- Enumerable.Empty(),
- sourceFilePath);
-
- // Assert
- WaveConditionsInput inputParameters = calculation.InputParameters;
- Assert.IsNull(inputParameters.ForeshoreProfile);
- CollectionAssert.AreEquivalent(new IObservable[]
+ var failureMechanism = new TestFailureMechanism(new[]
{
- foreshoreProfiles,
- inputParameters
- }, affectedObjects);
- }
+ calculationWithForeshoreProfileAndOutput,
+ calculationWithForeshoreProfile,
+ calculationWithoutForeshoreProfile
+ });
- #endregion
-
- #region Stability Stone Cover
-
- [Test]
- public void UpdateForeshoreProfilesWithImportedData_StabilityStoneCoverCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
- {
- // Setup
- var foreshoreProfile = new TestForeshoreProfile("Profile 1", "ID 1");
-
- var failureMechanism = new StabilityStoneCoverFailureMechanism();
- ForeshoreProfileCollection foreshoreProfiles = failureMechanism.ForeshoreProfiles;
+ var foreshoreProfiles = new ForeshoreProfileCollection();
foreshoreProfiles.AddRange(new[]
{
foreshoreProfile
}, sourceFilePath);
- var calculation = new StabilityStoneCoverWaveConditionsCalculation
+ var calculationsWithForeshoreProfile = new[]
{
- InputParameters =
- {
- ForeshoreProfile = foreshoreProfile
- }
+ calculationWithForeshoreProfileAndOutput,
+ calculationWithForeshoreProfile
};
- failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation);
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
+ var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism, foreshoreProfiles);
// Call
IEnumerable affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfiles,
Enumerable.Empty(),
sourceFilePath);
// Assert
- WaveConditionsInput inputParameters = calculation.InputParameters;
- Assert.IsNull(inputParameters.ForeshoreProfile);
- CollectionAssert.AreEquivalent(new IObservable[]
- {
- foreshoreProfiles,
- inputParameters
- }, affectedObjects);
- }
+ CollectionAssert.IsEmpty(foreshoreProfiles);
+ Assert.IsFalse(calculationWithForeshoreProfileAndOutput.HasOutput);
+ Assert.IsTrue(calculationsWithForeshoreProfile.All(calc => calc.InputParameters.ForeshoreProfile == null));
- #endregion
-
- #region Height Structures
-
- [Test]
- public void UpdateForeshoreProfilesWithImportedData_HeightStructuresCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
- {
- // Setup
- var foreshoreProfile = new TestForeshoreProfile("Profile 1", "ID 1");
-
- var failureMechanism = new HeightStructuresFailureMechanism();
- ForeshoreProfileCollection foreshoreProfiles = failureMechanism.ForeshoreProfiles;
- foreshoreProfiles.AddRange(new[]
- {
- foreshoreProfile
- }, sourceFilePath);
-
- var calculation = new TestHeightStructuresCalculation
- {
- InputParameters =
- {
- ForeshoreProfile = foreshoreProfile
- }
- };
- failureMechanism.CalculationsGroup.Children.Add(calculation);
-
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
-
- // Call
- IEnumerable affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfiles,
- Enumerable.Empty(),
- sourceFilePath);
-
- // Assert
- HeightStructuresInput inputParameters = calculation.InputParameters;
- Assert.IsNull(inputParameters.ForeshoreProfile);
- CollectionAssert.AreEquivalent(new IObservable[]
- {
- foreshoreProfiles,
- inputParameters
- }, affectedObjects);
+ IEnumerable expectedAffectedObjects =
+ calculationsWithForeshoreProfile.Select(calc => calc.InputParameters)
+ .Concat(new IObservable[]
+ {
+ foreshoreProfiles,
+ calculationWithForeshoreProfileAndOutput
+ });
+ CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
}
- #endregion
-
- #region Stability Point Structures
-
- [Test]
- public void UpdateForeshoreProfilesWithImportedData_StabilityPointStructuresCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ private class TestCalculationWithForeshoreProfile : Observable, ICalculation
{
- // Setup
- var foreshoreProfile = new TestForeshoreProfile("Profile 1", "ID 1");
-
- var failureMechanism = new StabilityPointStructuresFailureMechanism();
- ForeshoreProfileCollection foreshoreProfiles = failureMechanism.ForeshoreProfiles;
- foreshoreProfiles.AddRange(new[]
+ public TestCalculationWithForeshoreProfile(bool hasOutput)
{
- foreshoreProfile
- }, sourceFilePath);
+ InputParameters = new TestCalculationInputWithForeshoreProfile();
+ HasOutput = hasOutput;
+ }
- var calculation = new TestStabilityPointStructuresCalculation
- {
- InputParameters =
- {
- ForeshoreProfile = foreshoreProfile
- }
- };
- failureMechanism.CalculationsGroup.Children.Add(calculation);
+ public string Name { get; set; }
+ public bool HasOutput { get; private set; }
+ public Comment Comments { get; }
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
+ public TestCalculationInputWithForeshoreProfile InputParameters { get; }
- // Call
- IEnumerable affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfiles,
- Enumerable.Empty(),
- sourceFilePath);
-
- // Assert
- StabilityPointStructuresInput inputParameters = calculation.InputParameters;
- Assert.IsNull(inputParameters.ForeshoreProfile);
- CollectionAssert.AreEquivalent(new IObservable[]
+ public void ClearOutput()
{
- foreshoreProfiles,
- inputParameters
- }, affectedObjects);
+ HasOutput = false;
+ }
}
- #endregion
-
- #region Closing Structures
-
- [Test]
- public void UpdateForeshoreProfilesWithImportedData_ClosingStructuresCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ private class TestCalculationInputWithForeshoreProfile : ICalculationInput, IHasForeshoreProfile
{
- // Setup
- var foreshoreProfile = new TestForeshoreProfile("Profile 1", "ID 1");
+ public ForeshoreProfile ForeshoreProfile { get; set; }
- var failureMechanism = new ClosingStructuresFailureMechanism();
- ForeshoreProfileCollection foreshoreProfiles = failureMechanism.ForeshoreProfiles;
- foreshoreProfiles.AddRange(new[]
+ public void Attach(IObserver observer)
{
- foreshoreProfile
- }, sourceFilePath);
+ throw new NotImplementedException();
+ }
- var calculation = new TestClosingStructuresCalculation
+ public void Detach(IObserver observer)
{
- InputParameters =
- {
- ForeshoreProfile = foreshoreProfile
- }
- };
- failureMechanism.CalculationsGroup.Children.Add(calculation);
+ throw new NotImplementedException();
+ }
- var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism);
-
- // Call
- IEnumerable affectedObjects = strategy.UpdateForeshoreProfilesWithImportedData(foreshoreProfiles,
- Enumerable.Empty(),
- sourceFilePath);
-
- // Assert
- ClosingStructuresInput inputParameters = calculation.InputParameters;
- Assert.IsNull(inputParameters.ForeshoreProfile);
- CollectionAssert.AreEquivalent(new IObservable[]
+ public void NotifyObservers()
{
- foreshoreProfiles,
- inputParameters
- }, affectedObjects);
+ throw new NotImplementedException();
+ }
}
-
- #endregion
}
}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/RingtoetsDataSynchronizationServiceTest.cs
===================================================================
diff -u -r91d2618c244882958683e28675970ef50bbf2fe6 -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/RingtoetsDataSynchronizationServiceTest.cs (.../RingtoetsDataSynchronizationServiceTest.cs) (revision 91d2618c244882958683e28675970ef50bbf2fe6)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Service.Test/RingtoetsDataSynchronizationServiceTest.cs (.../RingtoetsDataSynchronizationServiceTest.cs) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -26,6 +26,7 @@
using NUnit.Framework;
using Rhino.Mocks;
using Ringtoets.ClosingStructures.Data;
+using Ringtoets.Common.Data;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.DikeProfiles;
@@ -1236,258 +1237,92 @@
}
[Test]
- public void RemoveAllForeshoreProfile_ClosingStructuresFailureMechanismNull_ThrowsArgumentNullException()
+ public void RemoveAllForeshoreProfile_CalculationsNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate call = () => RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles((ClosingStructuresFailureMechanism) null);
+ TestDelegate call = () => RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(null,
+ new ForeshoreProfileCollection());
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("failureMechanism", exception.ParamName);
+ Assert.AreEqual("calculations", exception.ParamName);
}
[Test]
- public void RemoveAllForeshoreProfile_FullyConfiguredClosingStructuresFailureMechanism_RemovesAllForeshoreProfilesAndDependentData()
+ public void RemoveAllForeshoreProfile_ForeshoreProfilesNull_ThrowsArgumentNullException()
{
- // Setup
- ClosingStructuresFailureMechanism failureMechanism = TestDataGenerator.GetClosingStructuresFailureMechanismWithAllCalculationConfigurations();
-
- StructuresCalculation[] calculationsWithForeshoreProfiles = failureMechanism.Calculations
- .Cast>()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null)
- .ToArray();
-
- // Pre-condition
- CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
-
// Call
- IEnumerable affectedObjects = RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(failureMechanism);
+ TestDelegate call = () => RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(Enumerable.Empty>(),
+ null);
// Assert
- // Note: To make sure the clear is performed regardless of what is done with
- // the return result, no ToArray() should be called before these assertions:
- CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
-
- IEnumerable expectedAffectedObjects =
- calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
- .Concat(new IObservable[]
- {
- failureMechanism.ForeshoreProfiles
- });
- CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
- }
-
- [Test]
- public void RemoveAllForeshoreProfile_StabilityPointStructuresFailureMechanismNull_ThrowsArgumentNullException()
- {
- // Call
- TestDelegate call = () => RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles((StabilityPointStructuresFailureMechanism) null);
-
- // Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("failureMechanism", exception.ParamName);
+ Assert.AreEqual("foreshoreProfiles", exception.ParamName);
}
[Test]
- public void RemoveAllForeshoreProfile_FullyConfiguredStabilityPointStructuresFailureMechanism_RemovesAllForeshoreProfilesAndDependentData()
+ public void RemoveAllForeshoreProfile_FullyConfiguredClosingStructuresFailureMechanism_RemovesAllForeshoreProfilesAndDependentData()
{
// Setup
- StabilityPointStructuresFailureMechanism failureMechanism = TestDataGenerator.GetStabilityPointStructuresFailureMechanismWithAllCalculationConfigurations();
+ var foreshoreProfile = new TestForeshoreProfile();
+ var foreshoreProfiles = new ForeshoreProfileCollection();
+ foreshoreProfiles.AddRange(new[]
+ {
+ foreshoreProfile
+ }, "path");
- StructuresCalculation[] calculationsWithForeshoreProfiles = failureMechanism.Calculations
- .Cast>()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null)
- .ToArray();
+ var calculationWithForeshoreProfileAndOutput = new TestCalculationWithForeshoreProfile(true)
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = foreshoreProfile
+ }
+ };
+ var calculationWithForeshoreProfile = new TestCalculationWithForeshoreProfile(false)
+ {
+ InputParameters =
+ {
+ ForeshoreProfile = foreshoreProfile
+ }
+ };
+ var calculationWithoutForeshoreProfile = new TestCalculationWithForeshoreProfile(false);
- // Pre-condition
- CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
+ var calculations = new List>
+ {
+ calculationWithForeshoreProfileAndOutput,
+ calculationWithForeshoreProfile,
+ calculationWithoutForeshoreProfile
+ };
- // Call
- IEnumerable affectedObjects = RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(failureMechanism);
+ var calculationsWithForeshoreProfile = new[]
+ {
+ calculationWithForeshoreProfileAndOutput,
+ calculationWithForeshoreProfile
+ };
- // Assert
- // Note: To make sure the clear is performed regardless of what is done with
- // the return result, no ToArray() should be called before these assertions:
- CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
-
- IEnumerable expectedAffectedObjects =
- calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
- .Concat(new IObservable[]
- {
- failureMechanism.ForeshoreProfiles
- });
- CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
- }
-
- [Test]
- public void RemoveAllForeshoreProfile_HeightStructuresFailureMechanismNull_ThrowsArgumentNullException()
- {
// Call
- TestDelegate call = () => RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles((HeightStructuresFailureMechanism) null);
+ IEnumerable affectedObjects = RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(calculations, foreshoreProfiles);
// Assert
- var exception = Assert.Throws(call);
- Assert.AreEqual("failureMechanism", exception.ParamName);
- }
-
- [Test]
- public void RemoveAllForeshoreProfile_FullyConfiguredHeightStructuresFailureMechanism_RemovesAllForeshoreProfilesAndDependentData()
- {
- // Setup
- HeightStructuresFailureMechanism failureMechanism = TestDataGenerator.GetHeightStructuresFailureMechanismWithAlLCalculationConfigurations();
-
- StructuresCalculation[] calculationsWithForeshoreProfiles = failureMechanism.Calculations
- .Cast>()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null)
- .ToArray();
-
- // Pre-condition
- CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
-
- // Call
- IEnumerable affectedObjects = RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(failureMechanism);
-
- // Assert
// Note: To make sure the clear is performed regardless of what is done with
// the return result, no ToArray() should be called before these assertions:
- CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
+ CollectionAssert.IsEmpty(foreshoreProfiles);
- IEnumerable expectedAffectedObjects =
- calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
- .Concat(new IObservable[]
- {
- failureMechanism.ForeshoreProfiles
- });
- CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
- }
+ CollectionAssert.IsEmpty(foreshoreProfiles);
+ Assert.IsFalse(calculationWithForeshoreProfileAndOutput.HasOutput);
+ Assert.IsTrue(calculationsWithForeshoreProfile.All(calc => calc.InputParameters.ForeshoreProfile == null));
- [Test]
- public void RemoveAllForeshoreProfile_GrassCoverErosionOutwardsFailureMechanismNull_ThrowsArgumentNullException()
- {
- // Call
- TestDelegate call = () => RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles((GrassCoverErosionOutwardsFailureMechanism) null);
-
- // Assert
- var exception = Assert.Throws(call);
- Assert.AreEqual("failureMechanism", exception.ParamName);
- }
-
- [Test]
- public void RemoveAllForeshoreProfile_FullyConfiguredGrassCoverErosionOutwardsFailureMechanism_RemovesAllForeshoreProfilesAndDependentData()
- {
- // Setup
- GrassCoverErosionOutwardsFailureMechanism failureMechanism = TestDataGenerator.GetGrassCoverErosionOutwardsFailureMechanismWithAllCalculationConfigurations();
-
- GrassCoverErosionOutwardsWaveConditionsCalculation[] calculationsWithForeshoreProfiles = failureMechanism.Calculations
- .Cast()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null)
- .ToArray();
-
- // Pre-condition
- CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
-
- // Call
- IEnumerable affectedObjects = RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(failureMechanism);
-
- // Assert
- // Note: To make sure the clear is performed regardless of what is done with
- // the return result, no ToArray() should be called before these assertions:
- CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
-
IEnumerable expectedAffectedObjects =
- calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
- .Concat(new IObservable[]
- {
- failureMechanism.ForeshoreProfiles
- });
+ calculationsWithForeshoreProfile.Select(calc => calc.InputParameters)
+ .Concat(new IObservable[]
+ {
+ foreshoreProfiles,
+ calculationWithForeshoreProfileAndOutput
+ });
CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
}
[Test]
- public void RemoveAllForeshoreProfile_StabilityStoneCoverFailureMechanismNull_ThrowsArgumentNullException()
- {
- // Call
- TestDelegate call = () => RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles((StabilityStoneCoverFailureMechanism) null);
-
- // Assert
- var exception = Assert.Throws(call);
- Assert.AreEqual("failureMechanism", exception.ParamName);
- }
-
- [Test]
- public void RemoveAllForeshoreProfile_FullyConfiguredStabilityStoneCoverFailureMechanism_RemovesAllForeshoreProfilesAndDependentData()
- {
- // Setup
- StabilityStoneCoverFailureMechanism failureMechanism = TestDataGenerator.GetStabilityStoneCoverFailureMechanismWithAllCalculationConfigurations();
-
- StabilityStoneCoverWaveConditionsCalculation[] calculationsWithForeshoreProfiles = failureMechanism.Calculations
- .Cast()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null)
- .ToArray();
-
- // Pre-condition
- CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
-
- // Call
- IEnumerable affectedObjects = RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(failureMechanism);
-
- // Assert
- // Note: To make sure the clear is performed regardless of what is done with
- // the return result, no ToArray() should be called before these assertions:
- CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
-
- IEnumerable expectedAffectedObjects =
- calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
- .Concat(new IObservable[]
- {
- failureMechanism.ForeshoreProfiles
- });
- CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
- }
-
- [Test]
- public void RemoveAllForeshoreProfile_WaveImpactAsphaltCoverFailureMechanismNull_ThrowsArgumentNullException()
- {
- // Call
- TestDelegate call = () => RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles((WaveImpactAsphaltCoverFailureMechanism) null);
-
- // Assert
- var exception = Assert.Throws(call);
- Assert.AreEqual("failureMechanism", exception.ParamName);
- }
-
- [Test]
- public void RemoveAllForeshoreProfile_FullyConfiguredWaveImpactAsphaltCoverFailureMechanism_RemovesAllForeshoreProfilesAndDependentData()
- {
- // Setup
- WaveImpactAsphaltCoverFailureMechanism failureMechanism = TestDataGenerator.GetWaveImpactAsphaltCoverFailureMechanismWithAllCalculationConfigurations();
-
- WaveImpactAsphaltCoverWaveConditionsCalculation[] calculationsWithForeshoreProfiles = failureMechanism.Calculations
- .Cast()
- .Where(calc => calc.InputParameters.ForeshoreProfile != null)
- .ToArray();
-
- // Pre-condition
- CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
-
- // Call
- IEnumerable affectedObjects = RingtoetsDataSynchronizationService.RemoveAllForeshoreProfiles(failureMechanism);
-
- // Assert
- // Note: To make sure the clear is performed regardless of what is done with
- // the return result, no ToArray() should be called before these assertions:
- CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
-
- IEnumerable expectedAffectedObjects =
- calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
- .Concat(new IObservable[]
- {
- failureMechanism.ForeshoreProfiles
- });
- CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
- }
-
- [Test]
public void RemoveDikeProfile_GrassCoverErosionInwardsFailureMechanismNull_ThrowsArgumentNullException()
{
// Setup
@@ -1757,6 +1592,46 @@
return hydraulicBoundaryLocation.DesignWaterLevelOutput != null || hydraulicBoundaryLocation.WaveHeightOutput != null;
}
+ private class TestCalculationWithForeshoreProfile : Observable, ICalculation
+ {
+ public TestCalculationWithForeshoreProfile(bool hasOutput)
+ {
+ InputParameters = new TestCalculationInputWithForeshoreProfile();
+ HasOutput = hasOutput;
+ }
+
+ public string Name { get; set; }
+ public bool HasOutput { get; private set; }
+ public Comment Comments { get; }
+
+ public TestCalculationInputWithForeshoreProfile InputParameters { get; }
+
+ public void ClearOutput()
+ {
+ HasOutput = false;
+ }
+ }
+
+ private class TestCalculationInputWithForeshoreProfile : ICalculationInput, IHasForeshoreProfile
+ {
+ public ForeshoreProfile ForeshoreProfile { get; set; }
+
+ public void Attach(IObserver observer)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void Detach(IObserver observer)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void NotifyObservers()
+ {
+ throw new NotImplementedException();
+ }
+ }
+
#region TestData
private static IEnumerable GetGrassAndDuneLocations(string testName)
Index: Ringtoets/Integration/test/Ringtoets.Integration.Test/FileImporters/ForeshoreProfileReplaceDataStrategyIntegrationTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Test/FileImporters/ForeshoreProfileReplaceDataStrategyIntegrationTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Test/FileImporters/ForeshoreProfileReplaceDataStrategyIntegrationTest.cs (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -0,0 +1,307 @@
+// 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.Base;
+using NUnit.Framework;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.Structures;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.HeightStructures.Data;
+using Ringtoets.Integration.Plugin.FileImporters;
+using Ringtoets.Integration.TestUtils;
+using Ringtoets.StabilityPointStructures.Data;
+using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.WaveImpactAsphaltCover.Data;
+
+namespace Ringtoets.Integration.Test.FileImporters
+{
+ [TestFixture]
+ public class ForeshoreProfileReplaceDataStrategyIntegrationTest
+ {
+ private const string sourceFilePath = "path/to/foreshoreProfiles";
+
+ [Test]
+ public void UpdateForeshoreProfilesWithImportedData_WaveImpactAsphaltCoverCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ {
+ // Setup
+ WaveImpactAsphaltCoverFailureMechanism failureMechanism =
+ TestDataGenerator.GetWaveImpactAsphaltCoverFailureMechanismWithAllCalculationConfigurations();
+
+ WaveImpactAsphaltCoverWaveConditionsCalculation[] calculationsWithForeshoreProfiles =
+ failureMechanism.Calculations
+ .Cast()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null)
+ .ToArray();
+
+ WaveImpactAsphaltCoverWaveConditionsCalculation[] calculationsWithOutput =
+ calculationsWithForeshoreProfiles.Where(calc => calc.HasOutput)
+ .ToArray();
+
+ // Precondition
+ CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
+
+ var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism, failureMechanism.ForeshoreProfiles);
+
+ // Call
+ IEnumerable affectedObjects =
+ strategy.UpdateForeshoreProfilesWithImportedData(failureMechanism.ForeshoreProfiles,
+ Enumerable.Empty(),
+ sourceFilePath);
+
+ // Assert
+ Assert.IsFalse(calculationsWithOutput.All(calc => calc.HasOutput));
+ Assert.IsTrue(calculationsWithForeshoreProfiles.All(calc => calc.InputParameters
+ .ForeshoreProfile == null));
+ CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
+
+ IEnumerable expectedAffectedObjects =
+ calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
+ .Concat(new IObservable[]
+ {
+ failureMechanism.ForeshoreProfiles
+ }
+ .Concat(calculationsWithOutput));
+ CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
+ }
+
+ [Test]
+ public void UpdateForeshoreProfilesWithImportedData_GrassCoverErosionOutwardsCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ {
+ // Setup
+ GrassCoverErosionOutwardsFailureMechanism failureMechanism =
+ TestDataGenerator.GetGrassCoverErosionOutwardsFailureMechanismWithAllCalculationConfigurations();
+
+ GrassCoverErosionOutwardsWaveConditionsCalculation[] calculationsWithForeshoreProfiles =
+ failureMechanism.Calculations
+ .Cast()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null)
+ .ToArray();
+
+ GrassCoverErosionOutwardsWaveConditionsCalculation[] calculationsWithOutput =
+ calculationsWithForeshoreProfiles.Where(calc => calc.HasOutput)
+ .ToArray();
+
+ // Precondition
+ CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
+
+ var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism, failureMechanism.ForeshoreProfiles);
+
+ // Call
+ IEnumerable affectedObjects =
+ strategy.UpdateForeshoreProfilesWithImportedData(failureMechanism.ForeshoreProfiles,
+ Enumerable.Empty(),
+ sourceFilePath);
+
+ // Assert
+ Assert.IsFalse(calculationsWithOutput.All(calc => calc.HasOutput));
+ Assert.IsTrue(calculationsWithForeshoreProfiles.All(calc => calc.InputParameters
+ .ForeshoreProfile == null));
+ CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
+
+ IEnumerable expectedAffectedObjects =
+ calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
+ .Concat(new IObservable[]
+ {
+ failureMechanism.ForeshoreProfiles
+ }
+ .Concat(calculationsWithOutput));
+ CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
+ }
+
+ [Test]
+ public void UpdateForeshoreProfilesWithImportedData_StabilityStoneCoverCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ {
+ // Setup
+ StabilityStoneCoverFailureMechanism failureMechanism =
+ TestDataGenerator.GetStabilityStoneCoverFailureMechanismWithAllCalculationConfigurations();
+
+ StabilityStoneCoverWaveConditionsCalculation[] calculationsWithForeshoreProfiles =
+ failureMechanism.Calculations
+ .Cast()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null)
+ .ToArray();
+
+ StabilityStoneCoverWaveConditionsCalculation[] calculationsWithOutput =
+ calculationsWithForeshoreProfiles.Where(calc => calc.HasOutput)
+ .ToArray();
+
+ // Precondition
+ CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
+
+ var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism, failureMechanism.ForeshoreProfiles);
+
+ // Call
+ IEnumerable affectedObjects =
+ strategy.UpdateForeshoreProfilesWithImportedData(failureMechanism.ForeshoreProfiles,
+ Enumerable.Empty(),
+ sourceFilePath);
+
+ // Assert
+ Assert.IsFalse(calculationsWithOutput.All(calc => calc.HasOutput));
+ Assert.IsTrue(calculationsWithForeshoreProfiles.All(calc => calc.InputParameters
+ .ForeshoreProfile == null));
+ CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
+
+ IEnumerable expectedAffectedObjects =
+ calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
+ .Concat(new IObservable[]
+ {
+ failureMechanism.ForeshoreProfiles
+ }
+ .Concat(calculationsWithOutput));
+ CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
+ }
+
+ [Test]
+ public void UpdateForeshoreProfilesWithImportedData_HeightStructuresCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ {
+ // Setup
+ HeightStructuresFailureMechanism failureMechanism =
+ TestDataGenerator.GetHeightStructuresFailureMechanismWithAlLCalculationConfigurations();
+
+ StructuresCalculation[] calculationsWithForeshoreProfiles =
+ failureMechanism.Calculations
+ .Cast>()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null)
+ .ToArray();
+
+ StructuresCalculation[] calculationsWithOutput =
+ calculationsWithForeshoreProfiles.Where(calc => calc.HasOutput)
+ .ToArray();
+
+ // Precondition
+ CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
+
+ var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism, failureMechanism.ForeshoreProfiles);
+
+ // Call
+ IEnumerable affectedObjects =
+ strategy.UpdateForeshoreProfilesWithImportedData(failureMechanism.ForeshoreProfiles,
+ Enumerable.Empty(),
+ sourceFilePath);
+
+ // Assert
+ Assert.IsFalse(calculationsWithOutput.All(calc => calc.HasOutput));
+ Assert.IsTrue(calculationsWithForeshoreProfiles.All(calc => calc.InputParameters
+ .ForeshoreProfile == null));
+ CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
+
+ IEnumerable expectedAffectedObjects =
+ calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
+ .Concat(new IObservable[]
+ {
+ failureMechanism.ForeshoreProfiles
+ }
+ .Concat(calculationsWithOutput));
+ CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
+ }
+
+ [Test]
+ public void UpdateForeshoreProfilesWithImportedData_StabilityPointStructuresCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ {
+ // Setup
+ StabilityPointStructuresFailureMechanism failureMechanism =
+ TestDataGenerator.GetStabilityPointStructuresFailureMechanismWithAllCalculationConfigurations();
+
+ StructuresCalculation[] calculationsWithForeshoreProfiles =
+ failureMechanism.Calculations
+ .Cast>()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null)
+ .ToArray();
+
+ StructuresCalculation[] calculationsWithOutput =
+ calculationsWithForeshoreProfiles.Where(calc => calc.HasOutput)
+ .ToArray();
+
+ // Precondition
+ CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
+
+ var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism, failureMechanism.ForeshoreProfiles);
+
+ // Call
+ IEnumerable affectedObjects =
+ strategy.UpdateForeshoreProfilesWithImportedData(failureMechanism.ForeshoreProfiles,
+ Enumerable.Empty(),
+ sourceFilePath);
+
+ // Assert
+ Assert.IsFalse(calculationsWithOutput.All(calc => calc.HasOutput));
+ Assert.IsTrue(calculationsWithForeshoreProfiles.All(calc => calc.InputParameters
+ .ForeshoreProfile == null));
+ CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
+
+ IEnumerable expectedAffectedObjects =
+ calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
+ .Concat(new IObservable[]
+ {
+ failureMechanism.ForeshoreProfiles
+ }
+ .Concat(calculationsWithOutput));
+ CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
+ }
+
+ [Test]
+ public void UpdateForeshoreProfilesWithImportedData_ClosingStructuresCalculationWithForeshoreProfile_CalculationUpdatedAndReturnsAffectedData()
+ {
+ // Setup
+ ClosingStructuresFailureMechanism failureMechanism =
+ TestDataGenerator.GetClosingStructuresFailureMechanismWithAllCalculationConfigurations();
+
+ StructuresCalculation[] calculationsWithForeshoreProfiles =
+ failureMechanism.Calculations
+ .Cast>()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null)
+ .ToArray();
+
+ StructuresCalculation[] calculationsWithOutput =
+ calculationsWithForeshoreProfiles.Where(calc => calc.HasOutput)
+ .ToArray();
+
+ // Precondition
+ CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfiles);
+
+ var strategy = new ForeshoreProfileReplaceDataStrategy(failureMechanism, failureMechanism.ForeshoreProfiles);
+
+ // Call
+ IEnumerable affectedObjects =
+ strategy.UpdateForeshoreProfilesWithImportedData(failureMechanism.ForeshoreProfiles,
+ Enumerable.Empty(),
+ sourceFilePath);
+
+ // Assert
+ Assert.IsTrue(calculationsWithOutput.All(calc => calc.HasOutput == false));
+ Assert.IsTrue(calculationsWithForeshoreProfiles.All(calc => calc.InputParameters
+ .ForeshoreProfile == null));
+ CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles);
+
+ IEnumerable expectedAffectedObjects =
+ calculationsWithForeshoreProfiles.Select(calc => calc.InputParameters)
+ .Concat(new IObservable[]
+ {
+ failureMechanism.ForeshoreProfiles
+ }).Concat(calculationsWithOutput);
+ CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Test/Ringtoets.Integration.Test.csproj
===================================================================
diff -u -r570695e818fcf887563710ad6d26df301be56227 -r9b0af3f940ae57b373ab4edfd7da944090255fde
--- Ringtoets/Integration/test/Ringtoets.Integration.Test/Ringtoets.Integration.Test.csproj (.../Ringtoets.Integration.Test.csproj) (revision 570695e818fcf887563710ad6d26df301be56227)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Test/Ringtoets.Integration.Test.csproj (.../Ringtoets.Integration.Test.csproj) (revision 9b0af3f940ae57b373ab4edfd7da944090255fde)
@@ -59,6 +59,7 @@
Properties\GlobalAssembly.cs
+
@@ -81,6 +82,14 @@
{d749ee4c-ce50-4c17-bf01-9a953028c126}
Core.Common.TestUtil
+
+ {C6309704-D67B-434C-BC98-9F8910BC1D10}
+ Ringtoets.ClosingStructures.Data
+
+
+ {F5B43C29-6169-4E9A-859E-09090330B94E}
+ Ringtoets.ClosingStructures.Data.TestUtil
+
{d4200f43-3f72-4f42-af0a-8ced416a38ec}
Ringtoets.Common.Data
@@ -89,6 +98,22 @@
{52ba7627-cbab-4209-be77-3b5f31378277}
Ringtoets.Common.IO
+
+ {4843D6E5-066F-4795-94F5-1D53932DD03C}
+ Ringtoets.Common.Data.TestUtil
+
+
+ {E7225477-577F-4A17-B7EC-6721158E1543}
+ Ringtoets.GrassCoverErosionOutwards.Data
+
+
+ {1C0017D8-35B5-4CA0-8FC7-A83F46DBDC99}
+ Ringtoets.HeightStructures.Data
+
+
+ {F67E8AE8-1FF0-4680-9817-99E025CD9FF6}
+ Ringtoets.HeightStructures.Data.TestUtil
+
{ce994cc9-6f6a-48ac-b4be-02c30a21f4db}
Ringtoets.Piping.Data
@@ -97,6 +122,30 @@
{14c6f716-64e2-4bc4-a1ef-05865fcefa4c}
Ringtoets.Piping.Primitives
+
+ {87c2c553-c0bc-40bf-b1ea-b83bff357f27}
+ Ringtoets.Revetment.Data
+
+
+ {3706200E-48C6-4B86-B48C-4E45C69ABE95}
+ Ringtoets.Revetment.Data.TestUtil
+
+
+ {3D4B9740-8348-4434-8D77-B611FC6EE57F}
+ Ringtoets.StabilityPointStructures.Data
+
+
+ {E9AC095B-8F10-41D2-9456-4A85E3BA91AD}
+ Ringtoets.StabilityPointStructures.Data.TestUtil
+
+
+ {B479E3AF-7C34-488C-BB73-D324100D36C9}
+ Ringtoets.StabilityStoneCover.Data
+
+
+ {567E0B69-5280-41CE-ADD6-443725A61C86}
+ Ringtoets.WaveImpactAsphaltCover.Data
+
{11f1f874-45af-43e4-8ae5-15a5c9593e28}
Ringtoets.Integration.Data
@@ -110,6 +159,7 @@
Ringtoets.Integration.TestUtils
+