Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/AssessmentSectionMerger.cs =================================================================== diff -u -r29d71fc2b326ae60c281103380b4babe1b881f87 -r03733ab29bedcd18c213b3d62b87080514a9a67b --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/AssessmentSectionMerger.cs (.../AssessmentSectionMerger.cs) (revision 29d71fc2b326ae60c281103380b4babe1b881f87) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/AssessmentSectionMerger.cs (.../AssessmentSectionMerger.cs) (revision 03733ab29bedcd18c213b3d62b87080514a9a67b) @@ -20,10 +20,12 @@ // All rights reserved. using System; +using System.Collections.Generic; +using System.Linq; using Core.Common.Gui; using log4net; using Ringtoets.Integration.Data; -using Ringtoets.Integration.Forms.Merge; +using Ringtoets.Integration.Plugin.Properties; using Ringtoets.Integration.Service.Merge; using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; using RingtoetsStorageResources = Ringtoets.Storage.Core.Properties.Resources; @@ -73,12 +75,28 @@ return; } - assessmentSectionProvider.GetAssessmentSections(filePath); + IEnumerable assessmentSections = assessmentSectionProvider.GetAssessmentSections(filePath); + + if (assessmentSections == null) + { + return; + } + + if (!assessmentSections.Any()) + { + LogError(Resources.AssessmentSectionMerger_No_matching_AssessmentSections); + return; + } } private static void CancelMergeAndLog() { log.Info(CoreCommonGuiResources.GuiImportHandler_ImportItemsUsingDialog_Importing_cancelled); } + + private static void LogError(string message) + { + log.Error(message); + } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -re25695acf2407be4ea1a9ea6c1791aba5c0ca81f -r03733ab29bedcd18c213b3d62b87080514a9a67b --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e25695acf2407be4ea1a9ea6c1791aba5c0ca81f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 03733ab29bedcd18c213b3d62b87080514a9a67b) @@ -142,6 +142,15 @@ } /// + /// Looks up a localized string similar to Er zijn geen trajecten gevonden die samengevoegd kunnen worden.. + /// + public static string AssessmentSectionMerger_No_matching_AssessmentSections { + get { + return ResourceManager.GetString("AssessmentSectionMerger_No_matching_AssessmentSections", resourceCulture); + } + } + + /// /// Looks up a localized string similar to &Selecteren.... /// public static string BackgroundData_SelectMapData { Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx =================================================================== diff -u -re25695acf2407be4ea1a9ea6c1791aba5c0ca81f -r03733ab29bedcd18c213b3d62b87080514a9a67b --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision e25695acf2407be4ea1a9ea6c1791aba5c0ca81f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 03733ab29bedcd18c213b3d62b87080514a9a67b) @@ -185,4 +185,7 @@ Gecombineerd totaaloordeel + + Er zijn geen trajecten gevonden die samengevoegd kunnen worden. + \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/AssessmentSectionMergerTest.cs =================================================================== diff -u -rcdb8bb817e1731b97aa9f4198b51f6ab88e76c8d -r03733ab29bedcd18c213b3d62b87080514a9a67b --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/AssessmentSectionMergerTest.cs (.../AssessmentSectionMergerTest.cs) (revision cdb8bb817e1731b97aa9f4198b51f6ab88e76c8d) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/AssessmentSectionMergerTest.cs (.../AssessmentSectionMergerTest.cs) (revision 03733ab29bedcd18c213b3d62b87080514a9a67b) @@ -20,10 +20,12 @@ // All rights reserved. using System; +using System.Linq; using Core.Common.Gui; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Integration.Data; using Ringtoets.Integration.Service.Merge; namespace Ringtoets.Integration.Plugin.Test @@ -69,7 +71,7 @@ } [Test] - public void StartMerge_FilePathNotNull_Continue() + public void GivenValidFilePath_WhenAssessmentSectionProviderReturnNull_Abort() { // Setup var mocks = new MockRepository(); @@ -88,5 +90,26 @@ TestHelper.AssertLogMessagesCount(call, 0); mocks.VerifyAll(); } + + [Test] + public void GivenValidFilePath_WhenAssessmentSectionProviderReturnEmptyCollection_LogErrorAndAbort() + { + // Setup + var mocks = new MockRepository(); + var inquiryHelper = mocks.StrictMock(); + inquiryHelper.Expect(helper => helper.GetSourceFileLocation(null)).IgnoreArguments().Return(string.Empty); + var assessmentSectionProvider = mocks.StrictMock(); + assessmentSectionProvider.Expect(asp => asp.GetAssessmentSections(null)).IgnoreArguments().Return(Enumerable.Empty()); + mocks.ReplayAll(); + + var merger = new AssessmentSectionMerger(inquiryHelper, assessmentSectionProvider); + + // Call + Action call = () => merger.StartMerge(); + + // Assert + TestHelper.AssertLogMessageWithLevelIsGenerated(call, new Tuple("Er zijn geen trajecten gevonden die samengevoegd kunnen worden.", LogLevelConstant.Error), 1); + mocks.VerifyAll(); + } } } \ No newline at end of file