Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/FileImporters/GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/FileImporters/GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy.cs (revision 0)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/FileImporters/GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy.cs (revision 3e77cae3d2a991e50ee6545f4de36ff84285e754)
@@ -0,0 +1,58 @@
+// 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.GrassCoverErosionOutwards.Data;
+
+namespace Ringtoets.GrassCoverErosionOutwards.Plugin.FileImporters
+{
+ ///
+ /// An update strategy that can be used to update a instance with data
+ /// from an old instance.
+ ///
+ public class GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy
+ : IFailureMechanismSectionResultUpdateStrategy
+ {
+ public void UpdateSectionResult(GrassCoverErosionOutwardsFailureMechanismSectionResult origin, GrassCoverErosionOutwardsFailureMechanismSectionResult target)
+ {
+ if (origin == null)
+ {
+ throw new ArgumentNullException(nameof(origin));
+ }
+
+ if (target == null)
+ {
+ throw new ArgumentNullException(nameof(target));
+ }
+
+ target.SimpleAssessmentResult = origin.SimpleAssessmentResult;
+ target.DetailedAssessmentResultForFactorizedSignalingNorm = origin.DetailedAssessmentResultForFactorizedSignalingNorm;
+ target.DetailedAssessmentResultForSignalingNorm = origin.DetailedAssessmentResultForSignalingNorm;
+ target.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm = origin.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm;
+ target.DetailedAssessmentResultForLowerLimitNorm = origin.DetailedAssessmentResultForLowerLimitNorm;
+ target.DetailedAssessmentResultForFactorizedLowerLimitNorm = origin.DetailedAssessmentResultForFactorizedLowerLimitNorm;
+ target.TailorMadeAssessmentResult = origin.TailorMadeAssessmentResult;
+ target.UseManualAssemblyCategoryGroup = origin.UseManualAssemblyCategoryGroup;
+ target.ManualAssemblyCategoryGroup = origin.ManualAssemblyCategoryGroup;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs
===================================================================
diff -u -rd7b4d0cecb153813b95de73ea5abbf8e3307e7c6 -r3e77cae3d2a991e50ee6545f4de36ff84285e754
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision d7b4d0cecb153813b95de73ea5abbf8e3307e7c6)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 3e77cae3d2a991e50ee6545f4de36ff84285e754)
@@ -45,6 +45,7 @@
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.Forms.PropertyClasses;
using Ringtoets.Common.Forms.TreeNodeInfos;
+using Ringtoets.Common.Forms.UpdateInfos;
using Ringtoets.Common.Forms.Views;
using Ringtoets.Common.Plugin;
using Ringtoets.Common.Service;
@@ -55,6 +56,7 @@
using Ringtoets.GrassCoverErosionOutwards.Forms.Views;
using Ringtoets.GrassCoverErosionOutwards.IO.Configurations;
using Ringtoets.GrassCoverErosionOutwards.IO.Exporters;
+using Ringtoets.GrassCoverErosionOutwards.Plugin.FileImporters;
using Ringtoets.GrassCoverErosionOutwards.Plugin.Properties;
using Ringtoets.GrassCoverErosionOutwards.Service;
using Ringtoets.Revetment.Data;
@@ -386,6 +388,13 @@
}, filePath));
}
+ public override IEnumerable GetUpdateInfos()
+ {
+ yield return RingtoetsUpdateInfoFactory.CreateFailureMechanismSectionsUpdateInfo<
+ GrassCoverErosionOutwardsFailureMechanismSectionsContext, GrassCoverErosionOutwardsFailureMechanism, GrassCoverErosionOutwardsFailureMechanismSectionResult>(
+ new GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy());
+ }
+
public override void Activate()
{
base.Activate();
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/Ringtoets.GrassCoverErosionOutwards.Plugin.csproj
===================================================================
diff -u -reffe3cbc48073f4f368b6a72851444ca1a3fec61 -r3e77cae3d2a991e50ee6545f4de36ff84285e754
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/Ringtoets.GrassCoverErosionOutwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionOutwards.Plugin.csproj) (revision effe3cbc48073f4f368b6a72851444ca1a3fec61)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/Ringtoets.GrassCoverErosionOutwards.Plugin.csproj (.../Ringtoets.GrassCoverErosionOutwards.Plugin.csproj) (revision 3e77cae3d2a991e50ee6545f4de36ff84285e754)
@@ -13,6 +13,7 @@
+
@@ -87,6 +88,11 @@
Ringtoets.Common.Plugin
False
+
+ {78AA56F5-431D-465C-AC50-3173D7E90AC1}
+ Ringtoets.Common.Primitives
+ False
+
{D951D6DA-FE83-4920-9FDB-63BF96480B54}
Ringtoets.Common.Service
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/FileImporters/GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategyTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/FileImporters/GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategyTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/FileImporters/GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategyTest.cs (revision 3e77cae3d2a991e50ee6545f4de36ff84285e754)
@@ -0,0 +1,111 @@
+// 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.AssemblyTool.Data;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.Common.Primitives;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.GrassCoverErosionOutwards.Plugin.FileImporters;
+
+namespace Ringtoets.GrassCoverErosionOutwards.Plugin.Test.FileImporters
+{
+ [TestFixture]
+ public class GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategyTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var strategy = new GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy();
+
+ // Assert
+ Assert.IsInstanceOf>(strategy);
+ }
+
+ [Test]
+ public void UpdateSectionResult_OriginNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var strategy = new GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy();
+
+ // Call
+ TestDelegate test = () => strategy.UpdateSectionResult(
+ null, new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()));
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("origin", paramName);
+ }
+
+ [Test]
+ public void UpdateSectionResult_TargetNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var strategy = new GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy();
+
+ // Call
+ TestDelegate test = () => strategy.UpdateSectionResult(
+ new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()), null);
+
+ // Assert
+ string paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("target", paramName);
+ }
+
+ [Test]
+ public void UpdateSectionResult_WithData_UpdatesTargetSectionResult()
+ {
+ // Setup
+ var strategy = new GrassCoverErosionOutwardsFailureMechanismSectionResultUpdateStrategy();
+ var originResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection())
+ {
+ SimpleAssessmentResult = SimpleAssessmentResultType.AssessFurther,
+ DetailedAssessmentResultForFactorizedSignalingNorm = DetailedAssessmentResultType.Sufficient,
+ DetailedAssessmentResultForSignalingNorm = DetailedAssessmentResultType.Sufficient,
+ DetailedAssessmentResultForLowerLimitNorm = DetailedAssessmentResultType.Sufficient,
+ DetailedAssessmentResultForMechanismSpecificLowerLimitNorm = DetailedAssessmentResultType.Sufficient,
+ DetailedAssessmentResultForFactorizedLowerLimitNorm = DetailedAssessmentResultType.Sufficient,
+ TailorMadeAssessmentResult = TailorMadeAssessmentCategoryGroupResultType.IIIv,
+ UseManualAssemblyCategoryGroup = true,
+ ManualAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.VIv
+ };
+ var targetResult = new GrassCoverErosionOutwardsFailureMechanismSectionResult(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ // Call
+ strategy.UpdateSectionResult(originResult, targetResult);
+
+ // Assert
+ Assert.AreEqual(originResult.SimpleAssessmentResult, targetResult.SimpleAssessmentResult);
+ Assert.AreEqual(originResult.DetailedAssessmentResultForFactorizedSignalingNorm, targetResult.DetailedAssessmentResultForFactorizedSignalingNorm);
+ Assert.AreEqual(originResult.DetailedAssessmentResultForSignalingNorm, targetResult.DetailedAssessmentResultForSignalingNorm);
+ Assert.AreEqual(originResult.DetailedAssessmentResultForLowerLimitNorm, targetResult.DetailedAssessmentResultForLowerLimitNorm);
+ Assert.AreEqual(originResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm, targetResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm);
+ Assert.AreEqual(originResult.DetailedAssessmentResultForFactorizedLowerLimitNorm, targetResult.DetailedAssessmentResultForFactorizedLowerLimitNorm);
+ Assert.AreEqual(originResult.TailorMadeAssessmentResult, targetResult.TailorMadeAssessmentResult);
+ Assert.AreEqual(originResult.UseManualAssemblyCategoryGroup, targetResult.UseManualAssemblyCategoryGroup);
+ Assert.AreEqual(originResult.ManualAssemblyCategoryGroup, targetResult.ManualAssemblyCategoryGroup);
+ Assert.AreNotSame(originResult.Section, targetResult.Section);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj
===================================================================
diff -u -r0fc08c66887f3e02384f9de25436d937461cdc0c -r3e77cae3d2a991e50ee6545f4de36ff84285e754
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj) (revision 0fc08c66887f3e02384f9de25436d937461cdc0c)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Plugin.Test.csproj) (revision 3e77cae3d2a991e50ee6545f4de36ff84285e754)
@@ -31,6 +31,7 @@
+
@@ -54,6 +55,7 @@
+
@@ -131,6 +133,10 @@
{52BA7627-CBAB-4209-BE77-3B5F31378277}
Ringtoets.Common.IO
+
+ {78AA56F5-431D-465C-AC50-3173D7E90AC1}
+ Ringtoets.Common.Primitives
+
{D951D6DA-FE83-4920-9FDB-63BF96480B54}
Ringtoets.Common.Service
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/UpdateInfos/GrassCoverErosionOutwardsFailureMechanismSectionsContextUpdateInfoTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/UpdateInfos/GrassCoverErosionOutwardsFailureMechanismSectionsContextUpdateInfoTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Plugin.Test/UpdateInfos/GrassCoverErosionOutwardsFailureMechanismSectionsContextUpdateInfoTest.cs (revision 3e77cae3d2a991e50ee6545f4de36ff84285e754)
@@ -0,0 +1,216 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Linq;
+using Core.Common.Base.IO;
+using Core.Common.Gui.Plugin;
+using Core.Common.TestUtil;
+using Core.Common.Util;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.GrassCoverErosionOutwards.Plugin.Test.UpdateInfos
+{
+ [TestFixture]
+ public class GrassCoverErosionOutwardsFailureMechanismSectionsContextUpdateInfoTest
+ {
+ [Test]
+ public void Name_Always_ReturnExpectedName()
+ {
+ // Setup
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ UpdateInfo importInfo = GetUpdateInfo(plugin);
+
+ // Call
+ string name = importInfo.Name;
+
+ // Assert
+ Assert.AreEqual("Vakindeling", name);
+ }
+ }
+
+ [Test]
+ public void Category_Always_ReturnExpectedCategory()
+ {
+ // Setup
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ UpdateInfo importInfo = GetUpdateInfo(plugin);
+
+ // Call
+ string category = importInfo.Category;
+
+ // Assert
+ Assert.AreEqual("Algemeen", category);
+ }
+ }
+
+ [Test]
+ public void Image_Always_ReturnExpectedIcon()
+ {
+ // Setup
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ UpdateInfo importInfo = GetUpdateInfo(plugin);
+
+ // Call
+ Image image = importInfo.Image;
+
+ // Assert
+ TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.SectionsIcon, image);
+ }
+ }
+
+ [Test]
+ public void IsEnabled_FailureMechanismSectionsSourcePathSet_ReturnTrue()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+
+ string sourcePath = TestHelper.GetScratchPadPath();
+ failureMechanism.SetSections(Enumerable.Empty(), sourcePath);
+ var context = new GrassCoverErosionOutwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ UpdateInfo importInfo = GetUpdateInfo(plugin);
+
+ // Call
+ bool isEnabled = importInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsTrue(isEnabled);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void IsEnabled_FailureMechanismSectionsSourcePathNull_ReturnFalse()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ var context = new GrassCoverErosionOutwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ UpdateInfo importInfo = GetUpdateInfo(plugin);
+
+ // Call
+ bool isEnabled = importInfo.IsEnabled(context);
+
+ // Assert
+ Assert.IsFalse(isEnabled);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void FileFilterGenerator_Always_ReturnExpectedFileFilter()
+ {
+ // Setup
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ UpdateInfo importInfo = GetUpdateInfo(plugin);
+
+ // Call
+ FileFilterGenerator fileFilterGenerator = importInfo.FileFilterGenerator;
+
+ // Assert
+ Assert.AreEqual("Shapebestand (*.shp)|*.shp", fileFilterGenerator.Filter);
+ }
+ }
+
+ [Test]
+ public void CreateFileImporter_WithValidData_ReturnsFileImporter()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ assessmentSection.ReferenceLine = new ReferenceLine();
+ mocks.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ var context = new GrassCoverErosionOutwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ UpdateInfo updateInfo = GetUpdateInfo(plugin);
+
+ // Call
+ IFileImporter importer = updateInfo.CreateFileImporter(context, string.Empty);
+
+ // Assert
+ Assert.IsInstanceOf(importer);
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void CurrentPath_FailureMechanismSectionsSourcePathSet_ReturnsExpectedPath()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+
+ string sourcePath = TestHelper.GetScratchPadPath();
+ failureMechanism.SetSections(Enumerable.Empty(), sourcePath);
+ var context = new GrassCoverErosionOutwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new GrassCoverErosionOutwardsPlugin())
+ {
+ UpdateInfo updateInfo = GetUpdateInfo(plugin);
+
+ // Call
+ string currentFilePath = updateInfo.CurrentPath(context);
+
+ // Assert
+ Assert.AreEqual(sourcePath, currentFilePath);
+ mocks.VerifyAll();
+ }
+ }
+
+ private static UpdateInfo GetUpdateInfo(GrassCoverErosionOutwardsPlugin plugin)
+ {
+ return plugin.GetUpdateInfos().First(ii => ii.DataType == typeof(GrassCoverErosionOutwardsFailureMechanismSectionsContext));
+ }
+ }
+}
\ No newline at end of file