Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj
===================================================================
diff -u -r5a890dc1600bd7e5e060405df22c757daaedd885 -r4c24ea3c9af887e9eb124d76fc87bdadcc75f3e7
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 5a890dc1600bd7e5e060405df22c757daaedd885)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.Plugin.Test.csproj) (revision 4c24ea3c9af887e9eb124d76fc87bdadcc75f3e7)
@@ -53,6 +53,7 @@
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/UpdateInfos/GrassCoverErosionInwardsFailureMechanismSectionsContextUpdateInfoTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/UpdateInfos/GrassCoverErosionInwardsFailureMechanismSectionsContextUpdateInfoTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/UpdateInfos/GrassCoverErosionInwardsFailureMechanismSectionsContextUpdateInfoTest.cs (revision 4c24ea3c9af887e9eb124d76fc87bdadcc75f3e7)
@@ -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.GrassCoverErosionInwards.Data;
+using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.GrassCoverErosionInwards.Plugin.Test.UpdateInfos
+{
+ [TestFixture]
+ public class GrassCoverErosionInwardsFailureMechanismSectionsContextUpdateInfoTest
+ {
+ [Test]
+ public void Name_Always_ReturnExpectedName()
+ {
+ // Setup
+ using (var plugin = new GrassCoverErosionInwardsPlugin())
+ {
+ 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 GrassCoverErosionInwardsPlugin())
+ {
+ 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 GrassCoverErosionInwardsPlugin())
+ {
+ 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 GrassCoverErosionInwardsFailureMechanism();
+
+ string sourcePath = TestHelper.GetScratchPadPath();
+ failureMechanism.SetSections(Enumerable.Empty(), sourcePath);
+ var context = new GrassCoverErosionInwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new GrassCoverErosionInwardsPlugin())
+ {
+ 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 GrassCoverErosionInwardsFailureMechanism();
+ var context = new GrassCoverErosionInwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new GrassCoverErosionInwardsPlugin())
+ {
+ 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 GrassCoverErosionInwardsPlugin())
+ {
+ 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 GrassCoverErosionInwardsFailureMechanism();
+ var context = new GrassCoverErosionInwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new GrassCoverErosionInwardsPlugin())
+ {
+ 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 GrassCoverErosionInwardsFailureMechanism();
+
+ string sourcePath = TestHelper.GetScratchPadPath();
+ failureMechanism.SetSections(Enumerable.Empty(), sourcePath);
+ var context = new GrassCoverErosionInwardsFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new GrassCoverErosionInwardsPlugin())
+ {
+ UpdateInfo updateInfo = GetUpdateInfo(plugin);
+
+ // Call
+ string currentFilePath = updateInfo.CurrentPath(context);
+
+ // Assert
+ Assert.AreEqual(sourcePath, currentFilePath);
+ mocks.VerifyAll();
+ }
+ }
+
+ private static UpdateInfo GetUpdateInfo(GrassCoverErosionInwardsPlugin plugin)
+ {
+ return plugin.GetUpdateInfos().First(ii => ii.DataType == typeof(GrassCoverErosionInwardsFailureMechanismSectionsContext));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/FileImporters/StabilityStoneCoverFailureMechanismSectionResultUpdateStrategy.cs
===================================================================
diff -u -rd7ee65107ab167be11bedb03745684bb0960dc98 -r4c24ea3c9af887e9eb124d76fc87bdadcc75f3e7
--- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/FileImporters/StabilityStoneCoverFailureMechanismSectionResultUpdateStrategy.cs (.../StabilityStoneCoverFailureMechanismSectionResultUpdateStrategy.cs) (revision d7ee65107ab167be11bedb03745684bb0960dc98)
+++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/FileImporters/StabilityStoneCoverFailureMechanismSectionResultUpdateStrategy.cs (.../StabilityStoneCoverFailureMechanismSectionResultUpdateStrategy.cs) (revision 4c24ea3c9af887e9eb124d76fc87bdadcc75f3e7)
@@ -29,7 +29,8 @@
/// An update strategy that can be used to update a instance with data
/// from an old instance.
///
- public class StabilityStoneCoverFailureMechanismSectionResultUpdateStrategy : IFailureMechanismSectionResultUpdateStrategy
+ public class StabilityStoneCoverFailureMechanismSectionResultUpdateStrategy
+ : IFailureMechanismSectionResultUpdateStrategy
{
public void UpdateSectionResult(StabilityStoneCoverFailureMechanismSectionResult origin, StabilityStoneCoverFailureMechanismSectionResult target)
{
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/Ringtoets.StabilityStoneCover.Plugin.Test.csproj
===================================================================
diff -u -rd7ee65107ab167be11bedb03745684bb0960dc98 -r4c24ea3c9af887e9eb124d76fc87bdadcc75f3e7
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/Ringtoets.StabilityStoneCover.Plugin.Test.csproj (.../Ringtoets.StabilityStoneCover.Plugin.Test.csproj) (revision d7ee65107ab167be11bedb03745684bb0960dc98)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/Ringtoets.StabilityStoneCover.Plugin.Test.csproj (.../Ringtoets.StabilityStoneCover.Plugin.Test.csproj) (revision 4c24ea3c9af887e9eb124d76fc87bdadcc75f3e7)
@@ -42,6 +42,7 @@
+
Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/UpdateInfos/StabilityStoneCoverFailureMechanismSectionsContextUpdateInfoTest.cs
===================================================================
diff -u
--- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/UpdateInfos/StabilityStoneCoverFailureMechanismSectionsContextUpdateInfoTest.cs (revision 0)
+++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/UpdateInfos/StabilityStoneCoverFailureMechanismSectionsContextUpdateInfoTest.cs (revision 4c24ea3c9af887e9eb124d76fc87bdadcc75f3e7)
@@ -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.StabilityStoneCover.Data;
+using Ringtoets.StabilityStoneCover.Forms.PresentationObjects;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.StabilityStoneCover.Plugin.Test.UpdateInfos
+{
+ [TestFixture]
+ public class StabilityStoneCoverFailureMechanismSectionsContextUpdateInfoTest
+ {
+ [Test]
+ public void Name_Always_ReturnExpectedName()
+ {
+ // Setup
+ using (var plugin = new StabilityStoneCoverPlugin())
+ {
+ 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 StabilityStoneCoverPlugin())
+ {
+ 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 StabilityStoneCoverPlugin())
+ {
+ 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 StabilityStoneCoverFailureMechanism();
+
+ string sourcePath = TestHelper.GetScratchPadPath();
+ failureMechanism.SetSections(Enumerable.Empty(), sourcePath);
+ var context = new StabilityStoneCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new StabilityStoneCoverPlugin())
+ {
+ 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 StabilityStoneCoverFailureMechanism();
+ var context = new StabilityStoneCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new StabilityStoneCoverPlugin())
+ {
+ 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 StabilityStoneCoverPlugin())
+ {
+ 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 StabilityStoneCoverFailureMechanism();
+ var context = new StabilityStoneCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new StabilityStoneCoverPlugin())
+ {
+ 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 StabilityStoneCoverFailureMechanism();
+
+ string sourcePath = TestHelper.GetScratchPadPath();
+ failureMechanism.SetSections(Enumerable.Empty(), sourcePath);
+ var context = new StabilityStoneCoverFailureMechanismSectionsContext(failureMechanism, assessmentSection);
+
+ using (var plugin = new StabilityStoneCoverPlugin())
+ {
+ UpdateInfo updateInfo = GetUpdateInfo(plugin);
+
+ // Call
+ string currentFilePath = updateInfo.CurrentPath(context);
+
+ // Assert
+ Assert.AreEqual(sourcePath, currentFilePath);
+ mocks.VerifyAll();
+ }
+ }
+
+ private static UpdateInfo GetUpdateInfo(StabilityStoneCoverPlugin plugin)
+ {
+ return plugin.GetUpdateInfos().First(ii => ii.DataType == typeof(StabilityStoneCoverFailureMechanismSectionsContext));
+ }
+ }
+}
\ No newline at end of file