Index: Core/Common/src/Core.Common.Base/IO/FileImporterBase.cs =================================================================== diff -u -re2719484be4a10aecf59be5a999943bb01688ec0 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Core/Common/src/Core.Common.Base/IO/FileImporterBase.cs (.../FileImporterBase.cs) (revision e2719484be4a10aecf59be5a999943bb01688ec0) +++ Core/Common/src/Core.Common.Base/IO/FileImporterBase.cs (.../FileImporterBase.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -20,42 +20,22 @@ // All rights reserved. using System.Collections.Generic; -using System.Drawing; using System.Linq; -using Core.Common.Utils.Reflection; - namespace Core.Common.Base.IO { /// /// Abstract class for file importers, providing an implementation of sending object /// change notifications for objects that have been affected /// during the import. /// - /// The type of the item supported by the importer. /// - public abstract class FileImporterBase : IFileImporter + public abstract class FileImporterBase : IFileImporter { - /// - /// Gets or sets value indicating if a cancel request has been made. When true, no - /// changes should be made to the data model unless the importer is already in progress - /// of changing the data model. - /// - protected bool Canceled { get; set; } - - public abstract string Name { get; } - public abstract string Category { get; } - public abstract Bitmap Image { get; } - public abstract string FileFilter { get; } public abstract ProgressChangedDelegate ProgressChanged { protected get; set; } - public virtual bool CanImportOn(object targetItem) - { - return targetItem != null && targetItem.GetType().Implements(); - } + public abstract bool Import(string filePath); - public abstract bool Import(object targetItem, string filePath); - public void Cancel() { Canceled = true; @@ -81,6 +61,13 @@ } /// + /// Gets or sets value indicating if a cancel request has been made. When true, no + /// changes should be made to the data model unless the importer is already in progress + /// of changing the data model. + /// + protected bool Canceled { get; set; } + + /// /// Gets all objects that have been affected during the call /// that implement and which are were not the targeted object /// to import the data to. Index: Core/Common/src/Core.Common.Base/IO/IFileImporter.cs =================================================================== diff -u -r64d5609bb2912cd52dc74deffdd189222e240599 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Core/Common/src/Core.Common.Base/IO/IFileImporter.cs (.../IFileImporter.cs) (revision 64d5609bb2912cd52dc74deffdd189222e240599) +++ Core/Common/src/Core.Common.Base/IO/IFileImporter.cs (.../IFileImporter.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -19,8 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System.Drawing; - namespace Core.Common.Base.IO { /// @@ -29,50 +27,17 @@ public interface IFileImporter { /// - /// Gets the name of the . - /// - string Name { get; } - - /// - /// Gets the category of the . - /// - string Category { get; } - - /// - /// Gets the image of the . - /// - /// This image can be used in selection and/or progress dialogs. - Bitmap Image { get; } - - /// - /// Gets the file filter of the . - /// - /// - /// An example string would be: - /// "My file format1 (*.ext1)|*.ext1|My file format2 (*.ext2)|*.ext2" - /// - string FileFilter { get; } - - /// /// Sets the action to perform when progress has changed. /// ProgressChangedDelegate ProgressChanged { set; } /// - /// Determines whether this importer can import data to target item. - /// - /// The item to perform the import on. - /// True if the import was successful; false otherwise. - bool CanImportOn(object targetItem); - - /// /// This method imports the data to an item from a file at the given location. /// - /// The item to perform the import on. /// The path of the file to import the data from. /// true if the import was successful. false otherwise. /// Implementations of this import method are allowed to throw exceptions of any kind. - bool Import(object targetItem, string filePath); + bool Import(string filePath); /// /// This method cancels an import. Index: Core/Common/src/Core.Common.Base/Service/FileImportActivity.cs =================================================================== diff -u -re3f9dffa91a0def0b6e6bc7dfabef74cc64745c5 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Core/Common/src/Core.Common.Base/Service/FileImportActivity.cs (.../FileImportActivity.cs) (revision e3f9dffa91a0def0b6e6bc7dfabef74cc64745c5) +++ Core/Common/src/Core.Common.Base/Service/FileImportActivity.cs (.../FileImportActivity.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -40,29 +40,31 @@ /// The to use for importing the data. /// The target object to import the data to. /// The path of the file to import the data from. + /// The name of the importer. /// Thrown when any input argument is null. - public FileImportActivity(IFileImporter fileImporter, object target, string filePath) + public FileImportActivity(IFileImporter fileImporter, object target, string filePath, string name) { if (fileImporter == null) { throw new ArgumentNullException("fileImporter"); } - if (target == null) { throw new ArgumentNullException("target"); } - if (filePath == null) { throw new ArgumentNullException("filePath"); } + if (name == null) + { + throw new ArgumentNullException("name"); + } this.fileImporter = fileImporter; this.target = target; this.filePath = filePath; - - Name = fileImporter.Name; + Name = name; } /// @@ -71,9 +73,13 @@ /// This method can throw exceptions of any kind. protected override void OnRun() { - fileImporter.ProgressChanged = (currentStepName, currentStep, totalSteps) => { ProgressText = string.Format(Resources.FileImportActivity_ImportFromFile_Step_CurrentProgress_0_of_TotalProgress_1_ProgressText_2, currentStep, totalSteps, currentStepName); }; + fileImporter.ProgressChanged = (currentStepName, currentStep, totalSteps) => + { + ProgressText = string.Format(Resources.FileImportActivity_ImportFromFile_Step_CurrentProgress_0_of_TotalProgress_1_ProgressText_2, + currentStep, totalSteps, currentStepName); + }; - fileImporter.Import(target, filePath); + fileImporter.Import(filePath); } protected override void OnCancel() Index: Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs =================================================================== diff -u -r3a1baec7e10e459689c326e20e95e140c597b0d6 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision 3a1baec7e10e459689c326e20e95e140c597b0d6) +++ Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -23,7 +23,6 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; -using Core.Common.Base.IO; using Core.Common.Base.Service; using Core.Common.Gui.Forms; using Core.Common.Gui.Forms.ProgressDialog; @@ -62,13 +61,13 @@ public void ImportOn(object target) { - IFileImporter importer = GetSupportedImporterUsingDialog(target); - if (importer == null) + ImportInfo importInfo = GetSupportedImporterUsingDialog(target); + if (importInfo == null) { return; } - ImportItemsUsingDialog(importer, target); + ImportItemsUsingDialog(importInfo, target); } private IEnumerable GetSupportedImportInfos(object target) @@ -83,10 +82,10 @@ return importInfos.Where(info => (info.DataType == targetType || targetType.Implements(info.DataType)) && info.IsEnabled(target)); } - private IFileImporter GetSupportedImporterUsingDialog(object target) + private ImportInfo GetSupportedImporterUsingDialog(object target) { - IFileImporter[] importers = GetSupportedImportInfos(target).Select(i => i.CreateFileImporter(target)).ToArray(); - if (importers.Length == 0) + ImportInfo[] supportedImportInfos = GetSupportedImportInfos(target).ToArray(); + if (supportedImportInfos.Length == 0) { MessageBox.Show(Resources.GuiImportHandler_GetSupportedImporterForTargetType_No_importer_available_for_this_item, Resources.GuiImportHandler_GetSupportedImporterForTargetType_Error); @@ -95,46 +94,46 @@ return null; } - if (importers.Length == 1) + if (supportedImportInfos.Length == 1) { - return importers[0]; + return supportedImportInfos[0]; } using (var selectImporterDialog = new SelectItemDialog(dialogParent, Resources.GuiImportHandler_GetSupportedImporterUsingDialog_Select_importer)) { - foreach (IFileImporter importer in importers) + foreach (ImportInfo importInfo in supportedImportInfos) { - string category = string.IsNullOrEmpty(importer.Category) ? + string category = string.IsNullOrEmpty(importInfo.Category) ? Resources.GuiImportHandler_GetSupportedImporterForTargetType_Data_Import : - importer.Category; - Bitmap itemImage = importer.Image ?? Resources.brick; + importInfo.Category; + Image itemImage = importInfo.Image ?? Resources.brick; - selectImporterDialog.AddItemType(importer.Name, category, itemImage, null); + selectImporterDialog.AddItemType(importInfo.Name, category, itemImage, null); } if (selectImporterDialog.ShowDialog() == DialogResult.OK) { - return importers.First(i => i.Name == selectImporterDialog.SelectedItemTypeName); + return supportedImportInfos.First(i => i.Name == selectImporterDialog.SelectedItemTypeName); } } return null; } - private void ImportItemsUsingDialog(IFileImporter importer, object target) + private void ImportItemsUsingDialog(ImportInfo importInfo, object target) { using (var dialog = new OpenFileDialog { Multiselect = true, - Filter = importer.FileFilter, + Filter = importInfo.FileFilter, Title = Resources.OpenFileDialog_Title }) { if (dialog.ShowDialog(dialogParent) == DialogResult.OK) { log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data); - FileImportActivity[] importActivitiesToRun = dialog.FileNames.Select(f => new FileImportActivity(importer, target, f)).ToArray(); + FileImportActivity[] importActivitiesToRun = dialog.FileNames.Select(f => new FileImportActivity(importInfo.CreateFileImporter(target), target, f, importInfo.Name)).ToArray(); ActivityProgressDialogRunner.Run(dialogParent, importActivitiesToRun); } } Index: Core/Common/test/Core.Common.Base.Test/IO/FileImporterBaseTest.cs =================================================================== diff -u -re2719484be4a10aecf59be5a999943bb01688ec0 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Core/Common/test/Core.Common.Base.Test/IO/FileImporterBaseTest.cs (.../FileImporterBaseTest.cs) (revision e2719484be4a10aecf59be5a999943bb01688ec0) +++ Core/Common/test/Core.Common.Base.Test/IO/FileImporterBaseTest.cs (.../FileImporterBaseTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -21,12 +21,8 @@ using System; using System.Collections.Generic; -using System.Drawing; - using Core.Common.Base.IO; - using NUnit.Framework; - using Rhino.Mocks; namespace Core.Common.Base.Test.IO @@ -47,64 +43,6 @@ } [Test] - public void CanImportOn_ObjectIsNull_ReturnFalse() - { - // Setup - var importer = new SimpleFileImporter(); - - // Call - var canImportOn = importer.CanImportOn(null); - - // Assert - Assert.IsFalse(canImportOn); - } - - [Test] - public void CanImportOn_ObjectIsOfCorrectType_ReturnTrue() - { - // Setup - var importer = new SimpleFileImporter(); - - var targetItem = new SimpleFileImporterTargetType(); - - // Call - var canImportOn = importer.CanImportOn(targetItem); - - // Assert - Assert.IsTrue(canImportOn); - } - - [Test] - public void CanImportOn_ObjectInheritsOfCorrectType_ReturnTrue() - { - // Setup - var importer = new SimpleFileImporter(); - - var targetItem = new InheritorOfImporterTargetType(); - - // Call - var canImportOn = importer.CanImportOn(targetItem); - - // Assert - Assert.IsTrue(canImportOn); - } - - [Test] - public void CanImportOn_ObjectTypeDoesNotMatch_ReturnFalse() - { - // Setup - var importer = new SimpleFileImporter(); - - var targetItem = new object(); - - // Call - var canImportOn = importer.CanImportOn(targetItem); - - // Assert - Assert.IsFalse(canImportOn); - } - - [Test] public void DoPostImportUpdates_TargetIsObservable_NotifyObservers() { // Setup @@ -213,70 +151,28 @@ Assert.AreEqual(1, progressChangedCallCount); } - private class SimpleFileImporter : FileImporterBase + private class SimpleFileImporter : FileImporterBase { - public override string Name - { - get - { - throw new NotImplementedException(); - } - } + public override ProgressChangedDelegate ProgressChanged { protected get; set; } + public IObservable[] AffectedNonTargetObservableInstancesOverride { private get; set; } - public override string Category + public void TestNotifyProgress(string currentStepName, int currentStep, int totalNumberOfSteps) { - get - { - throw new NotImplementedException(); - } + NotifyProgress(currentStepName, currentStep, totalNumberOfSteps); } - public override Bitmap Image + public override bool Import(string filePath) { - get - { - throw new NotImplementedException(); - } + throw new NotImplementedException(); } - public override string FileFilter - { - get - { - throw new NotImplementedException(); - } - } - - public override ProgressChangedDelegate ProgressChanged { protected get; set; } - public IObservable[] AffectedNonTargetObservableInstancesOverride { private get; set; } - protected override IEnumerable AffectedNonTargetObservableInstances { get { return AffectedNonTargetObservableInstancesOverride ?? base.AffectedNonTargetObservableInstances; } } - - public override bool Import(object targetItem, string filePath) - { - throw new NotImplementedException(); - } - - public void TestNotifyProgress(string currentStepName, int currentStep, int totalNumberOfSteps) - { - NotifyProgress(currentStepName, currentStep, totalNumberOfSteps); - } } - - private class SimpleFileImporterTargetType - { - - } - - private class InheritorOfImporterTargetType : SimpleFileImporterTargetType - { - - } } } \ No newline at end of file Index: Core/Common/test/Core.Common.Base.Test/Service/FileImportActivityTest.cs =================================================================== diff -u -rf64dceaa32788bad28dcf09f4a1c3150595f1327 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Core/Common/test/Core.Common.Base.Test/Service/FileImportActivityTest.cs (.../FileImportActivityTest.cs) (revision f64dceaa32788bad28dcf09f4a1c3150595f1327) +++ Core/Common/test/Core.Common.Base.Test/Service/FileImportActivityTest.cs (.../FileImportActivityTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Drawing; using Core.Common.Base.IO; using Core.Common.Base.Service; using NUnit.Framework; @@ -35,7 +34,7 @@ public void Constructor_ImporterEqualsNull_ArgumentExceptionIsThrown() { // Setup - TestDelegate test = () => new FileImportActivity(null, new object(), ""); + TestDelegate test = () => new FileImportActivity(null, new object(), "", ""); // Call var message = Assert.Throws(test).Message; @@ -53,7 +52,7 @@ mocks.ReplayAll(); - TestDelegate test = () => new FileImportActivity(fileImporter, null, ""); + TestDelegate test = () => new FileImportActivity(fileImporter, null, "", ""); // Call var message = Assert.Throws(test).Message; @@ -72,7 +71,7 @@ mocks.ReplayAll(); - TestDelegate test = () => new FileImportActivity(fileImporter, new object(), null); + TestDelegate test = () => new FileImportActivity(fileImporter, new object(), null, ""); // Call var message = Assert.Throws(test).Message; @@ -88,34 +87,31 @@ // Setup var mocks = new MockRepository(); var fileImporter = mocks.Stub(); - - fileImporter.Stub(i => i.Name).Return("Importer name"); - mocks.ReplayAll(); + const string name = "Importer name"; + // Call - var fileImportActivity = new FileImportActivity(fileImporter, new object(), ""); + var fileImportActivity = new FileImportActivity(fileImporter, new object(), "", name); // Assert - Assert.AreEqual(fileImporter.Name, fileImportActivity.Name); + Assert.AreEqual(name, fileImportActivity.Name); mocks.VerifyAll(); } [Test] public void Run_FileImportActivityWithFileImporter_ProvidedFileShouldBeImported() { // Setup - var mocks = new MockRepository(); - var fileImporter = mocks.Stub(); var target = new object(); + var mocks = new MockRepository(); + var fileImporter = mocks.Stub(); fileImporter.Stub(x => x.ProgressChanged = null).IgnoreArguments(); - fileImporter.Expect(x => x.Name).Return(string.Empty); - fileImporter.Expect(i => i.Import(target, "file")).Return(true); - + fileImporter.Expect(i => i.Import("file")).Return(true); mocks.ReplayAll(); - var fileImportActivity = new FileImportActivity(fileImporter, target, "file"); + var fileImportActivity = new FileImportActivity(fileImporter, target, "file", ""); // Call fileImportActivity.Run(); @@ -128,17 +124,15 @@ public void Cancel_FileImportActivityWithFileImporter_CancelsImporter() { // Setup - var mocks = new MockRepository(); - var fileImporter = mocks.Stub(); var target = new object(); + var mocks = new MockRepository(); + var fileImporter = mocks.Stub(); fileImporter.Stub(x => x.ProgressChanged = null).IgnoreArguments(); - fileImporter.Expect(x => x.Name).Return(string.Empty); fileImporter.Expect(x => x.Cancel()); - mocks.ReplayAll(); - var fileImportActivity = new FileImportActivity(fileImporter, target, ""); + var fileImportActivity = new FileImportActivity(fileImporter, target, "", ""); // Call fileImportActivity.Cancel(); @@ -154,7 +148,7 @@ var target = new object(); var fileImporter = new SimpleFileImporter(); - var fileImportActivity = new FileImportActivity(fileImporter, target, "file"); + var fileImportActivity = new FileImportActivity(fileImporter, target, "file", ""); // Call fileImportActivity.Run(); // Reuse the activity @@ -169,15 +163,13 @@ // Setup var mocks = new MockRepository(); var observer = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()); - mocks.ReplayAll(); var target = new ObservableList(); target.Attach(observer); var fileImporter = new SimpleFileImporter(); - var fileImportActivity = new FileImportActivity(fileImporter, target, ""); + var fileImportActivity = new FileImportActivity(fileImporter, target, "", ""); // Call fileImportActivity.Finish(); @@ -186,48 +178,16 @@ mocks.VerifyAll(); } - private class SimpleFileImporter : FileImporterBase + private class SimpleFileImporter : FileImporterBase { - public override string Name - { - get - { - return ""; - } - } - - public override string Category - { - get - { - return ""; - } - } - - public override Bitmap Image - { - get - { - return null; - } - } - - public override string FileFilter - { - get - { - return ""; - } - } - public override ProgressChangedDelegate ProgressChanged { protected get; set; } - public override bool Import(object targetItem, string filePath) + public override bool Import(string filePath) { NotifyProgress("Step description", 1, 10); return true; } } } -} +} \ No newline at end of file Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs =================================================================== diff -u -r8b5f0a2d2a65af3a54d892810e14e2b0499e8dca -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision 8b5f0a2d2a65af3a54d892810e14e2b0499e8dca) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -89,7 +89,7 @@ using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(GetType().Assembly, true, "traject_6-3.shp", "traject_6-3.dbf", "traject_6-3.prj", "traject_6-3.shx")) { var importer = new ReferenceLineImporter(demoAssessmentSection); - importer.Import(null, Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3.shp")); + importer.Import(Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3.shp")); } } @@ -118,7 +118,7 @@ if (i == 0) { var importer = new FailureMechanismSectionsImporter(failureMechanisms[i], demoAssessmentSection.ReferenceLine); - importer.Import(null, Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3_vakken.shp")); + importer.Import(Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3_vakken.shp")); } else { @@ -146,13 +146,13 @@ using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(GetType().Assembly, true, "DR6_surfacelines.csv", "DR6_surfacelines.krp.csv")) { var surfaceLinesImporter = new PipingSurfaceLinesCsvImporter(pipingFailureMechanism.SurfaceLines, demoAssessmentSection.ReferenceLine); - surfaceLinesImporter.Import(null, Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_surfacelines.csv")); + surfaceLinesImporter.Import(Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_surfacelines.csv")); } using (var embeddedResourceFileWriter = new EmbeddedResourceFileWriter(GetType().Assembly, true, "DR6.soil")) { var soilProfilesImporter = new PipingSoilProfilesImporter(pipingFailureMechanism.StochasticSoilModels); - soilProfilesImporter.Import(null, Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil")); + soilProfilesImporter.Import(Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil")); } var calculation = new PipingCalculationScenario(pipingFailureMechanism.GeneralInput); Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineImporter.cs =================================================================== diff -u -r96ae727341e257e67f04ffc76552b0364b4ad8c2 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineImporter.cs (.../ReferenceLineImporter.cs) (revision 96ae727341e257e67f04ffc76552b0364b4ad8c2) +++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineImporter.cs (.../ReferenceLineImporter.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; using System.Windows.Forms; using Core.Common.Base; @@ -31,7 +30,6 @@ using log4net; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; -using Ringtoets.Common.Forms.PresentationObjects; using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; using RingtoetsFormsResources = Ringtoets.Common.Forms.Properties.Resources; using RingtoetsDataResources = Ringtoets.Common.Data.Properties.Resources; @@ -43,7 +41,7 @@ /// Imports a and stores in on a , /// taking data from a shapefile containing a single polyline. /// - public class ReferenceLineImporter : FileImporterBase + public class ReferenceLineImporter : FileImporterBase { private static readonly ILog log = LogManager.GetLogger(typeof(ReferenceLineImporter)); private readonly IAssessmentSection importTarget; @@ -64,41 +62,9 @@ this.importTarget = importTarget; } - public override string Name - { - get - { - return RingtoetsDataResources.ReferenceLine_DisplayName; - } - } - - public override string Category - { - get - { - return RingtoetsFormsResources.Ringtoets_Category; - } - } - - public override Bitmap Image - { - get - { - return RingtoetsFormsResources.ReferenceLineIcon; - } - } - - public override string FileFilter - { - get - { - return RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter; - } - } - public override ProgressChangedDelegate ProgressChanged { protected get; set; } - public override bool Import(object targetItem, string filePath) + public override bool Import(string filePath) { Canceled = false; changedObservables.Clear(); Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineImporterTest.cs =================================================================== diff -u -r96ae727341e257e67f04ffc76552b0364b4ad8c2 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineImporterTest.cs (.../ReferenceLineImporterTest.cs) (revision 96ae727341e257e67f04ffc76552b0364b4ad8c2) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineImporterTest.cs (.../ReferenceLineImporterTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -64,12 +64,7 @@ var importer = new ReferenceLineImporter(assessmentSection); // Assert - Assert.IsInstanceOf>(importer); - Assert.AreEqual("Referentielijn", importer.Name); - Assert.AreEqual("Algemeen", importer.Category); - TestHelper.AssertImagesAreEqual(RingtoetsFormsResources.ReferenceLineIcon, importer.Image); - Assert.AreEqual(RingtoetsCommonIoResources.DataTypeDisplayName_shape_file_filter, importer.FileFilter); - + Assert.IsInstanceOf(importer); mocks.VerifyAll(); } @@ -84,12 +79,10 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.Combine("ReferenceLine", "traject_10-2.shp")); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var importer = new ReferenceLineImporter(assessmentSection); // Call - bool importSuccesful = importer.Import(referenceLineContext, path); + bool importSuccesful = importer.Import(path); // Assert Assert.IsTrue(importSuccesful); @@ -112,8 +105,6 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.Combine("ReferenceLine", "traject_10-2.shp")); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var expectedProgressMessages = new[] { new ExpectedProgressNotification @@ -138,7 +129,7 @@ }; // Call - importer.Import(referenceLineContext, path); + importer.Import(path); // Assert Assert.AreEqual(expectedProgressMessages.Length, progressChangedCallCount); @@ -155,13 +146,11 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.DirectorySeparatorChar.ToString()); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var importer = new ReferenceLineImporter(assessmentSection); // Call bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(referenceLineContext, path); + Action call = () => importSuccesful = importer.Import(path); // Assert var expectedMessage = string.Format(@"Fout bij het lezen van bestand '{0}': Bestandspad mag niet verwijzen naar een lege bestandsnaam. ", path) + Environment.NewLine + @@ -182,13 +171,11 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "I_dont_exist"); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var importer = new ReferenceLineImporter(assessmentSection); // Call bool importSuccesful = true; - Action call = () => importSuccesful = importer.Import(referenceLineContext, path); + Action call = () => importSuccesful = importer.Import(path); // Assert var expectedMessage = string.Format(@"Fout bij het lezen van bestand '{0}': Het bestand bestaat niet. ", path) + Environment.NewLine + @@ -232,8 +219,6 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "traject_10-2.shp"); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var importer = new ReferenceLineImporter(assessmentSection); string messageBoxTitle = null, messageBoxText = null; DialogBoxHandler = (name, wnd) => @@ -247,7 +232,7 @@ }; // Call - bool importSuccesful = importer.Import(referenceLineContext, path); + bool importSuccesful = importer.Import(path); // Assert Assert.IsFalse(importSuccesful); @@ -305,8 +290,6 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.Combine("ReferenceLine", "traject_10-2.shp")); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var importer = new ReferenceLineImporter(assessmentSection); string messageBoxTitle = null, messageBoxText = null; @@ -321,7 +304,7 @@ }; // Call - bool importSuccesful = importer.Import(referenceLineContext, path); + bool importSuccesful = importer.Import(path); // Assert Assert.IsTrue(importSuccesful); @@ -369,8 +352,6 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.Combine("ReferenceLine", "traject_10-2.shp")); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var expectedProgressMessages = new[] { new ExpectedProgressNotification @@ -409,7 +390,7 @@ }; // Call - importer.Import(referenceLineContext, path); + importer.Import(path); // Assert Assert.AreEqual(expectedProgressMessages.Length, progressChangedCallCount); @@ -429,8 +410,6 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "traject_10-2.shp"); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var importer = new ReferenceLineImporter(assessmentSection); DialogBoxHandler = (name, wnd) => @@ -442,7 +421,7 @@ }; // Call - bool importSuccesful = importer.Import(referenceLineContext, path); + bool importSuccesful = importer.Import(path); // Assert Assert.IsFalse(importSuccesful); @@ -465,8 +444,6 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "traject_10-2.shp"); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var importer = new ReferenceLineImporter(assessmentSection); DialogBoxHandler = (name, wnd) => @@ -485,7 +462,7 @@ }; // Call - Action call = () => importer.Import(referenceLineContext, path); + Action call = () => importer.Import(path); // Assert TestHelper.AssertLogMessageIsGenerated(call, "Referentielijn importeren afgebroken. Geen data ingelezen.", 1); @@ -503,13 +480,11 @@ var path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, Path.Combine("ReferenceLine", "traject_10-2.shp")); - var referenceLineContext = new ReferenceLineContext(assessmentSection); - var importer = new ReferenceLineImporter(assessmentSection); importer.Cancel(); // Call - bool importSuccesful = importer.Import(referenceLineContext, path); + bool importSuccesful = importer.Import(path); // Assert Assert.IsTrue(importSuccesful); @@ -589,7 +564,7 @@ }; // Precondition - Assert.IsTrue(importer.Import(referenceLineContext, path)); + Assert.IsTrue(importer.Import(path)); // Call importer.DoPostImportUpdates(referenceLineContext); @@ -629,7 +604,7 @@ }; // Precondition - Assert.IsTrue(importer.Import(referenceLineContext, path)); + Assert.IsTrue(importer.Import(path)); // Call importer.DoPostImportUpdates(referenceLineContext); @@ -680,7 +655,7 @@ }; // Precondition - Assert.IsFalse(importer.Import(referenceLineContext, path)); + Assert.IsFalse(importer.Import(path)); // Call importer.DoPostImportUpdates(referenceLineContext); @@ -757,14 +732,14 @@ }; // Precondition - Assert.IsTrue(importer.Import(referenceLineContext, path)); + Assert.IsTrue(importer.Import(path)); importer.Cancel(); DialogBoxHandler = (name, wnd) => { var messageBoxTester = new MessageBoxTester(wnd); messageBoxTester.ClickOk(); }; - Assert.IsTrue(importer.Import(referenceLineContext, path)); + Assert.IsTrue(importer.Import(path)); // Call importer.DoPostImportUpdates(referenceLineContext); Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs =================================================================== diff -u -r1ee86097840952b98a26fcf00a502fb7ccd53307 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision 1ee86097840952b98a26fcf00a502fb7ccd53307) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -22,7 +22,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Drawing; using System.IO; using System.Linq; using Core.Common.Base; @@ -46,7 +45,7 @@ /// /// Imports point shapefiles containing dike profile locations and text file containing the foreland/dike schematizations. /// - public class DikeProfilesImporter : FileImporterBase + public class DikeProfilesImporter : FileImporterBase { private readonly ObservableList importTarget; private readonly ReferenceLine referenceLine; @@ -73,47 +72,10 @@ this.referenceLine = referenceLine; } - public override string Name - { - get - { - return Resources.DikeProfilesImporter_DisplayName; - } - } - - public override string Category - { - get - { - return RingtoetsFormsResources.Ringtoets_Category; - } - } - - public override Bitmap Image - { - get - { - return Resources.DikeProfile; - } - } - - public override string FileFilter - { - get - { - return RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter; - } - } - public override ProgressChangedDelegate ProgressChanged { protected get; set; } - public override bool CanImportOn(object targetItem) + public override bool Import(string filePath) { - return base.CanImportOn(targetItem) && IsReferenceLineAvailable(targetItem); - } - - public override bool Import(object targetItem, string filePath) - { ReadResult importDikeProfilesResult = ReadDikeProfileLocations(filePath); if (importDikeProfilesResult.CriticalErrorOccurred) { Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsScenariosViewIntegrationTest.cs =================================================================== diff -u -r1ee86097840952b98a26fcf00a502fb7ccd53307 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsScenariosViewIntegrationTest.cs (.../GrassCoverErosionInwardsScenariosViewIntegrationTest.cs) (revision 1ee86097840952b98a26fcf00a502fb7ccd53307) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsScenariosViewIntegrationTest.cs (.../GrassCoverErosionInwardsScenariosViewIntegrationTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -29,7 +29,6 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.Helpers; using Ringtoets.GrassCoverErosionInwards.Data; -using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionInwards.Forms.Views; using Ringtoets.GrassCoverErosionInwards.Plugin.FileImporter; using Ringtoets.Integration.Data; @@ -100,7 +99,7 @@ var dikeProfilesImporter = new DikeProfilesImporter(assessmentSection.GrassCoverErosionInwards.DikeProfiles, assessmentSection.ReferenceLine); - dikeProfilesImporter.Import(null, filePath); + dikeProfilesImporter.Import(filePath); // Call foreach (var profile in assessmentSection.GrassCoverErosionInwards.DikeProfiles) @@ -147,7 +146,7 @@ var dikeProfilesImporter = new DikeProfilesImporter(assessmentSection.GrassCoverErosionInwards.DikeProfiles, assessmentSection.ReferenceLine); - dikeProfilesImporter.Import(null, filePath); + dikeProfilesImporter.Import(filePath); foreach (var profile in assessmentSection.GrassCoverErosionInwards.DikeProfiles) { @@ -199,7 +198,7 @@ var dikeProfilesImporter = new DikeProfilesImporter(assessmentSection.GrassCoverErosionInwards.DikeProfiles, assessmentSection.ReferenceLine); - dikeProfilesImporter.Import(null, filePath); + dikeProfilesImporter.Import(filePath); foreach (var profile in assessmentSection.GrassCoverErosionInwards.DikeProfiles) { Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/IntegrationTestHelper.cs =================================================================== diff -u -re58ce50bf65d8fa430a1ea7c651256a244f5d2b5 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/IntegrationTestHelper.cs (.../IntegrationTestHelper.cs) (revision e58ce50bf65d8fa430a1ea7c651256a244f5d2b5) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/IntegrationTestHelper.cs (.../IntegrationTestHelper.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -50,7 +50,8 @@ { var activity = new FileImportActivity(new ReferenceLineImporter(assessmentSection), new ReferenceLineContext(assessmentSection), - Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3.shp")); + Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3.shp"), + "ReferenceLineImporter"); activity.Run(); activity.Finish(); @@ -74,7 +75,8 @@ { var activity = new FileImportActivity(new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine), new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3_vakken.shp")); + Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3_vakken.shp"), + "FailureMechanismSectionsImporter"); activity.Run(); activity.Finish(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporter/DikeProfilesImporterTest.cs =================================================================== diff -u -r96ae727341e257e67f04ffc76552b0364b4ad8c2 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporter/DikeProfilesImporterTest.cs (.../DikeProfilesImporterTest.cs) (revision 96ae727341e257e67f04ffc76552b0364b4ad8c2) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/FileImporter/DikeProfilesImporterTest.cs (.../DikeProfilesImporterTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -64,89 +64,24 @@ var importer = new DikeProfilesImporter(importTarget, referenceLine); // Assert - Assert.IsInstanceOf>(importer); - Assert.AreEqual("Dijkprofiel locaties", importer.Name); - Assert.AreEqual("Algemeen", importer.Category); - TestHelper.AssertImagesAreEqual(GrassCoverErosionInwardsPluginResources.DikeProfile, importer.Image); - Assert.AreEqual(RingtoetsCommonIoResources.DataTypeDisplayName_shape_file_filter, importer.FileFilter); + Assert.IsInstanceOf(importer); } - + [Test] - public void CanImportOn_ValidContext_ReturnTrue() - { - // Setup - var referencePoints = new List - { - new Point2D(131223.2, 548393.4), - new Point2D(133854.3, 545323.1), - new Point2D(135561.0, 541920.3), - new Point2D(136432.1, 538235.2), - new Point2D(136039.4, 533920.2) - }; - var referenceLine = new ReferenceLine(); - referenceLine.SetGeometry(referencePoints); - - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - assessmentSection.ReferenceLine = referenceLine; - - mocks.ReplayAll(); - - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); - - // Call - var canImport = dikeProfilesImporter.CanImportOn(targetContext); - - // Assert - Assert.IsTrue(canImport); - mocks.VerifyAll(); - } - - [Test] - public void CanImportOn_ContextWithoutReferenceLine_ReturnFalse() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - mocks.ReplayAll(); - - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, new ReferenceLine()); - - // Call - var canImport = dikeProfilesImporter.CanImportOn(targetContext); - - // Assert - Assert.IsFalse(canImport); - mocks.VerifyAll(); - } - - [Test] [TestCase("")] [TestCase(" ")] [TestCase(null)] public void Import_FromInvalidEmptyPath_FalseAndLogError(string filePath) { // Setup var referenceLine = new ReferenceLine(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSection = mockRepository.Stub(); - assessmentSection.ReferenceLine = referenceLine; - mockRepository.ReplayAll(); - - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -157,7 +92,6 @@ StringAssert.StartsWith(messageArray[0], message); }); Assert.IsFalse(importResult); - mockRepository.VerifyAll(); } [Test] @@ -166,7 +100,7 @@ // Setup string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.GrassCoverErosionInwards.IO, Path.Combine("DikeProfiles", "AllOkTestData", "Voorlanden 12-2.shp")); - + var invalidFileNameChars = Path.GetInvalidFileNameChars(); var invalidPath = filePath.Replace('d', invalidFileNameChars[0]); @@ -179,13 +113,11 @@ var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, invalidPath); + Action call = () => importResult = dikeProfilesImporter.Import(invalidPath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -212,15 +144,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, folderPath); + Action call = () => importResult = dikeProfilesImporter.Import(folderPath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -254,15 +184,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -295,15 +223,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -333,15 +259,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -368,15 +292,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -403,19 +325,14 @@ ReferenceLine referenceLine = CreateMatchingReferenceLine(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var assessmentSection = mockRepository.Stub(); - assessmentSection.ReferenceLine = referenceLine; - mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -425,7 +342,6 @@ Assert.AreEqual(message, messageArray[0]); }); Assert.IsTrue(importResult); - mockRepository.VerifyAll(); } [Test] @@ -442,15 +358,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -496,7 +410,7 @@ var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert var expectedMessages = Enumerable.Repeat("Een dijkprofiel locatie met ID 'profiel001' ligt niet op de referentielijn. Locatie wordt overgeslagen.", 5).ToArray(); @@ -538,7 +452,7 @@ var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert string expectedMessage = "Een dijkprofiel locatie met ID 'profiel005' ligt niet op de referentielijn. Locatie wordt overgeslagen."; @@ -572,7 +486,7 @@ targetContext.Attach(observer); // Call - bool importResult = dikeProfilesImporter.Import(targetContext, filePath); + bool importResult = dikeProfilesImporter.Import(filePath); // Assert Assert.IsTrue(importResult); @@ -616,7 +530,7 @@ targetContext.Attach(observer); // Call - dikeProfilesImporter.Import(targetContext, filePath); + dikeProfilesImporter.Import(filePath); DikeProfile dikeProfile = targetContext.WrappedData[4]; // Assert @@ -653,7 +567,7 @@ targetContext.Attach(observer); // Call - bool importResult = dikeProfilesImporter.Import(targetContext, filePath); + bool importResult = dikeProfilesImporter.Import(filePath); // Assert Assert.IsTrue(importResult); @@ -700,7 +614,7 @@ bool importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert Action> asserts = messages => @@ -728,14 +642,12 @@ var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - // Precondition dikeProfilesImporter.Cancel(); bool importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessageIsGenerated(call, "Dijkprofielen importeren is afgebroken. Geen data ingelezen.", 1); @@ -761,11 +673,11 @@ var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); dikeProfilesImporter.Cancel(); - bool importResult = dikeProfilesImporter.Import(targetContext, filePath); + bool importResult = dikeProfilesImporter.Import(filePath); Assert.IsFalse(importResult); // Call - importResult = dikeProfilesImporter.Import(targetContext, filePath); + importResult = dikeProfilesImporter.Import(filePath); // Assert Assert.IsTrue(importResult); @@ -793,15 +705,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); // Precondition bool importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert Action> asserts = messages => @@ -829,15 +739,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); //Precondition var importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -864,15 +772,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); // Precondition bool importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert Action> asserts = messages => @@ -905,15 +811,13 @@ assessmentSection.ReferenceLine = referenceLine; mockRepository.ReplayAll(); - var targetContext = new DikeProfilesContext(failureMechanism.DikeProfiles, assessmentSection); - var dikeProfilesImporter = new DikeProfilesImporter(failureMechanism.DikeProfiles, referenceLine); // Precondition bool importResult = true; // Call - Action call = () => importResult = dikeProfilesImporter.Import(targetContext, filePath); + Action call = () => importResult = dikeProfilesImporter.Import(filePath); // Assert Action> asserts = messages => Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ImportInfos/DikeProfilesContextImportInfoTest.cs =================================================================== diff -u -r96ae727341e257e67f04ffc76552b0364b4ad8c2 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ImportInfos/DikeProfilesContextImportInfoTest.cs (.../DikeProfilesContextImportInfoTest.cs) (revision 96ae727341e257e67f04ffc76552b0364b4ad8c2) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/ImportInfos/DikeProfilesContextImportInfoTest.cs (.../DikeProfilesContextImportInfoTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -137,7 +137,7 @@ IFileImporter importer = importInfo.CreateFileImporter(importTarget); // Assert - Assert.IsTrue(importer.Import(null, path)); + Assert.IsTrue(importer.Import(path)); mocks.VerifyAll(); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs =================================================================== diff -u -re58ce50bf65d8fa430a1ea7c651256a244f5d2b5 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs (.../FailureMechanismSectionsImporter.cs) (revision e58ce50bf65d8fa430a1ea7c651256a244f5d2b5) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs (.../FailureMechanismSectionsImporter.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; using Core.Common.Base.Geometry; using Core.Common.Base.IO; @@ -30,7 +29,6 @@ using log4net; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; -using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.IO; using Ringtoets.Integration.Plugin.Properties; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -43,7 +41,7 @@ /// Imports instances from a shapefile that contains /// one or more polylines and stores them in a . /// - public class FailureMechanismSectionsImporter : FileImporterBase + public class FailureMechanismSectionsImporter : FileImporterBase { /// /// The snapping tolerance in meters. @@ -82,47 +80,10 @@ this.referenceLine = referenceLine; } - public override string Name - { - get - { - return RingtoetsCommonFormsResources.FailureMechanism_Sections_DisplayName; - } - } - - public override string Category - { - get - { - return RingtoetsCommonFormsResources.Ringtoets_Category; - } - } - - public override Bitmap Image - { - get - { - return RingtoetsCommonFormsResources.SectionsIcon; - } - } - - public override string FileFilter - { - get - { - return RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter; - } - } - public override ProgressChangedDelegate ProgressChanged { protected get; set; } - public override bool CanImportOn(object targetItem) + public override bool Import(string filePath) { - return base.CanImportOn(targetItem) && IsReferenceLineAvailable(targetItem); - } - - public override bool Import(object targetItem, string filePath) - { NotifyProgress(Resources.FailureMechanismSectionsImporter_ProgressText_Reading_file, 1, 3); ReadResult readResults = ReadFailureMechanismSections(filePath); if (readResults.CriticalErrorOccurred) @@ -155,11 +116,6 @@ return true; } - private static bool IsReferenceLineAvailable(object targetItem) - { - return ((FailureMechanismSectionsContext) targetItem).ParentAssessmentSection.ReferenceLine != null; - } - private void HandleUserCancellingImport() { log.Info(Resources.FailureMechanismSectionsImporter_Import_cancelled_no_data_read); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs =================================================================== diff -u -re58ce50bf65d8fa430a1ea7c651256a244f5d2b5 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs (.../FailureMechanismSectionsImporterTest.cs) (revision e58ce50bf65d8fa430a1ea7c651256a244f5d2b5) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileImporters/FailureMechanismSectionsImporterTest.cs (.../FailureMechanismSectionsImporterTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -31,7 +31,6 @@ using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; -using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.IO; using Ringtoets.Integration.Plugin.FileImporters; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -87,61 +86,11 @@ var importer = new FailureMechanismSectionsImporter(failureMechanism, referenceLine); // Assert - Assert.IsInstanceOf>(importer); - Assert.AreEqual("Vakindeling", importer.Name); - Assert.AreEqual("Algemeen", importer.Category); - TestHelper.AssertImagesAreEqual(RingtoetsCommonFormsResources.SectionsIcon, importer.Image); - Assert.AreEqual(RingtoetsCommonIoResources.DataTypeDisplayName_shape_file_filter, importer.FileFilter); + Assert.IsInstanceOf(importer); mocks.VerifyAll(); } [Test] - public void CanImportOn_ValidContextWithReferenceLine_ReturnTrue() - { - // Setup - var referenceLine = new ReferenceLine(); - - var mocks = new MockRepository(); - var failureMechanism = mocks.Stub(); - var assessmentSection = mocks.Stub(); - assessmentSection.ReferenceLine = referenceLine; - mocks.ReplayAll(); - - var targetContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - var importer = new FailureMechanismSectionsImporter(failureMechanism, referenceLine); - - // Call - var canImport = importer.CanImportOn(targetContext); - - // Assert - Assert.IsTrue(canImport); - mocks.VerifyAll(); - } - - [Test] - public void CanImportOn_ValidContextWithoutReferenceLine_ReturnFalse() - { - // Setup - var mocks = new MockRepository(); - var failureMechanism = mocks.Stub(); - var assessmentSection = mocks.Stub(); - assessmentSection.ReferenceLine = null; - mocks.ReplayAll(); - - var targetContext = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); - - var importer = new FailureMechanismSectionsImporter(failureMechanism, new ReferenceLine()); - - // Call - var canImport = importer.CanImportOn(targetContext); - - // Assert - Assert.IsFalse(canImport); - mocks.VerifyAll(); - } - - [Test] public void Import_ValidFileCorrespondingToReferenceLineAndNoSectionImportedYet_ImportSections() { // Setup @@ -155,14 +104,14 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call - var importSuccessful = importer.Import(null, sectionsFilePath); + var importSuccessful = importer.Import(sectionsFilePath); // Assert Assert.IsTrue(importSuccessful); @@ -187,15 +136,15 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); failureMechanism.AddSection(new FailureMechanismSection("A", assessmentSection.ReferenceLine.Points)); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call - var importSuccessful = importer.Import(null, sectionsFilePath); + var importSuccessful = importer.Import(sectionsFilePath); // Assert Assert.IsTrue(importSuccessful); @@ -220,14 +169,14 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call - var importSuccessful = importer.Import(null, sectionsFilePath); + var importSuccessful = importer.Import(sectionsFilePath); // Assert Assert.IsTrue(importSuccessful); @@ -252,7 +201,7 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var progressChangeNotifications = new List(); @@ -264,7 +213,7 @@ }; // Call - var importSuccessful = importer.Import(null, sectionsFilePath); + var importSuccessful = importer.Import(sectionsFilePath); // Assert Assert.IsTrue(importSuccessful); @@ -299,15 +248,15 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call bool importSuccessful = true; - Action call = () => importSuccessful = importer.Import(null, sectionsFilePath); + Action call = () => importSuccessful = importer.Import(sectionsFilePath); // Assert var expectedMessage = string.Format(@"Fout bij het lezen van bestand '{0}': Bestandspad mag niet verwijzen naar een lege bestandsnaam. ", sectionsFilePath) + Environment.NewLine + @@ -331,15 +280,15 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call bool importSuccessful = true; - Action call = () => importSuccessful = importer.Import(null, sectionsFilePath); + Action call = () => importSuccessful = importer.Import(sectionsFilePath); // Assert var expectedMessage = string.Format(@"Fout bij het lezen van bestand '{0}': Het bestand bestaat niet. ", sectionsFilePath) + Environment.NewLine + @@ -364,15 +313,15 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call bool importSuccessful = true; - Action call = () => importSuccessful = importer.Import(null, sectionsFilePath); + Action call = () => importSuccessful = importer.Import(sectionsFilePath); // Assert var expectedMessage = "Het bestand heeft geen vakindeling. " + Environment.NewLine + @@ -400,15 +349,15 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call bool importSuccessful = true; - Action call = () => importSuccessful = importer.Import(null, sectionsFilePath); + Action call = () => importSuccessful = importer.Import(sectionsFilePath); // Assert var expectedMessage = "Vakindeling komt niet overeen met de huidige referentielijn. " + Environment.NewLine + @@ -436,15 +385,15 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call bool importSuccessful = true; - Action call = () => importSuccessful = importer.Import(null, sectionsFilePath); + Action call = () => importSuccessful = importer.Import(sectionsFilePath); // Assert var expectedMessage = "Vakindeling komt niet overeen met de huidige referentielijn. " + Environment.NewLine + @@ -469,15 +418,15 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call bool importSuccessful = true; - Action call = () => importSuccessful = importer.Import(null, sectionsFilePath); + Action call = () => importSuccessful = importer.Import(sectionsFilePath); // Assert var expectedMessage = "Vakindeling komt niet overeen met de huidige referentielijn. " + Environment.NewLine + @@ -502,15 +451,15 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); // Call bool importSuccessful = true; - Action call = () => importSuccessful = importer.Import(null, sectionsFilePath); + Action call = () => importSuccessful = importer.Import(sectionsFilePath); // Assert var expectedMessage = "Vakindeling komt niet overeen met de huidige referentielijn. " + Environment.NewLine + @@ -535,17 +484,17 @@ mocks.ReplayAll(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var failureMechanism = new Simple(); var importer = new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine); importer.Cancel(); - Assert.IsFalse(importer.Import(null, sectionsFilePath)); + Assert.IsFalse(importer.Import(sectionsFilePath)); // Call - var importSuccessful = importer.Import(null, sectionsFilePath); + var importSuccessful = importer.Import(sectionsFilePath); // Assert Assert.IsTrue(importSuccessful); Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/FailureMechanismSectionsContextImportInfoTest.cs =================================================================== diff -u -re58ce50bf65d8fa430a1ea7c651256a244f5d2b5 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/FailureMechanismSectionsContextImportInfoTest.cs (.../FailureMechanismSectionsContextImportInfoTest.cs) (revision e58ce50bf65d8fa430a1ea7c651256a244f5d2b5) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/FailureMechanismSectionsContextImportInfoTest.cs (.../FailureMechanismSectionsContextImportInfoTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -153,15 +153,15 @@ var failureMechanism = new Simple(); var referenceLineImporter = new ReferenceLineImporter(assessmentSection); - referenceLineImporter.Import(null, referenceLineFilePath); + referenceLineImporter.Import(referenceLineFilePath); var importTarget = new FailureMechanismSectionsContext(failureMechanism, assessmentSection); // Call IFileImporter importer = importInfo.CreateFileImporter(importTarget); // Assert - Assert.IsTrue(importer.Import(null, sectionsFilePath)); + Assert.IsTrue(importer.Import(sectionsFilePath)); mocks.VerifyAll(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/ReferenceLineContextImportInfoTest.cs =================================================================== diff -u -r96ae727341e257e67f04ffc76552b0364b4ad8c2 -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/ReferenceLineContextImportInfoTest.cs (.../ReferenceLineContextImportInfoTest.cs) (revision 96ae727341e257e67f04ffc76552b0364b4ad8c2) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/ImportInfos/ReferenceLineContextImportInfoTest.cs (.../ReferenceLineContextImportInfoTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -119,7 +119,7 @@ IFileImporter importer = importInfo.CreateFileImporter(importTarget); // Assert - Assert.IsTrue(importer.Import(null, path)); + Assert.IsTrue(importer.Import(path)); mocks.VerifyAll(); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs =================================================================== diff -u -r8b5f0a2d2a65af3a54d892810e14e2b0499e8dca -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 8b5f0a2d2a65af3a54d892810e14e2b0499e8dca) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -22,15 +22,13 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Drawing; using System.Linq; using Core.Common.Base; using Core.Common.Base.IO; using Core.Common.IO.Exceptions; using Core.Common.IO.Readers; using log4net; using Ringtoets.Piping.Data; -using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.SoilProfile; using Ringtoets.Piping.Primitives; @@ -43,7 +41,7 @@ /// /// Imports .soil files (SqlLite database files) created with the DSoilModel application. /// - public class PipingSoilProfilesImporter : FileImporterBase + public class PipingSoilProfilesImporter : FileImporterBase { private readonly ILog log = LogManager.GetLogger(typeof(PipingSoilProfilesImporter)); private readonly ObservableList importTarget; @@ -62,48 +60,10 @@ this.importTarget = importTarget; } - public override string Name - { - get - { - return PipingFormsResources.StochasticSoilProfileCollection_DisplayName; - } - } - - public override string Category - { - get - { - return RingtoetsFormsResources.Ringtoets_Category; - } - } - - public override Bitmap Image - { - get - { - return PipingFormsResources.PipingSoilProfileIcon; - } - } - - public override string FileFilter - { - get - { - return string.Format("{0} {1} (*.soil)|*.soil", - PipingFormsResources.StochasticSoilProfileCollection_DisplayName, RingtoetsPluginResources.Soil_file_name); - } - } - public override ProgressChangedDelegate ProgressChanged { protected get; set; } - public override bool CanImportOn(object targetItem) + public override bool Import(string filePath) { - return base.CanImportOn(targetItem) && IsReferenceLineAvailable(targetItem); - } - - public override bool Import(object targetItem, string filePath) - { var importSoilProfileResult = ReadSoilProfiles(filePath); if (importSoilProfileResult.CriticalErrorOccurred) { @@ -221,11 +181,6 @@ return Math.Abs(sumOfAllScenarioProbabilities - 1.0) < 1e-6; } - private static bool IsReferenceLineAvailable(object targetItem) - { - return ((StochasticSoilModelContext) targetItem).AssessmentSection.ReferenceLine != null; - } - private void HandleException(Exception e) { var message = string.Format(RingtoetsPluginResources.PipingSoilProfilesImporter_CriticalErrorMessage_0_File_Skipped, Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs =================================================================== diff -u -r990491306518ecad9b61955f972fc5dfc1df144e -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision 990491306518ecad9b61955f972fc5dfc1df144e) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.IO; using System.Linq; using Core.Common.Base.Geometry; @@ -30,7 +29,6 @@ using Core.Common.IO.Readers; using log4net; using Ringtoets.Common.Data.AssessmentSection; -using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.IO.SurfaceLines; using Ringtoets.Piping.Primitives; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; @@ -45,7 +43,7 @@ /// Id;X1;Y1;Z1;...(Xn;Yn;Zn) /// Where Xn;Yn;Zn form the n-th 3D point describing the geometry of the surface line. /// - public class PipingSurfaceLinesCsvImporter : FileImporterBase + public class PipingSurfaceLinesCsvImporter : FileImporterBase { private enum ReferenceLineIntersectionsResult { @@ -76,48 +74,10 @@ this.referenceLine = referenceLine; } - public override string Name - { - get - { - return PipingFormsResources.PipingSurfaceLinesCollection_DisplayName; - } - } - - public override string Category - { - get - { - return RingtoetsFormsResources.Ringtoets_Category; - } - } - - public override Bitmap Image - { - get - { - return PipingFormsResources.PipingSurfaceLineIcon; - } - } - - public override string FileFilter - { - get - { - return string.Format("{0} {1} (*.csv)|*.csv", - PipingFormsResources.PipingSurfaceLinesCollection_DisplayName, RingtoetsPluginResources.Csv_file_name); - } - } - public override ProgressChangedDelegate ProgressChanged { protected get; set; } - public override bool CanImportOn(object targetItem) + public override bool Import(string filePath) { - return base.CanImportOn(targetItem) && IsReferenceLineAvailable(targetItem); - } - - public override bool Import(object targetItem, string filePath) - { var importSurfaceLinesResult = ReadPipingSurfaceLines(filePath); if (importSurfaceLinesResult.CriticalErrorOccurred) { @@ -147,11 +107,6 @@ return true; } - private static bool IsReferenceLineAvailable(object targetItem) - { - return ((RingtoetsPipingSurfaceLinesContext) targetItem).AssessmentSection.ReferenceLine != null; - } - private ReadResult HandleCriticalReadError(Exception e) { log.ErrorFormat(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_CriticalErrorMessage_0_File_Skipped, Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs =================================================================== diff -u -r8b5f0a2d2a65af3a54d892810e14e2b0499e8dca -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs (.../ImportSoilProfileFromDatabaseTest.cs) (revision 8b5f0a2d2a65af3a54d892810e14e2b0499e8dca) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/ImportSoilProfileFromDatabaseTest.cs (.../ImportSoilProfileFromDatabaseTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -45,7 +45,7 @@ // When var importer = new PipingSoilProfilesImporter(pipingFailureMechanism.StochasticSoilModels); - importer.Import(null, databasePath); + importer.Import(databasePath); // Then Assert.AreEqual(1, pipingFailureMechanism.StochasticSoilModels.Count); @@ -82,7 +82,7 @@ // When var importer = new PipingSoilProfilesImporter(pipingFailureMechanism.StochasticSoilModels); - importer.Import(null, databasePath); + importer.Import(databasePath); // Then Assert.AreEqual(1, pipingFailureMechanism.StochasticSoilModels.Count); @@ -115,7 +115,7 @@ // When var importer = new PipingSoilProfilesImporter(pipingFailureMechanism.StochasticSoilModels); - importer.Import(null, databasePath); + importer.Import(databasePath); // Then Assert.AreEqual(1, pipingFailureMechanism.StochasticSoilModels.Count); Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/IntegrationTestHelper.cs =================================================================== diff -u -r8b5f0a2d2a65af3a54d892810e14e2b0499e8dca -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/IntegrationTestHelper.cs (.../IntegrationTestHelper.cs) (revision 8b5f0a2d2a65af3a54d892810e14e2b0499e8dca) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/IntegrationTestHelper.cs (.../IntegrationTestHelper.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -52,7 +52,8 @@ { var activity = new FileImportActivity(new ReferenceLineImporter(assessmentSection), new ReferenceLineContext(assessmentSection), - Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3.shp")); + Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3.shp"), + "ReferenceLineImporter"); activity.Run(); activity.Finish(); } @@ -75,7 +76,8 @@ { var activity = new FileImportActivity(new FailureMechanismSectionsImporter(failureMechanism, assessmentSection.ReferenceLine), new FailureMechanismSectionsContext(failureMechanism, assessmentSection), - Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3_vakken.shp")); + Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "traject_6-3_vakken.shp"), + "FailureMechanismSectionsImporter"); activity.Run(); activity.Finish(); } @@ -113,7 +115,8 @@ { var activity = new FileImportActivity(new PipingSurfaceLinesCsvImporter(assessmentSection.PipingFailureMechanism.SurfaceLines, assessmentSection.ReferenceLine), new RingtoetsPipingSurfaceLinesContext(assessmentSection.PipingFailureMechanism, assessmentSection), - Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_surfacelines.csv")); + Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6_surfacelines.csv"), + "PipingSurfaceLinesCsvImporter"); activity.Run(); activity.Finish(); } @@ -132,7 +135,8 @@ { var activity = new FileImportActivity(new PipingSoilProfilesImporter(assessmentSection.PipingFailureMechanism.StochasticSoilModels), new StochasticSoilModelContext(assessmentSection.PipingFailureMechanism.StochasticSoilModels, assessmentSection.PipingFailureMechanism, assessmentSection), - Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil")); + Path.Combine(embeddedResourceFileWriter.TargetFolderPath, "DR6.soil"), + "PipingSoilProfilesImporter"); activity.Run(); activity.Finish(); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs =================================================================== diff -u -r8b5f0a2d2a65af3a54d892810e14e2b0499e8dca -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision 8b5f0a2d2a65af3a54d892810e14e2b0499e8dca) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSoilProfilesImporterTest.cs (.../PipingSoilProfilesImporterTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -28,10 +28,7 @@ using Core.Common.TestUtil; using Core.Common.Utils.Builders; using NUnit.Framework; -using Rhino.Mocks; -using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; -using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Plugin.FileImporter; using Ringtoets.Piping.Primitives; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; @@ -77,59 +74,10 @@ var importer = new PipingSoilProfilesImporter(list); // Assert - Assert.IsInstanceOf>(importer); - Assert.AreEqual(PipingFormsResources.StochasticSoilProfileCollection_DisplayName, importer.Name); - Assert.AreEqual(RingtoetsFormsResources.Ringtoets_Category, importer.Category); - Assert.AreEqual(16, importer.Image.Width); - Assert.AreEqual(16, importer.Image.Height); - Assert.AreEqual(expectedFileFilter, importer.FileFilter); + Assert.IsInstanceOf(importer); } [Test] - public void CanImportOn_ValidContextWithReferenceLine_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - assessmentSection.ReferenceLine = new ReferenceLine(); - var failureMechanism = new PipingFailureMechanism(); - mocks.ReplayAll(); - - var targetContext = new StochasticSoilModelContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - - var importer = new PipingSoilProfilesImporter(failureMechanism.StochasticSoilModels); - - // Call - var canImport = importer.CanImportOn(targetContext); - - // Assert - Assert.IsTrue(canImport); - mocks.VerifyAll(); - } - - [Test] - public void CanImportOn_ValidContextWithoutReferenceLine_ReturnFalse() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - assessmentSection.ReferenceLine = null; - var failureMechanism = new PipingFailureMechanism(); - mocks.ReplayAll(); - - var targetContext = new StochasticSoilModelContext(failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - - var importer = new PipingSoilProfilesImporter(failureMechanism.StochasticSoilModels); - - // Call - var canImport = importer.CanImportOn(targetContext); - - // Assert - Assert.IsFalse(canImport); - mocks.VerifyAll(); - } - - [Test] public void Import_FromNonExistingFile_LogError() { // Setup @@ -148,7 +96,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -181,7 +129,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, invalidFilePath); + Action call = () => importResult = importer.Import(invalidFilePath); // Assert TestHelper.AssertLogMessages(call, messages => @@ -210,7 +158,7 @@ }; // Call - var importResult = importer.Import(null, validFilePath); + var importResult = importer.Import(validFilePath); // Assert Assert.IsTrue(importResult); @@ -261,11 +209,11 @@ var importResult = false; // Precondition - importer.Import(null, validFilePath); + importer.Import(validFilePath); var alreadyImportedSoilModelNames = pipingFailureMechanism.StochasticSoilModels.Select(ssm => ssm.Name); // Call - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert var expectedLogMessages = alreadyImportedSoilModelNames.Select(name => string.Format("Het stochastische ondergrondmodel '{0}' bestaat al in het toetsspoor.", name)).ToArray(); @@ -296,7 +244,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert TestHelper.AssertLogMessageIsGenerated(call, ApplicationResources.PipingSoilProfilesImporter_Import_Import_cancelled, 1); @@ -323,11 +271,11 @@ // Setup (second part) importer.Cancel(); - var importResult = importer.Import(null, validFilePath); + var importResult = importer.Import(validFilePath); Assert.IsFalse(importResult); // Call - importResult = importer.Import(null, validFilePath); + importResult = importer.Import(validFilePath); // Assert Assert.IsTrue(importResult); @@ -349,7 +297,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, corruptPath); + Action call = () => importResult = importer.Import(corruptPath); // Assert var internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(RingtoetsIOResources.PipingSoilProfileReader_Critical_Unexpected_value_on_column); @@ -376,7 +324,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, corruptPath); + Action call = () => importResult = importer.Import(corruptPath); // Assert var internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath) @@ -409,7 +357,7 @@ }; // Call - var importResult = importer.Import(null, corruptPath); + var importResult = importer.Import(corruptPath); Assert.IsTrue(importResult); Assert.AreEqual(0, failureMechanism.StochasticSoilModels.Count); @@ -430,7 +378,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert var expectedLogMessage = string.Format("Fout bij het lezen van bestand '{0}': De ondergrondschematisatie verwijst naar een ongeldige waarde." + @@ -455,7 +403,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert var expectedLogMessages = "De som van de kansen van voorkomen in het stochastich ondergrondmodel 'Name' is niet gelijk aan 100%."; @@ -474,7 +422,7 @@ var importer = new PipingSoilProfilesImporter(pipingFailureMechanism.StochasticSoilModels); // Call - var importResult = importer.Import(null, validFilePath); + var importResult = importer.Import(validFilePath); // Assert Assert.IsTrue(importResult); @@ -507,7 +455,7 @@ var importer = new PipingSoilProfilesImporter(pipingFailureMechanism.StochasticSoilModels); // Call - var importResult = importer.Import(null, validFilePath); + var importResult = importer.Import(validFilePath); // Assert Assert.IsTrue(importResult); @@ -542,7 +490,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert var expectedLogMessage = @"Er zijn geen ondergrondschematisaties gevonden in het stochastische ondergrondmodel 'Model'. Dit model wordt overgeslagen."; @@ -568,7 +516,7 @@ Assert.IsTrue(File.Exists(validFilePath)); // Call - bool importResult = importer.Import(null, validFilePath); + bool importResult = importer.Import(validFilePath); // Assert Assert.IsTrue(importResult); @@ -624,7 +572,7 @@ Assert.IsTrue(File.Exists(validFilePath)); // Call - bool importResult = importer.Import(null, validFilePath); + bool importResult = importer.Import(validFilePath); // Assert Assert.IsTrue(importResult); Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs =================================================================== diff -u -r990491306518ecad9b61955f972fc5dfc1df144e -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision 990491306518ecad9b61955f972fc5dfc1df144e) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -29,10 +29,8 @@ using Core.Common.TestUtil; using Core.Common.Utils.Builders; using NUnit.Framework; -using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Piping.Data; -using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Plugin.FileImporter; using Ringtoets.Piping.Primitives; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; @@ -63,63 +61,10 @@ var importer = new PipingSurfaceLinesCsvImporter(list, referenceLine); // Assert - Assert.IsInstanceOf>(importer); - Assert.AreEqual(PipingFormsResources.PipingSurfaceLinesCollection_DisplayName, importer.Name); - Assert.AreEqual(RingtoetsFormsResources.Ringtoets_Category, importer.Category); - Assert.AreEqual(16, importer.Image.Width); - Assert.AreEqual(16, importer.Image.Height); - var expectedFileFilter = string.Format("{0} {1} (*.csv)|*.csv", - PipingFormsResources.PipingSurfaceLinesCollection_DisplayName, PipingPluginResources.Csv_file_name); - Assert.AreEqual(expectedFileFilter, importer.FileFilter); + Assert.IsInstanceOf(importer); } [Test] - public void CanImportOn_ValidContextWithReferenceLine_ReturnTrue() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - assessmentSection.ReferenceLine = new ReferenceLine(); - mocks.ReplayAll(); - - var failureMechanism = new PipingFailureMechanism(); - - var targetContext = new RingtoetsPipingSurfaceLinesContext(failureMechanism, assessmentSection); - - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, assessmentSection.ReferenceLine); - - // Call - bool canImport = importer.CanImportOn(targetContext); - - // Assert - Assert.IsTrue(canImport); - mocks.VerifyAll(); - } - - [Test] - public void CanImportOn_ValidContextWithoutReferenceLine_ReturnFalse() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - assessmentSection.ReferenceLine = null; - mocks.ReplayAll(); - - var failureMechanism = new PipingFailureMechanism(); - - var targetContext = new RingtoetsPipingSurfaceLinesContext(failureMechanism, assessmentSection); - - var importer = new PipingSurfaceLinesCsvImporter(failureMechanism.SurfaceLines, new ReferenceLine()); - - // Call - bool canImport = importer.CanImportOn(targetContext); - - // Assert - Assert.IsFalse(canImport); - mocks.VerifyAll(); - } - - [Test] public void Import_ImportingToValidTargetWithValidFile_ImportSurfaceLinesToCollection() { // Setup @@ -182,7 +127,7 @@ Assert.IsTrue(File.Exists(validFilePath)); // Call - bool importResult = importer.Import(null, validFilePath); + bool importResult = importer.Import(validFilePath); // Assert Assert.IsTrue(importResult); @@ -231,7 +176,7 @@ // Call bool importResult = false; - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert var mesages = new[] @@ -288,7 +233,7 @@ bool importResult = true; // Call - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert TestHelper.AssertLogMessageIsGenerated(call, PipingPluginResources.PipingSurfaceLinesCsvImporter_Import_Import_cancelled, 3); @@ -322,11 +267,11 @@ // Setup (second part) importer.Cancel(); - var importResult = importer.Import(null, validFilePath); + var importResult = importer.Import(validFilePath); Assert.IsFalse(importResult); // Call - importResult = importer.Import(null, validFilePath); + importResult = importer.Import(validFilePath); // Assert Assert.IsTrue(importResult); @@ -348,7 +293,7 @@ bool importResult = true; // Call - Action call = () => importResult = importer.Import(null, corruptPath); + Action call = () => importResult = importer.Import(corruptPath); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(string.Format(UtilsResources.Error_Path_cannot_contain_Characters_0_, @@ -374,7 +319,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, corruptPath); + Action call = () => importResult = importer.Import(corruptPath); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(UtilsResources.Error_File_does_not_exist); @@ -406,7 +351,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, corruptPath); + Action call = () => importResult = importer.Import(corruptPath); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath) @@ -440,7 +385,7 @@ bool importResult = true; // Call - Action call = () => importResult = importer.Import(null, corruptPath); + Action call = () => importResult = importer.Import(corruptPath); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath) @@ -485,7 +430,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, copyTargetPath); + Action call = () => importResult = importer.Import(copyTargetPath); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(copyTargetPath).Build(UtilsResources.Error_File_does_not_exist); @@ -535,7 +480,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, corruptPath); + Action call = () => importResult = importer.Import(corruptPath); // Assert string duplicateDefinitionMessage = string.Format(PipingPluginResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_Duplicate_definitions_for_same_location_0_, @@ -585,7 +530,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, corruptPath); + Action call = () => importResult = importer.Import(corruptPath); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath) @@ -644,7 +589,7 @@ // Call var importResult = false; - Action call = () => importResult = importer.Import(null, path); + Action call = () => importResult = importer.Import(path); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(path) @@ -689,7 +634,7 @@ // Call var importResult = false; - Action call = () => importResult = importer.Import(null, path); + Action call = () => importResult = importer.Import(path); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(path) @@ -736,7 +681,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert TestHelper.AssertLogMessageIsGenerated(call, PipingPluginResources.PipingSurfaceLinesCsvImporter_Import_Import_cancelled, 3); @@ -772,7 +717,7 @@ Assert.IsFalse(File.Exists(nonExistingCharacteristicFile)); // Call - Action call = () => importResult = importer.Import(null, surfaceLinesFile); + Action call = () => importResult = importer.Import(surfaceLinesFile); // Assert var expectedLogMessage = string.Format(PipingPluginResources.PipingSurfaceLinesCsvImporter_Import_No_characteristic_points_file_for_surface_line_file_expecting_file_0_, @@ -797,7 +742,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, surfaceLinesFile); + Action call = () => importResult = importer.Import(surfaceLinesFile); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath) @@ -838,7 +783,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, surfaceLinesFile); + Action call = () => importResult = importer.Import(surfaceLinesFile); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath) @@ -899,7 +844,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, copyTargetPath); + Action call = () => importResult = importer.Import(copyTargetPath); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(copyCharacteristicPointsTargetPath).Build(UtilsResources.Error_File_does_not_exist); @@ -960,7 +905,7 @@ var importResult = true; // Call - Action call = () => importResult = importer.Import(null, surfaceLinesFile); + Action call = () => importResult = importer.Import(surfaceLinesFile); // Assert string duplicateDefinitionMessage = string.Format(PipingPluginResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_Duplicate_definitions_for_same_characteristic_point_location_0_, @@ -1015,7 +960,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, surfaceLinesFile); + Action call = () => importResult = importer.Import(surfaceLinesFile); // Assert string internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath) @@ -1087,7 +1032,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, surfaceLinesPath); + Action call = () => importResult = importer.Import(surfaceLinesPath); // Assert string[] expectedLogMessages = @@ -1153,7 +1098,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, surfaceLinesPath); + Action call = () => importResult = importer.Import(surfaceLinesPath); // Assert string[] expectedLogMessages = @@ -1224,7 +1169,7 @@ var importResult = false; // Call - Action call = () => importResult = importer.Import(null, surfaceLinesPath); + Action call = () => importResult = importer.Import(surfaceLinesPath); // Assert var pointFormat = string.Format(PipingDataResources.RingtoetsPipingSurfaceLine_SetCharacteristicPointAt_Geometry_does_not_contain_point_at_0_to_assign_as_characteristic_point_1_, @@ -1339,7 +1284,7 @@ Assert.IsTrue(File.Exists(validCharacteristicPointsFilePath)); // Call - bool importResult = importer.Import(null, validSurfaceLinesFilePath); + bool importResult = importer.Import(validSurfaceLinesFilePath); // Assert Assert.IsTrue(importResult); @@ -1400,7 +1345,7 @@ // Call var importResult = false; - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert var mesagge = "Profielschematisatie ArtifcialLocal doorkruist de huidige referentielijn niet of op meer dan 1 punt en kan niet worden geïmporteerd. Dit kan komen doordat de profielschematisatie een lokaal coördinaatsysteem heeft."; @@ -1447,7 +1392,7 @@ // Call var importResult = false; - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert var mesagge = "Profielschematisatie Rotterdam1 doorkruist de huidige referentielijn niet of op meer dan 1 punt en kan niet worden geïmporteerd."; @@ -1492,7 +1437,7 @@ // Call var importResult = false; - Action call = () => importResult = importer.Import(null, validFilePath); + Action call = () => importResult = importer.Import(validFilePath); // Assert var message = string.Format(PipingPluginResources.PipingSurfaceLinesCsvImporter_CheckCharacteristicPoints_EntryPointL_greater_or_equal_to_ExitPointL_for_0_, Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs =================================================================== diff -u -r990491306518ecad9b61955f972fc5dfc1df144e -rf81243697050d2c39aee9c38125aa6f030b17cb7 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextImportInfoTest.cs) (revision 990491306518ecad9b61955f972fc5dfc1df144e) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/ImportInfos/RingtoetsPipingSurfaceLinesContextImportInfoTest.cs (.../RingtoetsPipingSurfaceLinesContextImportInfoTest.cs) (revision f81243697050d2c39aee9c38125aa6f030b17cb7) @@ -165,7 +165,7 @@ IFileImporter importer = importInfo.CreateFileImporter(importTarget); // Assert - Assert.IsTrue(importer.Import(null, filePath)); + Assert.IsTrue(importer.Import(filePath)); mocks.VerifyAll(); } }