Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ForeshoreProfilesImporter.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r27bbcb784f41b02ded9416b5ac0f40e4c3f99d23 --- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ForeshoreProfilesImporter.cs (.../ForeshoreProfilesImporter.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/ForeshoreProfilesImporter.cs (.../ForeshoreProfilesImporter.cs) (revision 27bbcb784f41b02ded9416b5ac0f40e4c3f99d23) @@ -57,7 +57,14 @@ foreach (ForeshoreProfile foreshoreProfile in importedForeshoreProfiles) { - ImportTarget.Add(foreshoreProfile); + if (ImportTarget.Select(fp => fp.Id).Contains(foreshoreProfile.Id)) + { + Log.WarnFormat(Resources.ForeshoreProfilesImporter_CreateProfiles_ForeshoreProfile_0_already_imported, foreshoreProfile.Id); + } + else + { + ImportTarget.Add(foreshoreProfile); + } } } Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r6d5e26f9a71e8337b5973cfb20d08b8a6ea37c35 -r27bbcb784f41b02ded9416b5ac0f40e4c3f99d23 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 6d5e26f9a71e8337b5973cfb20d08b8a6ea37c35) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 27bbcb784f41b02ded9416b5ac0f40e4c3f99d23) @@ -749,6 +749,15 @@ } /// + /// Looks up a localized string similar to Voorlandprofiel '{0}' is al geïmporteerd en wordt overgeslagen.. + /// + public static string ForeshoreProfilesImporter_CreateProfiles_ForeshoreProfile_0_already_imported { + get { + return ResourceManager.GetString("ForeshoreProfilesImporter_CreateProfiles_ForeshoreProfile_0_already_imported", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Kan geen geldige gegevens vinden voor voorlandprofiellocatie met ID '{0}'.. /// public static string ForeshoreProfilesImporter_GetMatchingForeshoreProfileData_no_foreshoreprofiledata_for_location_0_ { Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r9ccf12127f1ce0721f8589c16289c632cb854455 -r27bbcb784f41b02ded9416b5ac0f40e4c3f99d23 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 9ccf12127f1ce0721f8589c16289c632cb854455) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 27bbcb784f41b02ded9416b5ac0f40e4c3f99d23) @@ -643,4 +643,7 @@ Er is geen kunstwerk opgegeven om de stochast '{0}' aan toe te voegen. + + Voorlandprofiel '{0}' is al geïmporteerd en wordt overgeslagen. + \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r27bbcb784f41b02ded9416b5ac0f40e4c3f99d23 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs (.../ForeshoreProfilesImporterTest.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/ForeshoreProfilesImporterTest.cs (.../ForeshoreProfilesImporterTest.cs) (revision 27bbcb784f41b02ded9416b5ac0f40e4c3f99d23) @@ -436,6 +436,41 @@ mockRepository.VerifyAll(); } + [Test] + public void Import_ImportingAlreadyExistingForeshoreProfiles_TrueAndLogMessagesAndFiveForeshoreProfiles() + { + // Setup + string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, + Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp")); + + ReferenceLine referenceLine = CreateMatchingReferenceLine(); + var assessmentSection = mockRepository.Stub(); + assessmentSection.ReferenceLine = referenceLine; + mockRepository.ReplayAll(); + + var foreshoreProfiles = new ObservableList(); + var foreshoreProfilesImporter = new ForeshoreProfilesImporter(foreshoreProfiles, referenceLine, filePath); + + bool importResult = foreshoreProfilesImporter.Import(); + foreshoreProfiles.RemoveAt(3); + + // Call + Action call = () => importResult = foreshoreProfilesImporter.Import(); + + // Assert + var expectedMessages = new[] + { + Tuple.Create("Voorlandprofiel 'profiel001' is al geïmporteerd en wordt overgeslagen.", LogLevelConstant.Warn), + Tuple.Create("Voorlandprofiel 'profiel002' is al geïmporteerd en wordt overgeslagen.", LogLevelConstant.Warn), + Tuple.Create("Voorlandprofiel 'profiel003' is al geïmporteerd en wordt overgeslagen.", LogLevelConstant.Warn), + Tuple.Create("Voorlandprofiel 'profiel005' is al geïmporteerd en wordt overgeslagen.", LogLevelConstant.Warn) + }; + TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedMessages, 4); + Assert.IsTrue(importResult); + Assert.AreEqual(5, foreshoreProfiles.Count); + mockRepository.VerifyAll(); + } + private ReferenceLine CreateMatchingReferenceLine() { var referenceLine = new ReferenceLine();