Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/DikeProfilesImporter.cs
===================================================================
diff -u -rd12c953518f14c3d50136775b2c03afdf3a4f8f1 -r4eaa942f6a986a04aacee22d1b8e142b0d07f389
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision d12c953518f14c3d50136775b2c03afdf3a4f8f1)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision 4eaa942f6a986a04aacee22d1b8e142b0d07f389)
@@ -57,7 +57,7 @@
string filePath,
IDikeProfileUpdateDataStrategy dikeProfileUpdateStrategy,
IImporterMessageProvider messageProvider)
- : base(referenceLine, filePath, importTarget, messageProvider)
+ : base(referenceLine, filePath, importTarget, messageProvider, RingtoetsCommonDataResources.DikeProfileCollection_TypeDescriptor)
{
if (dikeProfileUpdateStrategy == null)
{
Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ForeshoreProfilesImporter.cs
===================================================================
diff -u -r1325800e22033161045afc4ab04b73c76585d370 -r4eaa942f6a986a04aacee22d1b8e142b0d07f389
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ForeshoreProfilesImporter.cs (.../ForeshoreProfilesImporter.cs) (revision 1325800e22033161045afc4ab04b73c76585d370)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ForeshoreProfilesImporter.cs (.../ForeshoreProfilesImporter.cs) (revision 4eaa942f6a986a04aacee22d1b8e142b0d07f389)
@@ -30,6 +30,7 @@
using Ringtoets.Common.IO.DikeProfiles;
using Ringtoets.Common.IO.FileImporters.MessageProviders;
using Ringtoets.Common.IO.Properties;
+using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
namespace Ringtoets.Common.IO.FileImporters
{
@@ -46,16 +47,18 @@
///
/// The foreshore profiles to import on.
/// The reference line used to check if the
- /// objects found in the file are intersecting it.
- /// The strategy to update the
- /// foreshore profiles with the imported data.
+ /// objects found in the file are intersecting it.
/// The path to the file to import from.
- /// Thrown when ,
- /// or is null.
- public ForeshoreProfilesImporter(ForeshoreProfileCollection importTarget, ReferenceLine referenceLine,
+ /// The strategy to update the
+ /// foreshore profiles with the imported data.
+ ///
+ /// Thrown when any parameter is null.
+ public ForeshoreProfilesImporter(ForeshoreProfileCollection importTarget,
+ ReferenceLine referenceLine,
+ string filePath,
IForeshoreProfileUpdateDataStrategy foreshoreProfileUpdateStrategy,
- string filePath)
- : base(referenceLine, filePath, importTarget, new ImportMessageProvider())
+ IImporterMessageProvider messageProvider)
+ : base(referenceLine, filePath, importTarget, messageProvider, RingtoetsCommonDataResources.ForeshoreProfileCollection_TypeDescriptor)
{
if (foreshoreProfileUpdateStrategy == null)
{
@@ -87,7 +90,9 @@
protected override void LogImportCanceledMessage()
{
- Log.Info(Resources.ForeshoreProfilesImporter_HandleUserCancelingImport_foreshoreprofile_import_aborted);
+ string logMessage =
+ MessageProvider.GetCancelledLogMessageText(RingtoetsCommonDataResources.ForeshoreProfileCollection_TypeDescriptor);
+ Log.Info(logMessage);
}
protected override bool DikeProfileDataIsValid(DikeProfileData data, string prflFilePath)
Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ProfilesImporter.cs
===================================================================
diff -u -r21a8ed792a5a1fca14173225ba3ac976e40f7a1c -r4eaa942f6a986a04aacee22d1b8e142b0d07f389
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ProfilesImporter.cs (.../ProfilesImporter.cs) (revision 21a8ed792a5a1fca14173225ba3ac976e40f7a1c)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ProfilesImporter.cs (.../ProfilesImporter.cs) (revision 4eaa942f6a986a04aacee22d1b8e142b0d07f389)
@@ -47,6 +47,7 @@
{
protected readonly IImporterMessageProvider MessageProvider;
private readonly ReferenceLine referenceLine;
+ private readonly string typeDescriptor;
///
/// Initializes a new instance of .
@@ -55,10 +56,13 @@
/// The path to the file to import from.
/// The import target.
/// The message provider to provide messages during the import.
- /// Thrown when ,
- /// or is null.
- protected ProfilesImporter(ReferenceLine referenceLine, string filePath, T importTarget,
- IImporterMessageProvider messageProvider) : base(filePath, importTarget)
+ /// The description of the profiles that are imported.
+ /// Thrown when any input parameter is null.
+ protected ProfilesImporter(ReferenceLine referenceLine,
+ string filePath,
+ T importTarget,
+ IImporterMessageProvider messageProvider,
+ string typeDescriptor) : base(filePath, importTarget)
{
if (referenceLine == null)
{
@@ -68,8 +72,13 @@
{
throw new ArgumentNullException(nameof(messageProvider));
}
+ if (typeDescriptor == null)
+ {
+ throw new ArgumentNullException(nameof(typeDescriptor));
+ }
this.referenceLine = referenceLine;
+ this.typeDescriptor = typeDescriptor;
MessageProvider = messageProvider;
}
@@ -98,7 +107,7 @@
catch (UpdateDataException e)
{
string message = string.Format(MessageProvider.GetUpdateDataFailedLogMessageText(
- "TODO"),
+ typeDescriptor),
e.Message);
Log.Error(message, e);
return false;
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/DikeProfilesImporterTest.cs
===================================================================
diff -u -r56a1b0ad79756583461f17301d0edcd79a1d0de4 -r4eaa942f6a986a04aacee22d1b8e142b0d07f389
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/DikeProfilesImporterTest.cs (.../DikeProfilesImporterTest.cs) (revision 56a1b0ad79756583461f17301d0edcd79a1d0de4)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/DikeProfilesImporterTest.cs (.../DikeProfilesImporterTest.cs) (revision 4eaa942f6a986a04aacee22d1b8e142b0d07f389)
@@ -30,6 +30,7 @@
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.Exceptions;
using Ringtoets.Common.IO.FileImporters;
using Ringtoets.Common.IO.FileImporters.MessageProviders;
using Ringtoets.Common.IO.TestUtil;
@@ -528,6 +529,43 @@
// Asserts done in TearDown()
}
+ [Test]
+ public void Import_ThrowsUpdateDataException_ReturnsFalseAndLogsError()
+ {
+ // Setup
+ var messageProvider = mocks.StrictMock();
+ messageProvider.Expect(mp => mp.GetAddDataToModelProgressText())
+ .Return("");
+ messageProvider.Expect(mp => mp.GetUpdateDataFailedLogMessageText("Dijkprofielen"))
+ .IgnoreArguments()
+ .Return("error {0}");
+
+ const string exceptionMessage = "Look, an exception!";
+ var strategy = mocks.StrictMock();
+ strategy.Expect(strat => strat.UpdateDikeProfilesWithImportedData(null, null, null))
+ .IgnoreArguments()
+ .Throw(new UpdateDataException(exceptionMessage));
+ mocks.ReplayAll();
+
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO,
+ Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp"));
+ ReferenceLine referenceLine = CreateMatchingReferenceLine();
+
+ var importer = new DikeProfilesImporter(new DikeProfileCollection(),
+ referenceLine,
+ filePath,
+ strategy, messageProvider);
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = importer.Import();
+
+ // Assert
+ string expectedMessage = $"error {exceptionMessage}";
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 1);
+ Assert.IsFalse(importResult);
+ }
+
private static ReferenceLine CreateMatchingReferenceLine()
{
var referenceLine = new ReferenceLine();
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs
===================================================================
diff -u -r1325800e22033161045afc4ab04b73c76585d370 -r4eaa942f6a986a04aacee22d1b8e142b0d07f389
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs (.../ForeshoreProfilesImporterTest.cs) (revision 1325800e22033161045afc4ab04b73c76585d370)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs (.../ForeshoreProfilesImporterTest.cs) (revision 4eaa942f6a986a04aacee22d1b8e142b0d07f389)
@@ -31,9 +31,11 @@
using Rhino.Mocks;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.Exceptions;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Forms.PresentationObjects;
using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.Common.IO.FileImporters.MessageProviders;
namespace Ringtoets.Common.IO.Test.FileImporters
{
@@ -58,14 +60,15 @@
public void ParameteredConstructor_ExpectedValues()
{
// Setup
+ var messageProvider = mockRepository.Stub();
var strategy = mockRepository.Stub();
mockRepository.ReplayAll();
var importTarget = new ForeshoreProfileCollection();
var referenceLine = new ReferenceLine();
// Call
- var importer = new ForeshoreProfilesImporter(importTarget, referenceLine, strategy, "");
+ var importer = new ForeshoreProfilesImporter(importTarget, referenceLine, "", strategy, messageProvider);
// Assert
Assert.IsInstanceOf>(importer);
@@ -75,11 +78,12 @@
public void ParameteredConstructor_ImportTargetNull_ThrowArgumentNullException()
{
// Setup
+ var messageProvider = mockRepository.Stub();
var strategy = mockRepository.Stub();
mockRepository.ReplayAll();
// Call
- TestDelegate call = () => new ForeshoreProfilesImporter(null, new ReferenceLine(), strategy, "");
+ TestDelegate call = () => new ForeshoreProfilesImporter(null, new ReferenceLine(), "", strategy, messageProvider);
// Assert
var exception = Assert.Throws(call);
@@ -90,41 +94,61 @@
public void ParameteredConstructor_ReferenceLineNull_ThrowArgumentNullException()
{
// Setup
+ var messageProvider = mockRepository.Stub();
var strategy = mockRepository.Stub();
mockRepository.ReplayAll();
// Call
- TestDelegate call = () => new ForeshoreProfilesImporter(new ForeshoreProfileCollection(), null, strategy, "");
+ TestDelegate call = () => new ForeshoreProfilesImporter(new ForeshoreProfileCollection(), null, "", strategy, messageProvider);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("referenceLine", exception.ParamName);
}
[Test]
+ public void ParameteredConstructor_FilePathNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var messageProvider = mockRepository.Stub();
+ var strategy = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new ForeshoreProfilesImporter(new ForeshoreProfileCollection(), new ReferenceLine(), null, strategy, messageProvider);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("filePath", exception.ParamName);
+ }
+
+ [Test]
public void ParameteredConstructor_ForeshoreProfileUpdateStrategyNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate call = () => new ForeshoreProfilesImporter(new ForeshoreProfileCollection(), new ReferenceLine(), null, "path");
+ var messageProvider = mockRepository.Stub();
+ mockRepository.ReplayAll();
+ TestDelegate call = () => new ForeshoreProfilesImporter(new ForeshoreProfileCollection(), new ReferenceLine(), "path", null, messageProvider);
+
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("foreshoreProfileUpdateStrategy", exception.ParamName);
}
[Test]
- public void ParameteredConstructor_FilePathNull_ThrowArgumentNullException()
+ public void ParameteredConstructor_MessageProviderNull_ThrowArgumentNullException()
{
// Setup
var strategy = mockRepository.Stub();
mockRepository.ReplayAll();
// Call
- TestDelegate call = () => new ForeshoreProfilesImporter(new ForeshoreProfileCollection(), new ReferenceLine(), strategy, null);
+ TestDelegate call = () => new ForeshoreProfilesImporter(new ForeshoreProfileCollection(), new ReferenceLine(), "path", strategy, null);
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("filePath", exception.ParamName);
+ Assert.AreEqual("messageProvider", exception.ParamName);
}
[Test]
@@ -140,10 +164,12 @@
var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = referenceLine;
+ var messageProvider = mockRepository.Stub();
var strategy = mockRepository.StrictMock();
+
mockRepository.ReplayAll();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath, strategy, messageProvider);
// Call
var importResult = true;
@@ -179,11 +205,13 @@
var readForeshoreProfiles = (IEnumerable) invocation.Arguments[1];
Assert.AreEqual(5, readForeshoreProfiles.Count());
});
+
+ var messageProvider = mockRepository.Stub();
mockRepository.ReplayAll();
ReferenceLine referenceLine = CreateMatchingReferenceLine();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath, strategy, messageProvider);
// Call
var importResult = false;
@@ -222,13 +250,14 @@
referenceLine.SetGeometry(referencePoints);
var foreshoreProfiles = new ForeshoreProfileCollection();
+ var messageProvider = mockRepository.StrictMock();
var strategy = mockRepository.StrictMock();
-
+
var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = referenceLine;
mockRepository.ReplayAll();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath, strategy, messageProvider);
// Call
var importResult = true;
@@ -264,10 +293,14 @@
var readForeshoreProfiles = (IEnumerable) invocation.Arguments[1];
Assert.AreEqual(5, readForeshoreProfiles.Count());
});
+
+ const string expectedAddingDataToModelMessage = "Adding data to model";
+ var messageProvider = mockRepository.StrictMock();
+ messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()).Return(expectedAddingDataToModelMessage);
mockRepository.ReplayAll();
var progressChangeNotifications = new List();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath, strategy, messageProvider);
foreshoreProfilesImporter.SetProgressChanged((description, step, steps) => progressChangeNotifications.Add(new ProgressNotification(description, step, steps)));
// Call
@@ -289,7 +322,7 @@
new ProgressNotification("Inlezen van profielgegevens.", 3, 5),
new ProgressNotification("Inlezen van profielgegevens.", 4, 5),
new ProgressNotification("Inlezen van profielgegevens.", 5, 5),
- new ProgressNotification("Geïmporteerde data toevoegen aan het toetsspoor.", 1, 1)
+ new ProgressNotification(expectedAddingDataToModelMessage, 1, 1)
};
ValidateProgressMessages(expectedProgressMessages, progressChangeNotifications);
}
@@ -348,9 +381,11 @@
Assert.AreEqual(new RoundedDouble(2, 330.0), foreshoreProfile5.Orientation);
Assert.IsTrue(foreshoreProfile5.HasBreakWater);
});
+
+ var messageProvider = mockRepository.Stub();
mockRepository.ReplayAll();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath, strategy, messageProvider);
var targetContext = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection);
targetContext.Attach(observer);
@@ -388,10 +423,14 @@
var readForeshoreProfiles = (IEnumerable) invocation.Arguments[1];
Assert.AreEqual(5, readForeshoreProfiles.Count());
});
+
+ const string expectedAddingDataToModelMessage = "Adding data to model";
+ var messageProvider = mockRepository.StrictMock();
+ messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()).Return(expectedAddingDataToModelMessage);
mockRepository.ReplayAll();
var progressChangeNotifications = new List();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath, strategy, messageProvider);
foreshoreProfilesImporter.SetProgressChanged((description, step, steps) => progressChangeNotifications.Add(new ProgressNotification(description, step, steps)));
var targetContext = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection);
@@ -416,7 +455,7 @@
new ProgressNotification("Inlezen van profielgegevens.", 3, 5),
new ProgressNotification("Inlezen van profielgegevens.", 4, 5),
new ProgressNotification("Inlezen van profielgegevens.", 5, 5),
- new ProgressNotification("Geïmporteerde data toevoegen aan het toetsspoor.", 1, 1)
+ new ProgressNotification(expectedAddingDataToModelMessage, 1, 1)
};
ValidateProgressMessages(expectedProgressMessages, progressChangeNotifications);
// 'observer' should not be notified
@@ -433,11 +472,16 @@
var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = referenceLine;
+ const string cancelledLogMessage = "Operation cancelled";
+ var messageProvider = mockRepository.StrictMock();
+ messageProvider.Expect(mp => mp.GetCancelledLogMessageText("Voorlandprofielen")).Return(cancelledLogMessage);
+
var strategy = mockRepository.StrictMock();
mockRepository.ReplayAll();
var foreshoreProfiles = new ForeshoreProfileCollection();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine,
+ filePath, strategy, messageProvider);
foreshoreProfilesImporter.SetProgressChanged((description, step, steps) =>
{
if (description.Contains("Inlezen van profiellocaties uit een shapebestand."))
@@ -452,8 +496,9 @@
Action call = () => importResult = foreshoreProfilesImporter.Import();
// Assert
- const string expectedMessage = "Voorlandprofielen importeren is afgebroken. Geen gegevens ingelezen.";
- TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Info), 1);
+ Tuple expectedLogMessage = Tuple.Create(cancelledLogMessage,
+ LogLevelConstant.Info);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedLogMessage, 1);
Assert.IsFalse(importResult);
}
@@ -468,11 +513,15 @@
var assessmentSection = mockRepository.Stub();
assessmentSection.ReferenceLine = referenceLine;
+ const string cancelledLogMessage = "Operation cancelled";
+ var messageProvider = mockRepository.StrictMock();
+ messageProvider.Expect(mp => mp.GetCancelledLogMessageText("Voorlandprofielen")).Return(cancelledLogMessage);
var strategy = mockRepository.StrictMock();
mockRepository.ReplayAll();
var foreshoreProfiles = new ForeshoreProfileCollection();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath,
+ strategy, messageProvider);
foreshoreProfilesImporter.SetProgressChanged((description, step, steps) =>
{
if (description.Contains("Inlezen van profielgegevens uit een prfl bestand."))
@@ -487,8 +536,8 @@
Action call = () => importResult = foreshoreProfilesImporter.Import();
// Assert
- const string expectedMessage = "Voorlandprofielen importeren is afgebroken. Geen gegevens ingelezen.";
- TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Info), 1);
+ Tuple expectedLogMessage = Tuple.Create(cancelledLogMessage, LogLevelConstant.Info);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedLogMessage, 1);
Assert.IsFalse(importResult);
}
@@ -517,9 +566,12 @@
Assert.AreEqual(5, readForeshoreProfiles.Count());
}
});
+
+ var messageProvider = mockRepository.Stub();
mockRepository.ReplayAll();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath,
+ strategy, messageProvider);
foreshoreProfilesImporter.SetProgressChanged((description, step, steps) => foreshoreProfilesImporter.Cancel());
// Precondition
@@ -537,6 +589,42 @@
}
[Test]
+ public void Import_ThrowsUpdateDataException_ReturnsFalseAndLogsError()
+ {
+ // Setup
+ var messageProvider = mockRepository.StrictMock();
+ messageProvider.Expect(mp => mp.GetAddDataToModelProgressText())
+ .Return("");
+ messageProvider.Expect(mp => mp.GetUpdateDataFailedLogMessageText("Dijkprofielen"))
+ .IgnoreArguments()
+ .Return("error {0}");
+
+ const string exceptionMessage = "Look, an exception!";
+ var strategy = mockRepository.StrictMock();
+ strategy.Expect(strat => strat.UpdateForeshoreProfilesWithImportedData(null, null, null))
+ .IgnoreArguments()
+ .Throw(new UpdateDataException(exceptionMessage));
+ mockRepository.ReplayAll();
+
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO,
+ Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp"));
+ ReferenceLine referenceLine = CreateMatchingReferenceLine();
+
+ var importer = new ForeshoreProfilesImporter(new ForeshoreProfileCollection(),
+ referenceLine,
+ filePath, strategy, messageProvider);
+ var importResult = true;
+
+ // Call
+ Action call = () => importResult = importer.Import();
+
+ // Assert
+ string expectedMessage = $"error {exceptionMessage}";
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 1);
+ Assert.IsFalse(importResult);
+ }
+
+ [Test]
public void DoPostImport_AfterImport_ObserversNotified()
{
// Setup
@@ -556,14 +644,16 @@
var foreshoreProfiles = new ForeshoreProfileCollection();
strategy.Expect(strat => strat.UpdateForeshoreProfilesWithImportedData(null, null, null))
.IgnoreArguments()
- .Return(new []
+ .Return(new[]
{
observableA,
observableB
});
+
+ var messageProvider = mockRepository.Stub();
mockRepository.ReplayAll();
- var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, strategy, filePath);
+ var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath, strategy, messageProvider);
foreshoreProfilesImporter.Import();
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ProfilesImporterTest.cs
===================================================================
diff -u -r21a8ed792a5a1fca14173225ba3ac976e40f7a1c -r4eaa942f6a986a04aacee22d1b8e142b0d07f389
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ProfilesImporterTest.cs (.../ProfilesImporterTest.cs) (revision 21a8ed792a5a1fca14173225ba3ac976e40f7a1c)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ProfilesImporterTest.cs (.../ProfilesImporterTest.cs) (revision 4eaa942f6a986a04aacee22d1b8e142b0d07f389)
@@ -130,6 +130,21 @@
}
[Test]
+ public void ParameteredConstructor_TypeDescriptorNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var messageProvider = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new TestProfilesImporter(testImportTarget, testReferenceLine, testFilePath, messageProvider, null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("typeDescriptor", exception.ParamName);
+ }
+
+ [Test]
[TestCase("", "bestandspad mag niet leeg of ongedefinieerd zijn.")]
[TestCase(" ", "bestandspad mag niet leeg of ongedefinieerd zijn.")]
[TestCase("c>\\Invalid_Characters.shp", "er zitten ongeldige tekens in het bestandspad. Alle tekens in het bestandspad moeten geldig zijn.")]
@@ -586,10 +601,12 @@
public void Import_CreateProfilesThrowsUpdateDataException_ReturnsFalseAndLogsError()
{
// Setup
+ const string typeDescriptor = "A typeDescriptor";
+
var messageProvider = mocks.StrictMock();
messageProvider.Expect(mp => mp.GetAddDataToModelProgressText())
.Return("");
- messageProvider.Expect(mp => mp.GetUpdateDataFailedLogMessageText(null))
+ messageProvider.Expect(mp => mp.GetUpdateDataFailedLogMessageText(typeDescriptor))
.IgnoreArguments()
.Return("error {0}");
mocks.ReplayAll();
@@ -598,7 +615,11 @@
Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp"));
ReferenceLine referenceLine = CreateMatchingReferenceLine();
- var testProfilesImporter = new TestProfilesImporter(new ObservableList