Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporters/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy.cs (revision 5a890dc1600bd7e5e060405df22c757daaedd885)
@@ -0,0 +1,55 @@
+// 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;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.GrassCoverErosionInwards.Data;
+
+namespace Ringtoets.GrassCoverErosionInwards.Plugin.FileImporters
+{
+ ///
+ /// An update strategy that can be used to update a instance with data
+ /// from an old instance.
+ ///
+ public class GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy : IFailureMechanismSectionResultUpdateStrategy
+ {
+ public void UpdateSectionResult(GrassCoverErosionInwardsFailureMechanismSectionResult origin, GrassCoverErosionInwardsFailureMechanismSectionResult target)
+ {
+ if (origin == null)
+ {
+ throw new ArgumentNullException(nameof(origin));
+ }
+
+ if (target == null)
+ {
+ throw new ArgumentNullException(nameof(target));
+ }
+
+ target.Calculation = origin.Calculation;
+ target.SimpleAssessmentResult = origin.SimpleAssessmentResult;
+ target.DetailedAssessmentResult = origin.DetailedAssessmentResult;
+ target.TailorMadeAssessmentResult = origin.TailorMadeAssessmentResult;
+ target.TailorMadeAssessmentProbability = origin.TailorMadeAssessmentProbability;
+ target.UseManualAssemblyProbability = origin.UseManualAssemblyProbability;
+ target.ManualAssemblyProbability = origin.ManualAssemblyProbability;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs
===================================================================
diff -u -r21ee838997690c7f1cdc9eaf5089e309aa4291d6 -r5a890dc1600bd7e5e060405df22c757daaedd885
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 21ee838997690c7f1cdc9eaf5089e309aa4291d6)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 5a890dc1600bd7e5e060405df22c757daaedd885)
@@ -39,6 +39,7 @@
using Ringtoets.Common.Forms.ImportInfos;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.TreeNodeInfos;
+using Ringtoets.Common.Forms.UpdateInfos;
using Ringtoets.Common.IO.FileImporters;
using Ringtoets.Common.IO.FileImporters.MessageProviders;
using Ringtoets.Common.Plugin;
@@ -151,6 +152,10 @@
VerifyUpdates = context => VerifyDikeProfilesShouldUpdate(context,
Resources.GrassCoverErosionInwardsPlugin_VerifyDikeProfileUpdate_When_updating_Calculation_with_DikeProfile_data_output_will_be_cleared_confirm)
};
+
+ yield return RingtoetsUpdateInfoFactory.CreateFailureMechanismSectionsUpdateInfo<
+ GrassCoverErosionInwardsFailureMechanismSectionsContext, GrassCoverErosionInwardsFailureMechanism, GrassCoverErosionInwardsFailureMechanismSectionResult>(
+ new GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy());
}
public override IEnumerable GetExportInfos()
@@ -535,7 +540,7 @@
{
return new object[]
{
- new GrassCoverErosionInwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection),
+ new GrassCoverErosionInwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection),
new DikeProfilesContext(failureMechanism.DikeProfiles, failureMechanism, assessmentSection),
failureMechanism.InputComments
};
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj
===================================================================
diff -u -rfcad48d7beb394e1ac15cfe4289a7381e05aa883 -r5a890dc1600bd7e5e060405df22c757daaedd885
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.csproj) (revision fcad48d7beb394e1ac15cfe4289a7381e05aa883)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/Ringtoets.GrassCoverErosionInwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.csproj) (revision 5a890dc1600bd7e5e060405df22c757daaedd885)
@@ -15,6 +15,7 @@
+
@@ -84,6 +85,11 @@
Ringtoets.Common.Plugin
False
+
+ {78AA56F5-431D-465C-AC50-3173D7E90AC1}
+ Ringtoets.Common.Primitives
+ False
+
{d951d6da-fe83-4920-9fdb-63bf96480b54}
Ringtoets.Common.Service
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategyTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategyTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporters/GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategyTest.cs (revision 5a890dc1600bd7e5e060405df22c757daaedd885)
@@ -0,0 +1,107 @@
+// 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;
+using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.Common.Primitives;
+using Ringtoets.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Plugin.FileImporters;
+
+namespace Ringtoets.GrassCoverErosionInwards.Plugin.Test.FileImporters
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategyTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var strategy = new GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy();
+
+ // Assert
+ Assert.IsInstanceOf>(strategy);
+ }
+
+ [Test]
+ public void UpdateSectionResult_OriginNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var strategy = new GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy();
+
+ // Call
+ TestDelegate test = () => strategy.UpdateSectionResult(
+ null, new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()));
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("origin", paramName);
+ }
+
+ [Test]
+ public void UpdateSectionResult_TargetNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var strategy = new GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy();
+
+ // Call
+ TestDelegate test = () => strategy.UpdateSectionResult(
+ new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), null);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("target", paramName);
+ }
+
+ [Test]
+ public void UpdateSectionResult_WithData_UpdatesTargetSectionResult()
+ {
+ // Setup
+ var random = new Random(39);
+ var strategy = new GrassCoverErosionInwardsFailureMechanismSectionResultUpdateStrategy();
+ var originResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ Calculation = new GrassCoverErosionInwardsCalculation(),
+ SimpleAssessmentResult = SimpleAssessmentValidityOnlyResultType.NotApplicable,
+ DetailedAssessmentResult = DetailedAssessmentProbabilityOnlyResultType.NotAssessed,
+ TailorMadeAssessmentResult = TailorMadeAssessmentProbabilityCalculationResultType.Probability,
+ TailorMadeAssessmentProbability = random.NextDouble(),
+ UseManualAssemblyProbability = true,
+ ManualAssemblyProbability = random.NextDouble()
+ };
+ var targetResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ // Call
+ strategy.UpdateSectionResult(originResult, targetResult);
+
+ // Assert
+ Assert.AreSame(originResult.Calculation, targetResult.Calculation);
+ Assert.AreEqual(originResult.SimpleAssessmentResult, targetResult.SimpleAssessmentResult);
+ Assert.AreEqual(originResult.DetailedAssessmentResult, targetResult.DetailedAssessmentResult);
+ Assert.AreEqual(originResult.TailorMadeAssessmentResult, targetResult.TailorMadeAssessmentResult);
+ Assert.AreEqual(originResult.TailorMadeAssessmentProbability, targetResult.TailorMadeAssessmentProbability);
+ Assert.AreEqual(originResult.UseManualAssemblyProbability, targetResult.UseManualAssemblyProbability);
+ Assert.AreEqual(originResult.ManualAssemblyProbability, targetResult.ManualAssemblyProbability);
+ Assert.AreNotSame(originResult.Section, targetResult.Section);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs
===================================================================
diff -u -r73bb4932d13d36d1cd3cd30d8151f2adf49646f2 -r5a890dc1600bd7e5e060405df22c757daaedd885
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs (.../GrassCoverErosionInwardsPluginTest.cs) (revision 73bb4932d13d36d1cd3cd30d8151f2adf49646f2)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs (.../GrassCoverErosionInwardsPluginTest.cs) (revision 5a890dc1600bd7e5e060405df22c757daaedd885)
@@ -193,8 +193,9 @@
UpdateInfo[] updateInfos = plugin.GetUpdateInfos().ToArray();
// Assert
- Assert.AreEqual(1, updateInfos.Length);
+ Assert.AreEqual(2, updateInfos.Length);
Assert.IsTrue(updateInfos.Any(i => i.DataType == typeof(DikeProfilesContext)));
+ Assert.IsTrue(updateInfos.Any(i => i.DataType == typeof(GrassCoverErosionInwardsFailureMechanismSectionsContext)));
}
}
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj
===================================================================
diff -u -re63b47a8282dfc596cc2dbe89bd8ffb501b0b326 -r5a890dc1600bd7e5e060405df22c757daaedd885
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision e63b47a8282dfc596cc2dbe89bd8ffb501b0b326)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 5a890dc1600bd7e5e060405df22c757daaedd885)
@@ -29,6 +29,7 @@
+
@@ -129,6 +130,10 @@
{52ba7627-cbab-4209-be77-3b5f31378277}
Ringtoets.Common.IO
+
+ {78AA56F5-431D-465C-AC50-3173D7E90AC1}
+ Ringtoets.Common.Primitives
+
{4843D6E5-066F-4795-94F5-1D53932DD03C}
Ringtoets.Common.Data.TestUtil