Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs =================================================================== diff -u -r7a4f8ff71ae5f81177fe5ff9cd78fdc7f24c69f4 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision 7a4f8ff71ae5f81177fe5ff9cd78fdc7f24c69f4) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -37,6 +37,7 @@ using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.IO.FileImporters; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Common.IO.ReferenceLines; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionOutwards.Data; @@ -557,6 +558,7 @@ demoAssessmentSection.ReferenceLine, Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_surfacelines.csv"), + new ImportMessageProvider(), new RingtoetsPipingSurfaceLineReplaceDataStrategy(pipingFailureMechanism)); surfaceLinesImporter.Import(); } @@ -566,6 +568,7 @@ var soilProfilesImporter = new StochasticSoilModelImporter(pipingFailureMechanism.StochasticSoilModels, Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil"), + new ImportMessageProvider(), new StochasticSoilModelReplaceDataStrategy(pipingFailureMechanism)); soilProfilesImporter.Import(); } Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/IImporterMessageProvider.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/IImporterMessageProvider.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/IImporterMessageProvider.cs (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -0,0 +1,35 @@ +// Copyright (C) Stichting Deltares 2016. 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. + +namespace Ringtoets.Common.IO.FileImporters.MessageProviders +{ + /// + /// Interface for providing messages for the importers. + /// + public interface IImporterMessageProvider + { + /// + /// Gets the progress text to be displayed when adding data to the model. + /// + /// The progress text. + string GetAddDataToModelProgressText(); + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/ImportMessageProvider.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/ImportMessageProvider.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/ImportMessageProvider.cs (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -0,0 +1,36 @@ +// Copyright (C) Stichting Deltares 2016. 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 Ringtoets.Common.IO.Properties; + +namespace Ringtoets.Common.IO.FileImporters.MessageProviders +{ + /// + /// This class provides the messages during the import actions of an importer. + /// + public class ImportMessageProvider : IImporterMessageProvider + { + public string GetAddDataToModelProgressText() + { + return Resources.Importer_ProgressText_Adding_imported_data_to_data_model; + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/UpdateMessageProvider.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/UpdateMessageProvider.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/MessageProviders/UpdateMessageProvider.cs (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -0,0 +1,36 @@ +// Copyright (C) Stichting Deltares 2016. 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 Ringtoets.Common.IO.Properties; + +namespace Ringtoets.Common.IO.FileImporters.MessageProviders +{ + /// + /// This class provides the messages during the update actions of an importer. + /// + public class UpdateMessageProvider : IImporterMessageProvider + { + public string GetAddDataToModelProgressText() + { + return Resources.Importer_ProgressText_Updating_data_in_data_model; + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r4136a0156ea9e20e7e1aca569c5e89cbc713fed2 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 4136a0156ea9e20e7e1aca569c5e89cbc713fed2) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -702,6 +702,15 @@ } /// + /// Looks up a localized string similar to Bijwerken data in het toetsspoor.. + /// + public static string Importer_ProgressText_Updating_data_in_data_model { + get { + return ResourceManager.GetString("Importer_ProgressText_Updating_data_in_data_model", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Kon geen punten vinden in dit bestand.. /// public static string PointShapefileReader_File_can_only_contain_points { @@ -990,14 +999,14 @@ } /// - /// Looks up a localized string similar to BEGIN TRANSACTION; - ///CREATE TABLE "TimeIntegrationSettings" ( - /// "LocationID" INTEGER NOT NULL, - /// "CalculationTypeID" INTEGER NOT NULL, - /// "TimeIntegrationSchemeID" INTEGER NOT NULL, - /// CONSTRAINT timeintegrationsettings_pk PRIMARY KEY ("LocationID", "CalculationTypeID"), - /// CONSTRAINT calculationtypes_timeintegrationsettings_fk FOREIGN KEY ("CalculationTypeID") REFERENCES CalculationTypes ("CalculationTypeID") ON DELETE NO ACTION ON UPDATE NO ACTION - ///); + /// Looks up a localized string similar to BEGIN TRANSACTION; + ///CREATE TABLE "TimeIntegrationSettings" ( + /// "LocationID" INTEGER NOT NULL, + /// "CalculationTypeID" INTEGER NOT NULL, + /// "TimeIntegrationSchemeID" INTEGER NOT NULL, + /// CONSTRAINT timeintegrationsettings_pk PRIMARY KEY ("LocationID", "CalculationTypeID"), + /// CONSTRAINT calculationtypes_timeintegrationsettings_fk FOREIGN KEY ("CalculationTypeID") REFERENCES CalculationTypes ("CalculationTypeID") ON DELETE NO ACTION ON UPDATE NO ACTION + ///); ///CREATE TABLE "Numeri [rest of string was truncated]";. /// public static string settings_schema { Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r4136a0156ea9e20e7e1aca569c5e89cbc713fed2 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 4136a0156ea9e20e7e1aca569c5e89cbc713fed2) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -507,4 +507,7 @@ Het XML-document dat de configuratie voor de berekeningen beschrijft bevat geen berekeningselementen. + + Bijwerken data in het toetsspoor. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r97c94a903e0fd98edd8cd4120340f91f06d3955c -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 97c94a903e0fd98edd8cd4120340f91f06d3955c) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -65,6 +65,9 @@ + + + Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/MessageProviders/ImportMessageProviderTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/MessageProviders/ImportMessageProviderTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/MessageProviders/ImportMessageProviderTest.cs (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -0,0 +1,54 @@ +// Copyright (C) Stichting Deltares 2016. 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 NUnit.Framework; +using Ringtoets.Common.IO.FileImporters.MessageProviders; + +namespace Ringtoets.Common.IO.Test.FileImporters.MessageProviders +{ + [TestFixture] + public class ImportMessageProviderTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var messageProvider = new ImportMessageProvider(); + + // Assert + Assert.IsInstanceOf(messageProvider); + } + + [Test] + public void GetAddDataToModelProgressText_Always_ReturnsExpectedMessage() + { + // Setup + var messageProvider = new ImportMessageProvider(); + + // Call + string message = messageProvider.GetAddDataToModelProgressText(); + + // Assert + const string expectedMessage = "Geïmporteerde data toevoegen aan het toetsspoor."; + Assert.AreEqual(expectedMessage, message); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/MessageProviders/UpdateMessageProviderTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/MessageProviders/UpdateMessageProviderTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/MessageProviders/UpdateMessageProviderTest.cs (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -0,0 +1,54 @@ +// Copyright (C) Stichting Deltares 2016. 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 NUnit.Framework; +using Ringtoets.Common.IO.FileImporters.MessageProviders; + +namespace Ringtoets.Common.IO.Test.FileImporters.MessageProviders +{ + [TestFixture] + public class UpdateMessageProviderTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var messageProvider = new UpdateMessageProvider(); + + // Assert + Assert.IsInstanceOf(messageProvider); + } + + [Test] + public void GetAddDataToModelProgressText_Always_ReturnsExpectedMessage() + { + // Setup + var messageProvider = new UpdateMessageProvider(); + + // Call + string message = messageProvider.GetAddDataToModelProgressText(); + + // Assert + const string expectedMessage = "Bijwerken data in het toetsspoor."; + Assert.AreEqual(expectedMessage, message); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj =================================================================== diff -u -r97c94a903e0fd98edd8cd4120340f91f06d3955c -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 97c94a903e0fd98edd8cd4120340f91f06d3955c) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -68,6 +68,8 @@ + + Index: Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataImportHelper.cs =================================================================== diff -u -rf35a1bdec32700c5cb0027d714c8a51dfc118e0d -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataImportHelper.cs (.../DataImportHelper.cs) (revision f35a1bdec32700c5cb0027d714c8a51dfc118e0d) +++ Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataImportHelper.cs (.../DataImportHelper.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -31,6 +31,7 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.IO.FileImporters; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Common.IO.ReferenceLines; using Ringtoets.Integration.Data; using Ringtoets.Integration.Plugin.Handlers; @@ -188,6 +189,7 @@ var activity = new FileImportActivity(new PipingSurfaceLinesCsvImporter(assessmentSection.PipingFailureMechanism.SurfaceLines, assessmentSection.ReferenceLine, filePath, + new ImportMessageProvider(), new RingtoetsPipingSurfaceLineReplaceDataStrategy(assessmentSection.PipingFailureMechanism)), "PipingSurfaceLinesCsvImporter"); activity.Run(); @@ -211,6 +213,7 @@ var activity = new FileImportActivity(new StochasticSoilModelImporter( assessmentSection.PipingFailureMechanism.StochasticSoilModels, filePath, + new ImportMessageProvider(), new StochasticSoilModelReplaceDataStrategy(assessmentSection.PipingFailureMechanism)), "StochasticSoilModelImporter"); activity.Run(); Index: Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataUpdateHelper.cs =================================================================== diff -u -r199f41a71b3b4c214f819f4519fffd4dc9418ff9 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataUpdateHelper.cs (.../DataUpdateHelper.cs) (revision 199f41a71b3b4c214f819f4519fffd4dc9418ff9) +++ Ringtoets/Integration/test/Ringtoets.Integration.TestUtils/DataUpdateHelper.cs (.../DataUpdateHelper.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -23,6 +23,7 @@ using Core.Common.Base.Service; using Core.Common.Utils.IO; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Integration.Data; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Importers; @@ -54,6 +55,7 @@ var activity = new FileImportActivity(new StochasticSoilModelImporter( assessmentSection.PipingFailureMechanism.StochasticSoilModels, filePath, + new UpdateMessageProvider(), new StochasticSoilModelUpdateDataStrategy(assessmentSection.PipingFailureMechanism)), "StochasticSoilModelUpdater"); activity.Run(); Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/StochasticSoilModelImporter.cs =================================================================== diff -u -rda6c157314d3df1c278d58cc444c7754a79dc656 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/StochasticSoilModelImporter.cs (.../StochasticSoilModelImporter.cs) (revision da6c157314d3df1c278d58cc444c7754a79dc656) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/StochasticSoilModelImporter.cs (.../StochasticSoilModelImporter.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -28,6 +28,7 @@ using Core.Common.IO.Exceptions; using Core.Common.IO.Readers; using log4net; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; @@ -43,23 +44,31 @@ public class StochasticSoilModelImporter : FileImporterBase { private readonly ILog log = LogManager.GetLogger(typeof(StochasticSoilModelImporter)); + private readonly IImporterMessageProvider messageProvider; private readonly IStochasticSoilModelUpdateModelStrategy modelUpdateStrategy; /// /// Initializes a new instance of the class. /// /// The collection to update. /// The path to the file to import from. + /// The message provider to provide messages during importer actions. /// The to use /// when updating the . /// Thrown when any of the input parameters is null. - public StochasticSoilModelImporter(StochasticSoilModelCollection importTarget, string filePath, IStochasticSoilModelUpdateModelStrategy modelUpdateStrategy) + public StochasticSoilModelImporter(StochasticSoilModelCollection importTarget, string filePath, + IImporterMessageProvider messageProvider, IStochasticSoilModelUpdateModelStrategy modelUpdateStrategy) : base(filePath, importTarget) { if (modelUpdateStrategy == null) { throw new ArgumentNullException(nameof(modelUpdateStrategy)); } + if (messageProvider == null) + { + throw new ArgumentNullException(nameof(messageProvider)); + } + this.messageProvider = messageProvider; this.modelUpdateStrategy = modelUpdateStrategy; } @@ -138,9 +147,10 @@ { var currentStep = 1; StochasticSoilModel[] importedModels = importStochasticSoilModelResult.Items.ToArray(); + string addDataToModelProgressText = messageProvider.GetAddDataToModelProgressText(); foreach (StochasticSoilModel importedModel in importedModels) { - NotifyProgress(RingtoestCommonIOResources.Importer_ProgressText_Adding_imported_data_to_data_model, currentStep, importedModels.Length); + NotifyProgress(addDataToModelProgressText, currentStep, importedModels.Length); if (ValidateStochasticSoilModel(importedModel)) { yield return importedModel; Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs =================================================================== diff -u -re6afafed09cf1face1cacd89329da45ff93485a9 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision e6afafed09cf1face1cacd89329da45ff93485a9) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -30,6 +30,7 @@ using Core.Common.IO.Readers; using log4net; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Importers; using Ringtoets.Piping.IO.SurfaceLines; @@ -55,6 +56,7 @@ private const string characteristicPointsFileSubExtension = ".krp"; private const string csvFileExtension = ".csv"; + private readonly IImporterMessageProvider messageProvider; private readonly ISurfaceLineUpdateDataStrategy surfaceLineUpdateStrategy; private readonly ILog log = LogManager.GetLogger(typeof(PipingSurfaceLinesCsvImporter)); @@ -66,13 +68,13 @@ /// The import target. /// The reference line. /// The path to the file to import from. + /// The message provider to provide messages during importer actions. /// The strategy to update the surface lines with imported data. /// Thrown when /// or is null. - public PipingSurfaceLinesCsvImporter(RingtoetsPipingSurfaceLineCollection importTarget, - ReferenceLine referenceLine, - string filePath, - ISurfaceLineUpdateDataStrategy surfaceLineUpdateStrategy) : base(filePath, importTarget) + public PipingSurfaceLinesCsvImporter(RingtoetsPipingSurfaceLineCollection importTarget, ReferenceLine referenceLine, string filePath, + IImporterMessageProvider messageProvider, ISurfaceLineUpdateDataStrategy surfaceLineUpdateStrategy) + : base(filePath, importTarget) { if (importTarget == null) { @@ -82,11 +84,15 @@ { throw new ArgumentNullException(nameof(referenceLine)); } + if (messageProvider == null) + { + throw new ArgumentNullException(nameof(messageProvider)); + } if (surfaceLineUpdateStrategy == null) { throw new ArgumentNullException(nameof(surfaceLineUpdateStrategy)); } - + this.messageProvider = messageProvider; this.surfaceLineUpdateStrategy = surfaceLineUpdateStrategy; this.referenceLine = referenceLine; } @@ -141,14 +147,14 @@ private IEnumerable ProcessImportedDataToModel(ICollection readSurfaceLines, ICollection readCharacteristicPointsLocations) { - NotifyProgress(RingtoetsCommonIOResources.Importer_ProgressText_Adding_imported_data_to_data_model, 0, readSurfaceLines.Count); + string progressText = messageProvider.GetAddDataToModelProgressText(); + NotifyProgress(progressText, 0, readSurfaceLines.Count); List readCharacteristicPointsLocationNames = readCharacteristicPointsLocations.Select(cpl => cpl.Name).ToList(); int surfaceLineNumber = 1; foreach (var readSurfaceLine in readSurfaceLines) { - NotifyProgress(RingtoetsCommonIOResources.Importer_ProgressText_Adding_imported_data_to_data_model, - surfaceLineNumber++, readSurfaceLines.Count); + NotifyProgress(progressText, surfaceLineNumber++, readSurfaceLines.Count); if (Canceled) { Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -rd3ebf1b56b406bc99fdf54a9920fdfa9f7632ca7 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision d3ebf1b56b406bc99fdf54a9920fdfa9f7632ca7) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -39,6 +39,7 @@ using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.TreeNodeInfos; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Common.Service; using Ringtoets.Piping.Data; using Ringtoets.Piping.Forms; @@ -105,7 +106,7 @@ Image = PipingFormsResources.PipingSurfaceLineIcon, FileFilterGenerator = RingtoetsPipingSurfaceLineFileFilter, IsEnabled = IsSurfaceLineImporterEnabled, - CreateFileImporter = (context, filePath) => PipingSurfaceLinesCsvImporter(context, filePath, new RingtoetsPipingSurfaceLineReplaceDataStrategy(context.FailureMechanism)), + CreateFileImporter = (context, filePath) => PipingSurfaceLinesCsvImporter(context, filePath, new ImportMessageProvider(), new RingtoetsPipingSurfaceLineReplaceDataStrategy(context.FailureMechanism)), VerifyUpdates = context => VerifyPipingSurfaceLineUpdates(context, Resources.PipingPlugin_VerifyRingtoetsPipingSurfaceLineImport_When_importing_surfacelines_calculation_output_will_be_cleared_confirm) }; @@ -116,7 +117,7 @@ Image = PipingFormsResources.PipingSoilProfileIcon, FileFilterGenerator = StochasticSoilModelFileFilter, IsEnabled = StochasticSoilModelImporterEnabled, - CreateFileImporter = (context, filePath) => StochasticSoilModelImporter(context, filePath, new StochasticSoilModelReplaceDataStrategy(context.FailureMechanism)), + CreateFileImporter = (context, filePath) => StochasticSoilModelImporter(context, filePath, new ImportMessageProvider(), new StochasticSoilModelReplaceDataStrategy(context.FailureMechanism)), VerifyUpdates = context => VerifyStochasticSoilModelUpdates(context, Resources.PipingPlugin_VerifyStochasticSoilModelImport_When_importing_StochasticSoilModels_calculation_output_will_be_cleared_confirm) }; @@ -154,7 +155,7 @@ FileFilterGenerator = RingtoetsPipingSurfaceLineFileFilter, IsEnabled = IsSurfaceLineImporterEnabled, CurrentPath = context => context.WrappedData.SourcePath, - CreateFileImporter = (context, filePath) => PipingSurfaceLinesCsvImporter(context, filePath, new RingtoetsPipingSurfaceLineUpdateDataStrategy(context.FailureMechanism)), + CreateFileImporter = (context, filePath) => PipingSurfaceLinesCsvImporter(context, filePath, new UpdateMessageProvider(), new RingtoetsPipingSurfaceLineUpdateDataStrategy(context.FailureMechanism)), VerifyUpdates = context => VerifyPipingSurfaceLineUpdates(context, Resources.PipingPlugin_VerifyRingtoetsPipingSurfaceLineUpdates_When_updating_surfacelines_definitions_assigned_to_calculation_output_will_be_cleared_confirm) }; @@ -166,7 +167,7 @@ FileFilterGenerator = StochasticSoilModelFileFilter, IsEnabled = StochasticSoilModelImporterEnabled, CurrentPath = context => context.WrappedData.SourcePath, - CreateFileImporter = (context, filePath) => StochasticSoilModelImporter(context, filePath, new StochasticSoilModelUpdateDataStrategy(context.FailureMechanism)), + CreateFileImporter = (context, filePath) => StochasticSoilModelImporter(context, filePath, new UpdateMessageProvider(), new StochasticSoilModelUpdateDataStrategy(context.FailureMechanism)), VerifyUpdates = context => VerifyStochasticSoilModelUpdates(context, Resources.PipingPlugin_VerifyStochasticSoilModelUpdates_When_updating_StochasticSoilModel_definitions_assigned_to_calculation_output_will_be_cleared_confirm) }; } @@ -369,10 +370,12 @@ && context.AvailablePipingSurfaceLines.Any(); } - private static StochasticSoilModelImporter StochasticSoilModelImporter(StochasticSoilModelCollectionContext context, string filePath, IStochasticSoilModelUpdateModelStrategy updateStrategy) + private static StochasticSoilModelImporter StochasticSoilModelImporter(StochasticSoilModelCollectionContext context, string filePath, + IImporterMessageProvider messageProvider, IStochasticSoilModelUpdateModelStrategy updateStrategy) { return new StochasticSoilModelImporter(context.WrappedData, filePath, + messageProvider, updateStrategy); } @@ -1099,11 +1102,13 @@ private static PipingSurfaceLinesCsvImporter PipingSurfaceLinesCsvImporter(RingtoetsPipingSurfaceLinesContext context, string filePath, + IImporterMessageProvider messageProvider, ISurfaceLineUpdateDataStrategy strategy) { return new PipingSurfaceLinesCsvImporter(context.WrappedData, context.AssessmentSection.ReferenceLine, filePath, + messageProvider, strategy); } Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/StochasticSoilModelImporterTest.cs =================================================================== diff -u -r110999cffbcac705d99ff96033e9eabb0e0b5e12 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 110999cffbcac705d99ff96033e9eabb0e0b5e12) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/StochasticSoilModelImporterTest.cs (.../StochasticSoilModelImporterTest.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -29,6 +29,7 @@ using Core.Common.Utils.Builders; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Importers; using Ringtoets.Piping.IO.TestUtil; @@ -42,19 +43,33 @@ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, "PipingSoilProfilesReader"); private int progress; + private MockRepository mocks; + [SetUp] public void SetUp() { progress = 0; + mocks = new MockRepository(); } + [TearDown] + public void TearDown() + { + mocks.VerifyAll(); + } + [Test] public void Constructor_ObservableListNull_ThrowsArgumentNullException() { + // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + // Call TestDelegate call = () => new StochasticSoilModelImporter( null, "", + messageProvider, new TestStochasticSoilModelUpdateModelStrategy()); // Assert @@ -63,12 +78,32 @@ } [Test] + public void Constructor_MessageProviderNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new StochasticSoilModelImporter( + new StochasticSoilModelCollection(), + "", + null, + new TestStochasticSoilModelUpdateModelStrategy()); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("messageProvider", paramName); + } + + [Test] public void Constructor_ModelUpdateStrategyNull_ThrowsArgumentNullException() { + // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + // Call TestDelegate call = () => new StochasticSoilModelImporter( new StochasticSoilModelCollection(), "", + messageProvider, null); // Assert @@ -79,12 +114,17 @@ [Test] public void Constructor_ExpectedValues() { + // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var list = new StochasticSoilModelCollection(); // Call var importer = new StochasticSoilModelImporter( list, "", + messageProvider, new TestStochasticSoilModelUpdateModelStrategy()); // Assert @@ -95,6 +135,9 @@ public void Import_FromNonExistingFile_LogError() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var file = "nonexisting.soil"; string validFilePath = Path.Combine(testDataPath, file); @@ -103,6 +146,7 @@ var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -127,6 +171,9 @@ public void Import_FromInvalidFilePath_LogError() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const string file = "/"; string invalidFilePath = Path.Combine(testDataPath, file); @@ -135,6 +182,7 @@ var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, invalidFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -159,6 +207,12 @@ public void Import_ImportingToValidTargetWithValidFile_ImportSoilModelToCollectionAndSourcePathSet() { // Setup + const string expectedAddDataText = "Adding Data"; + var messageProvider = mocks.StrictMock(); + messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()) + .Return(expectedAddDataText); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "complete.soil"); var pipingFailureMechanism = new PipingFailureMechanism(); @@ -168,6 +222,7 @@ var importer = new StochasticSoilModelImporter( pipingFailureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged((description, step, steps) => progressChangeNotifications.Add(new ProgressNotification(description, step, steps))); @@ -196,7 +251,7 @@ expectedProgressMessages.Add(new ProgressNotification("Controleren van ondergrondschematisaties.", 1, 1)); for (var i = 1; i <= expectedModels; i++) { - expectedProgressMessages.Add(new ProgressNotification("Geïmporteerde data toevoegen aan het toetsspoor.", i, expectedModels)); + expectedProgressMessages.Add(new ProgressNotification(expectedAddDataText, i, expectedModels)); } Assert.AreEqual(expectedProgressMessages.Count, progressChangeNotifications.Count); for (var i = 0; i < expectedProgressMessages.Count; i++) @@ -213,13 +268,17 @@ public void Import_ImportingToValidTargetWithValidFileTwice_ReadAnotherTime() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "complete.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -241,13 +300,17 @@ public void Import_CancelOfImportWhenReadingSoilProfiles_CancelsImportAndLogs() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "complete.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged((description, step, steps) => { @@ -271,13 +334,17 @@ public void Import_CancelOfImportWhenReadingStochasticSoilModels_CancelsImportAndLogs() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "complete.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged((description, step, steps) => { @@ -301,13 +368,17 @@ public void Import_CancelOfImportWhenAddingAndCheckingSoilProfiles_CancelsImportAndLogs() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "complete.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged((description, step, steps) => { @@ -331,17 +402,24 @@ public void Import_CancelOfImportWhenAddingDataToModel_ImportCompletedSuccessfullyNonetheless() { // Setup + const string expectedAddDataProgressText = "Adding data..."; + var messageProvider = mocks.StrictMock(); + messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()) + .Return(expectedAddDataProgressText); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "complete.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged((description, step, steps) => { - if (description.Contains("Geïmporteerde data toevoegen aan het toetsspoor.")) + if (description.Contains(expectedAddDataProgressText)) { importer.Cancel(); } @@ -362,13 +440,17 @@ public void Import_ReuseOfCanceledImportToValidTargetWithValidFile_ImportSoilModelToCollection() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "complete.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged((description, step, steps) => importer.Cancel()); @@ -389,13 +471,17 @@ public void Import_ImportingToValidTargetWithProfileContainingInvalidAtX_SkipImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string pathToCorruptFile = Path.Combine(testDataPath, "invalidAtX2dProperty.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, pathToCorruptFile, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -424,13 +510,17 @@ public void Import_ImportingToValidTargetWithProfileContainingInvalidParameterValue_ZeroForValue() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string pathToCorruptFile = Path.Combine(testDataPath, "incorrectValue2dProperty.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, pathToCorruptFile, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -446,13 +536,17 @@ public void Import_IncorrectProfiles_SkipModelAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string pathToCorruptFile = Path.Combine(testDataPath, "invalidStochasticSoilProfiles.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, pathToCorruptFile, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -475,13 +569,17 @@ public void Import_IncorrectProbability_LogAndImportSoilModelToCollection() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string pathToCorruptFile = Path.Combine(testDataPath, "incorrectProbability.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, pathToCorruptFile, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -502,13 +600,17 @@ public void Import_TwoSoilModelsReusingSameProfile1D_ImportSoilModelsToCollection() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "reusedSoilProfile1D.soil"); var pipingFailureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( pipingFailureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); // Call @@ -539,13 +641,17 @@ public void Import_TwoSoilModelsReusingSameProfile2D_ImportSoilModelsToCollection() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "reusedSoilProfile2D.soil"); var pipingFailureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( pipingFailureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); // Call @@ -576,13 +682,17 @@ public void Import_ModelWithOneInvalidStochasticSoilProfileDueToMissingProfile_SkipModelAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "EmptySoilModel.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); var importResult = false; @@ -603,13 +713,17 @@ public void Import_ModelWithTwoStochasticSoilProfileForSameProfile_ProbabilitiesAddedAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string pathToFile = Path.Combine(testDataPath, "multipleStochasticSoilProfileForSameProfile.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, pathToFile, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -634,13 +748,17 @@ public void Import_ModelWithTwoStochasticSoilProfileForProfilesWithSameNameButDifferentTypes_ProbabilitiesNotAdded() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string pathToFile = Path.Combine(testDataPath, "combined1d2d.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, pathToFile, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -662,13 +780,17 @@ public void Import_ModelWithOneStochasticSoilProfile2DWithoutLayerPropertiesSet_ImportModelToCollection() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "SingleSoilProfile2D_noLayerProperties.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -716,13 +838,17 @@ public void Import_ModelWithOneStochasticSoilProfile2DWithLayerPropertiesSet_ImportModelToCollection() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(testDataPath, "SingleSoilProfile2D_withLayerProperties.soil"); var failureMechanism = new PipingFailureMechanism(); var updateStrategy = new TestStochasticSoilModelUpdateModelStrategy(); var importer = new StochasticSoilModelImporter( failureMechanism.StochasticSoilModels, validFilePath, + messageProvider, updateStrategy); importer.SetProgressChanged(IncrementProgress); @@ -799,6 +925,8 @@ observableA.Expect(o => o.NotifyObservers()); var observableB = mocks.StrictMock(); observableB.Expect(o => o.NotifyObservers()); + + var messageProvider = mocks.Stub(); mocks.ReplayAll(); string validFilePath = Path.Combine(testDataPath, "complete.soil"); @@ -811,14 +939,14 @@ var importer = new StochasticSoilModelImporter( new StochasticSoilModelCollection(), validFilePath, + messageProvider, updateStrategy); importer.Import(); // Call importer.DoPostImport(); // Assert - mocks.VerifyAll(); } private static StochasticSoilModel[] AssertSuccessfulImport( Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs =================================================================== diff -u -rf96e01d46f29a268ab62fc6afe5b23f311e63a39 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs (.../ImportSoilProfileFromDatabaseTest.cs) (revision f96e01d46f29a268ab62fc6afe5b23f311e63a39) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs (.../ImportSoilProfileFromDatabaseTest.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -24,9 +24,10 @@ using Core.Common.TestUtil; using Deltares.WTIPiping; using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Importers; -using Ringtoets.Piping.IO.TestUtil; using Ringtoets.Piping.KernelWrapper; using Ringtoets.Piping.Plugin.FileImporter; using Ringtoets.Piping.Primitives; @@ -42,13 +43,18 @@ public void GivenDatabaseWithSimple1DProfile_WhenImportingPipingProfile_ThenPipingProfileHasValuesCorrectlySet() { // Given + var mocks = new MockRepository(); + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string databasePath = Path.Combine(testDataPath, "1dprofile.soil"); var pipingFailureMechanism = new PipingFailureMechanism(); // When var importer = new StochasticSoilModelImporter( pipingFailureMechanism.StochasticSoilModels, databasePath, + messageProvider, new StochasticSoilModelReplaceDataStrategy(pipingFailureMechanism)); importer.Import(); @@ -72,6 +78,8 @@ 2.2, 1.1 }, pipingProfile.Layers.Select(l => l.TopLevel)); + + mocks.VerifyAll(); } /// @@ -82,13 +90,18 @@ public void GivenDatabaseWithValid2DProfileAnd2dProfileWithInvalidLayerGeometry_WhenImportingPipingProfile_ThenValidPipingProfileHasValuesCorrectlySet() { // Given + var mocks = new MockRepository(); + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string databasePath = Path.Combine(testDataPath, "invalid2dGeometry.soil"); var pipingFailureMechanism = new PipingFailureMechanism(); // When var importer = new StochasticSoilModelImporter( pipingFailureMechanism.StochasticSoilModels, databasePath, + messageProvider, new StochasticSoilModelReplaceDataStrategy(pipingFailureMechanism)); importer.Import(); @@ -112,19 +125,26 @@ 3.75, 2.75 }, pipingProfile.Layers.Select(l => l.TopLevel)); + + mocks.VerifyAll(); } [Test] public void GivenDatabaseWithNoLayerValues_WhenImportingPipingProfile_ThenValidPipingProfileWithDefaultValuesCreated() { // Given + var mocks = new MockRepository(); + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var databasePath = Path.Combine(testDataPath, "1dprofileNoValues.soil"); var pipingFailureMechanism = new PipingFailureMechanism(); // When var importer = new StochasticSoilModelImporter( pipingFailureMechanism.StochasticSoilModels, databasePath, + messageProvider, new StochasticSoilModelReplaceDataStrategy(pipingFailureMechanism)); importer.Import(); @@ -143,6 +163,8 @@ 2.2, 1.1 }, pipingProfile.Layers.Select(l => l.TopLevel)); + + mocks.VerifyAll(); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj =================================================================== diff -u -ra59b471e3b6a02319f91b7317b3814a099ef0221 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj (.../Ringtoets.Piping.Integration.Test.csproj) (revision a59b471e3b6a02319f91b7317b3814a099ef0221) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/Ringtoets.Piping.Integration.Test.csproj (.../Ringtoets.Piping.Integration.Test.csproj) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -50,6 +50,10 @@ ..\..\..\..\lib\NUnitForms.dll + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + True + @@ -91,6 +95,10 @@ {4D840673-3812-4338-A352-84854E32B8A0} Ringtoets.Common.Forms + + {52BA7627-CBAB-4209-BE77-3B5F31378277} + Ringtoets.Common.IO + {11F1F874-45AF-43E4-8AE5-15A5C9593E28} Ringtoets.Integration.Data Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/packages.config =================================================================== diff -u -r6a5d7b40b7ba4dcb73e393075338352d194e97c2 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/packages.config (.../packages.config) (revision 6a5d7b40b7ba4dcb73e393075338352d194e97c2) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/packages.config (.../packages.config) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -23,5 +23,6 @@ --> + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs =================================================================== diff -u -r28ab332db2d96ad9e766f19677af1c00fc88a644 -r2ab087c5f7b254eb7ea6d167b122afaea10b0ff6 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision 28ab332db2d96ad9e766f19677af1c00fc88a644) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision 2ab087c5f7b254eb7ea6d167b122afaea10b0ff6) @@ -32,6 +32,7 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.IO.FileImporters.MessageProviders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Importers; using Ringtoets.Piping.Plugin.FileImporter; @@ -52,16 +53,34 @@ private readonly string krpFormat = "{0}.krp.csv"; private readonly string surfaceLineFormat = "{0}.csv"; + private MockRepository mocks; + + [SetUp] + public void Setup() + { + mocks = new MockRepository(); + } + + [TearDown] + public void TearDown() + { + mocks.VerifyAll(); + } + [Test] public void Constructor_ObservableListNull_ThrowsArgumentNullException() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var referenceLine = new ReferenceLine(); // Call TestDelegate call = () => new PipingSurfaceLinesCsvImporter(null, referenceLine, string.Empty, + messageProvider, new TestSurfaceLineUpdateStrategy()); // Assert @@ -73,12 +92,16 @@ public void Constructor_ReferenceLineNull_ThrowsArgumentNullException() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var collection = new RingtoetsPipingSurfaceLineCollection(); // Call TestDelegate call = () => new PipingSurfaceLinesCsvImporter(collection, null, string.Empty, + messageProvider, new TestSurfaceLineUpdateStrategy()); // Assert @@ -87,16 +110,39 @@ } [Test] + public void Constructor_MessageProviderNull_ThrowsArgumentNullException() + { + // Setup + var collection = new RingtoetsPipingSurfaceLineCollection(); + var referenceLine = new ReferenceLine(); + + // Call + TestDelegate call = () => new PipingSurfaceLinesCsvImporter(collection, + referenceLine, + string.Empty, + null, + new TestSurfaceLineUpdateStrategy()); + + // Assert + string parameter = Assert.Throws(call).ParamName; + Assert.AreEqual("messageProvider", parameter); + } + + [Test] public void Constructor_ModelUpdateStrategyNull_ThrowsArgumentNullException() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var collection = new RingtoetsPipingSurfaceLineCollection(); var referenceLine = new ReferenceLine(); // Call TestDelegate call = () => new PipingSurfaceLinesCsvImporter(collection, referenceLine, string.Empty, + messageProvider, null); // Assert @@ -107,11 +153,15 @@ [Test] public void DefaultConstructor_ExpectedValues() { + // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var collection = new RingtoetsPipingSurfaceLineCollection(); var referenceLine = new ReferenceLine(); // Call - var importer = new PipingSurfaceLinesCsvImporter(collection, referenceLine, "", new TestSurfaceLineUpdateStrategy()); + var importer = new PipingSurfaceLinesCsvImporter(collection, referenceLine, "", messageProvider, new TestSurfaceLineUpdateStrategy()); // Assert Assert.IsInstanceOf>(importer); @@ -121,6 +171,11 @@ public void Import_ImportingToValidTargetWithValidFile_ImportSurfaceLinesToCollection() { // Setup + const string expectedAddDataToModelProgressText = "Adding data"; + var messageProvider = mocks.StrictMock(); + messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()).Return(expectedAddDataToModelProgressText); + mocks.ReplayAll(); + const int expectedNumberOfSurfaceLines = 2; var twovalidsurfacelinesCsv = "TwoValidSurfaceLines.csv"; string validFilePath = Path.Combine(ioTestDataPath, twovalidsurfacelinesCsv); @@ -141,7 +196,7 @@ bool progressCharacteristicPointsStarted = false; var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged(delegate(string currentStepName, int currentStep, int totalNumberOfSteps) { if (!progressStarted && callCount == 0) @@ -163,7 +218,7 @@ } else if (callCount <= expectedNumberOfSurfaceLines + 1 + expectedNumberOfSurfaceLines) { - Assert.AreEqual("Geïmporteerde data toevoegen aan het toetsspoor.", currentStepName); + Assert.AreEqual(expectedAddDataToModelProgressText, currentStepName); } else { @@ -206,6 +261,9 @@ public void Import_ImportingToValidTargetWithValidFileWithConsecutiveDuplicatePoints_ImportSurfaceLineWithDuplicatesRemovedToCollection() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var twovalidsurfacelinesCsv = "ValidSurfaceLine_HasConsecutiveDuplicatePoints.csv"; string validFilePath = Path.Combine(ioTestDataPath, twovalidsurfacelinesCsv); @@ -218,7 +276,7 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); // Precondition CollectionAssert.IsEmpty(failureMechanism.SurfaceLines); @@ -263,13 +321,16 @@ public void Import_CancelOfImportWhenReadingPipingSurfaceLines_CancelsImportAndLogs() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(ioTestDataPath, "TwoValidSurfaceLines.csv"); var referenceLine = new ReferenceLine(); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged(delegate(string description, int step, int steps) { if (description.Contains("Inlezen van het profielschematisatiesbestand.")) @@ -296,13 +357,16 @@ public void Import_CancelOfImportWhenReadingCharacteristicPoints_CancelsImportAndLogs() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(ioTestDataPath, "TwoValidSurfaceLines.csv"); var referenceLine = new ReferenceLine(); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((description, step, steps) => { if (description.Contains("Inlezen van het karakteristieke punten-bestand.")) @@ -329,6 +393,11 @@ public void Import_CancelOfImportDuringAddingDataToModel_CancelsImportAndLogs() { // Setup + const string expectedAddDataToModelProgressText = "Adding data"; + var messageProvider = mocks.StrictMock(); + messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()).Return(expectedAddDataToModelProgressText); + mocks.ReplayAll(); + string validFilePath = Path.Combine(ioTestDataPath, "TwoValidSurfaceLines.csv"); var referenceLine = new ReferenceLine(); @@ -342,11 +411,11 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((description, step, steps) => { if (step < steps - && description.Contains("Geïmporteerde data toevoegen aan het toetsspoor.")) + && description.Contains(expectedAddDataToModelProgressText)) { importer.Cancel(); } @@ -370,6 +439,9 @@ public void Import_ReuseOfCanceledImportToValidTargetWithValidFile_ImportSurfaceLinesToCollection() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const int expectedNumberOfSurfaceLines = 2; string validFilePath = Path.Combine(ioTestDataPath, "TwoValidSurfaceLines.csv"); @@ -384,7 +456,7 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((description, step, steps) => importer.Cancel()); // Precondition @@ -408,12 +480,15 @@ public void Import_PathIsInvalid_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(ioTestDataPath, "TwoValidSurfaceLines.csv"); string corruptPath = validFilePath.Replace('S', Path.GetInvalidPathChars().First()); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), corruptPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), corruptPath, messageProvider, surfaceLineUpdateStrategy); bool importResult = true; @@ -433,12 +508,15 @@ public void Import_FileDoesNotExist_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string corruptPath = Path.Combine(ioTestDataPath, "I_dont_exists.csv"); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), corruptPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), corruptPath, messageProvider, surfaceLineUpdateStrategy); var importResult = true; @@ -464,11 +542,14 @@ public void Import_FileIsEmpty_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string corruptPath = Path.Combine(ioTestDataPath, "empty.csv"); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), corruptPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), corruptPath, messageProvider, surfaceLineUpdateStrategy); var importResult = true; @@ -496,11 +577,14 @@ public void Import_InvalidHeader_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string corruptPath = Path.Combine(ioTestDataPath, "InvalidHeader_LacksY1.csv"); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), corruptPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), corruptPath, messageProvider, surfaceLineUpdateStrategy); bool importResult = true; @@ -528,6 +612,9 @@ public void Import_FileDeletedDuringRead_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var copyTargetPath = TestHelper.GetScratchPadPath($"{nameof(Import_FileDeletedDuringRead_AbortImportAndLog)}.csv"); string validFilePath = Path.Combine(ioTestDataPath, "TwoValidSurfaceLines.csv"); File.Copy(validFilePath, copyTargetPath); @@ -536,7 +623,7 @@ { var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), copyTargetPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), copyTargetPath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((name, step, steps) => { // Delete the file being read by the import during the import itself: @@ -576,6 +663,9 @@ public void Import_FileHasDuplicateIdentifier_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var fileName = "TwoValidSurfaceLines_DuplicateIdentifier"; string corruptPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); string expectedCharacteristicPointsFile = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(krpFormat, fileName)); @@ -589,7 +679,7 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, corruptPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, corruptPath, messageProvider, surfaceLineUpdateStrategy); var importResult = true; @@ -620,6 +710,9 @@ public void Import_FileWithTwoValidLinesAndOneInvalidDueToUnparsableNumber_SkipInvalidRowAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string corruptPath = Path.Combine(ioTestDataPath, "TwoValidAndOneInvalidNumberRowSurfaceLines.csv"); var referenceLine = new ReferenceLine(); @@ -635,7 +728,7 @@ int progressCallCount = 0; var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, corruptPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, corruptPath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((name, step, steps) => progressCallCount++); var importResult = false; @@ -683,13 +776,16 @@ public void Import_ImportingToValidTargetWithInvalidFileWithDuplicatePointsCausingRecline_SkipInvalidRowAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var twovalidsurfacelinesCsv = "InvalidRow_DuplicatePointsCausingRecline.csv"; string path = Path.Combine(ioTestDataPath, twovalidsurfacelinesCsv); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), path, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), path, messageProvider, surfaceLineUpdateStrategy); // Precondition CollectionAssert.IsEmpty(failureMechanism.SurfaceLines); @@ -725,13 +821,16 @@ public void Import_ImportingToValidTargetWithInvalidFileWithDuplicatePointsCausingZeroLength_SkipInvalidRowAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var twovalidsurfacelinesCsv = "InvalidRow_DuplicatePointsCausingZeroLength.csv"; string path = Path.Combine(ioTestDataPath, twovalidsurfacelinesCsv); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), path, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), path, messageProvider, surfaceLineUpdateStrategy); // Precondition CollectionAssert.IsEmpty(failureMechanism.SurfaceLines); @@ -767,6 +866,9 @@ public void Import_CharacteristicPointsFileDoesNotExist_Log() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + var fileName = "TwoValidSurfaceLines"; string surfaceLinesFile = Path.Combine(ioTestDataPath, string.Format(surfaceLineFormat, fileName)); string nonExistingCharacteristicFile = Path.Combine(ioTestDataPath, string.Format(krpFormat, fileName)); @@ -783,7 +885,7 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesFile, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesFile, messageProvider, surfaceLineUpdateStrategy); var importResult = true; @@ -806,14 +908,17 @@ public void Import_CharacteristicPointsFileIsEmpty_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const string fileName = "TwoValidSurfaceLines_EmptyCharacteristicPoints"; string surfaceLinesFile = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); string corruptPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(krpFormat, fileName)); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), surfaceLinesFile, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), surfaceLinesFile, messageProvider, surfaceLineUpdateStrategy); var importResult = true; @@ -846,14 +951,17 @@ public void Import_CharacteristicPointsFileHasInvalidHeader_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const string fileName = "TwoValidSurfaceLines_InvalidHeaderCharacteristicPoints"; string surfaceLinesFile = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); string corruptPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(krpFormat, fileName)); var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), surfaceLinesFile, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), surfaceLinesFile, messageProvider, surfaceLineUpdateStrategy); var importResult = true; @@ -887,6 +995,9 @@ public void Import_CharacteristicPointsFileDeletedDuringRead_AbortImportAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const string target = "Import_FileDeletedDuringRead_AbortImportAndLog"; const string source = "TwoValidSurfaceLines_WithCharacteristicPoints"; @@ -904,7 +1015,7 @@ { var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), copyTargetPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine(), copyTargetPath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((name, step, steps) => { // Delete the file being read by the import during the import itself: @@ -957,6 +1068,9 @@ public void Import_CharacteristicPointsFileHasDuplicateIdentifier_LogAndSkipsLine() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const string fileName = "TwoValidSurfaceLines_DuplicateIdentifiersCharacteristicPoints"; string surfaceLinesFile = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); string corruptPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(krpFormat, fileName)); @@ -972,7 +1086,7 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesFile, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesFile, messageProvider, surfaceLineUpdateStrategy); var importResult = true; @@ -1006,6 +1120,9 @@ public void Import_FileWithTwoValidLinesAndOneInvalidCharacteristicPointsDefinitionDueToUnparsableNumber_SkipInvalidRowAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const string fileName = "TwoValidSurfaceLines_WithOneInvalidCharacteristicPoints"; string surfaceLinesFile = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); string corruptPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(krpFormat, fileName)); @@ -1023,7 +1140,7 @@ int progressCallCount = 0; var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesFile, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesFile, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((name, step, steps) => progressCallCount++); var importResult = false; @@ -1075,6 +1192,9 @@ public void Import_FileWithTwoValidLinesAndOneCharacteristicPointsDefinition_LogMissingDefinition() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const string fileName = "TwoValidSurfaceLines_WithOneCharacteristicPointsLocation"; string surfaceLinesPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); string corruptPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(krpFormat, fileName)); @@ -1092,7 +1212,7 @@ int progressCallCount = 0; var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesPath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((name, step, steps) => progressCallCount++); var importResult = false; @@ -1138,6 +1258,9 @@ public void Import_FileWithTwoValidLinesAndThreeCharacteristicPointsDefinition_LogMissingDefinition() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const string fileName = "TwoValidSurfaceLines_WithThreeCharacteristicPointsLocations"; string surfaceLinesPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); string corruptPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(krpFormat, fileName)); @@ -1155,7 +1278,7 @@ int progressCallCount = 0; var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesPath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((name, step, steps) => progressCallCount++); var importResult = false; @@ -1207,6 +1330,9 @@ public void Import_FileWithTwoValidLinesAndCharacteristicPointNotOnGeometry_LogInvalidPointDefinition(string characteristicPointName, string fileName) { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string surfaceLinesPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); string corruptPath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(krpFormat, fileName)); @@ -1223,7 +1349,7 @@ int progressCallCount = 0; var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesPath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, surfaceLinesPath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged((name, step, steps) => progressCallCount++); var importResult = false; @@ -1273,6 +1399,11 @@ public void Import_ImportingToValidTargetWithValidFileWithCharacteristicPoints_ImportSurfaceLinesToCollection() { // Setup + const string expectedAddDataToModelProgressText = "Adding data"; + var messageProvider = mocks.StrictMock(); + messageProvider.Expect(mp => mp.GetAddDataToModelProgressText()).Return(expectedAddDataToModelProgressText); + mocks.ReplayAll(); + const int expectedNumberOfSurfaceLines = 2; const int expectedNumberOfCharacteristicPointsDefinitions = 2; @@ -1299,7 +1430,7 @@ bool progressCharacteristicPointsStarted = false; var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validSurfaceLinesFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validSurfaceLinesFilePath, messageProvider, surfaceLineUpdateStrategy); importer.SetProgressChanged(delegate(string currentStepName, int currentStep, int totalNumberOfSteps) { if (!progressStarted && callCount == 0) @@ -1325,7 +1456,7 @@ } else if (callCount <= expectedNumberOfSurfaceLines + expectedNumberOfCharacteristicPointsDefinitions + 2 + expectedNumberOfSurfaceLines) { - Assert.AreEqual("Geïmporteerde data toevoegen aan het toetsspoor.", currentStepName); + Assert.AreEqual(expectedAddDataToModelProgressText, currentStepName); } else { @@ -1380,6 +1511,9 @@ public void Import_DoesNotInterSectReferenceLine_SkipRowAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const int expectedNumberOfSurfaceLines = 1; var twovalidsurfacelinesCsv = "TwoValidSurfaceLines.csv"; string validFilePath = Path.Combine(ioTestDataPath, twovalidsurfacelinesCsv); @@ -1394,7 +1528,7 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); // Precondition CollectionAssert.IsEmpty(failureMechanism.SurfaceLines); @@ -1423,6 +1557,9 @@ public void Import_DoesInterSectReferenceLineMultipleTimes_SkipRowAndLog() { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + const int expectedNumberOfSurfaceLines = 1; var twovalidsurfacelinesCsv = "TwoValidSurfaceLines.csv"; string validFilePath = Path.Combine(ioTestDataPath, twovalidsurfacelinesCsv); @@ -1441,7 +1578,7 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); // Precondition CollectionAssert.IsEmpty(failureMechanism.SurfaceLines); @@ -1472,6 +1609,9 @@ public void Import_ExitPointGreaterOrEqualToEntryPoint_SkipRowAndLog(string fileName) { // Setup + var messageProvider = mocks.Stub(); + mocks.ReplayAll(); + string validFilePath = Path.Combine(pluginSurfaceLinesTestDataPath, string.Format(surfaceLineFormat, fileName)); var referenceLine = new ReferenceLine(); @@ -1485,7 +1625,7 @@ var failureMechanism = new PipingFailureMechanism(); var surfaceLineUpdateStrategy = new TestSurfaceLineUpdateStrategy(); - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, surfaceLineUpdateStrategy); + var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, referenceLine, validFilePath, messageProvider, surfaceLineUpdateStrategy); // Precondition CollectionAssert.IsEmpty(failureMechanism.SurfaceLines); @@ -1518,6 +1658,8 @@ observableA.Expect(o => o.NotifyObservers()); var observableB = mocks.StrictMock(); observableB.Expect(o => o.NotifyObservers()); + + var messageProvider = mocks.Stub(); mocks.ReplayAll(); const string fileName = "TwoValidSurfaceLines_WithCharacteristicPoints"; @@ -1543,14 +1685,14 @@ new RingtoetsPipingSurfaceLineCollection(), referenceLine, validSurfaceLinesFilePath, + messageProvider, updateStrategy); importer.Import(); // Call importer.DoPostImport(); - // Assert - mocks.VerifyAll(); + // Asserts done in the TearDown method } private static RingtoetsPipingSurfaceLine[] AssertSuccessfulImport(bool importResult,