Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs =================================================================== diff -u -r10779bb6a6db2d00f4627b2bc190e7e35e1fee3e -r619f3fd6896edb6d7f6ac160fcfc66054883dce4 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 10779bb6a6db2d00f4627b2bc190e7e35e1fee3e) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 619f3fd6896edb6d7f6ac160fcfc66054883dce4) @@ -27,12 +27,13 @@ using Core.Common.IO.Exceptions; using Core.Common.IO.Readers; using log4net; +using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.SoilProfile; using Ringtoets.Piping.Primitives; using PipingFormsResources = Ringtoets.Piping.Forms.Properties.Resources; using RingtoetsFormsResources = Ringtoets.Common.Forms.Properties.Resources; -using ApplicationResources = Ringtoets.Piping.Plugin.Properties.Resources; +using RingtoetsPluginResources = Ringtoets.Piping.Plugin.Properties.Resources; namespace Ringtoets.Piping.Plugin.FileImporter { @@ -72,37 +73,124 @@ get { return String.Format("{0} {1} (*.soil)|*.soil", - PipingFormsResources.PipingSoilProfilesCollection_DisplayName, ApplicationResources.Soil_file_name); + PipingFormsResources.PipingSoilProfilesCollection_DisplayName, RingtoetsPluginResources.Soil_file_name); } } public override ProgressChangedDelegate ProgressChanged { protected get; set; } public override bool Import(object targetItem, string filePath) { - var importResult = ReadSoilProfiles(filePath); + if (!IsReferenceLineAvailable(targetItem)) + { + var message = String.Format(RingtoetsPluginResources.PipingSoilProfilesImporter_ReadSoilProfiles_ParseErrorMessage_0_SoilProfile_skipped, + RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_Import_Required_referenceline_missing); + log.Error(message); + return false; + } - if (!importResult.CriticalErrorOccurred) + var importSoilProfileResult = ReadSoilProfiles(filePath); + if (importSoilProfileResult.CriticalErrorOccurred) { - if (!ImportIsCancelled) - { - AddImportedDataToModel(targetItem, importResult); + return false; + } - return true; - } - + if (ImportIsCancelled) + { HandleUserCancellingImport(); + return false; } - return false; + AddImportedDataToModel(targetItem, importSoilProfileResult); + return true; } - private ReadResult ReadSoilProfiles(string path) + private static bool IsReferenceLineAvailable(object targetItem) { - NotifyProgress(ApplicationResources.PipingSoilProfilesImporter_Reading_database, 1, 1); + //return ((RingtoetsPipingSurfaceLinesContext) targetItem).AssessmentSection.ReferenceLine != null; + return true; + } + private void HandleException(string path, Exception e) + { + var message = string.Format(RingtoetsPluginResources.PipingSoilProfilesImporter_CriticalErrorMessage_0_File_Skipped, + e.Message); + log.Error(message); + } + + private void HandleUserCancellingImport() + { + log.Info(RingtoetsPluginResources.PipingSoilProfilesImporter_Import_Import_cancelled); + + ImportIsCancelled = false; + } + + #region read stochastic soil models + + private ReadResult ReadStochasticSoilModels(string path) + { + NotifyProgress(RingtoetsPluginResources.PipingSoilProfilesImporter_Reading_database, 1, 1); try { + using (var stochasticSoilModelReader = new StochasticSoilModelReader(path)) + { + return GetStochasticSoilModelReadResult(path, stochasticSoilModelReader); + } + } + catch (CriticalFileReadException e) + { + HandleException(path, e); + } + return new ReadResult(true); + } + + private ReadResult GetStochasticSoilModelReadResult(string path, StochasticSoilModelReader stochasticSoilModelReader) + { + var totalNumberOfSteps = stochasticSoilModelReader.PipingStochasticSoilModelCount; + var currentStep = 1; + + var soilModels = new Collection(); + while (stochasticSoilModelReader.HasNext) + { + if (ImportIsCancelled) + { + return new ReadResult(false); + } + try + { + NotifyProgress("Inlezen van de ondergrondsmodellen uit de D-Soil Model database.", currentStep++, totalNumberOfSteps); + soilModels.Add(stochasticSoilModelReader.ReadStochasticSoilModel()); + } + catch (PipingSoilProfileReadException e) + { + var message = string.Format("{0} " + + "Dit ondergrondsmodel wordt overgeslagen.", + e.Message); + log.Error(message); + } + catch (CriticalFileReadException e) + { + var message = string.Format(RingtoetsPluginResources.PipingSoilProfilesImporter_CriticalErrorMessage_0_File_Skipped, + path, e.Message); + log.Error(message); + return new ReadResult(true); + } + } + return new ReadResult(false) + { + ImportedItems = soilModels + }; + } + + #endregion + + #region read soil profiles + + private ReadResult ReadSoilProfiles(string path) + { + NotifyProgress(RingtoetsPluginResources.PipingSoilProfilesImporter_Reading_database, 1, 1); + try + { using (var soilProfileReader = new PipingSoilProfileReader(path)) { return GetProfileReadResult(path, soilProfileReader); @@ -115,11 +203,16 @@ return new ReadResult(true); } - private void HandleException(string path, Exception e) + private void AddImportedDataToModel(object target, ReadResult imported) { - var message = string.Format(ApplicationResources.PipingSoilProfilesImporter_CriticalErrorMessage_0_File_Skipped, - e.Message); - log.Error(message); + var targetCollection = (ICollection) target; + + int totalProfileCount = imported.ImportedItems.Count; + NotifyProgress(RingtoetsPluginResources.PipingSoilProfilesImporter_Adding_imported_data_to_model, totalProfileCount, totalProfileCount); + foreach (var item in imported.ImportedItems) + { + targetCollection.Add(item); + } } private ReadResult GetProfileReadResult(string path, PipingSoilProfileReader soilProfileReader) @@ -136,18 +229,18 @@ } try { - NotifyProgress(ApplicationResources.PipingSoilProfilesImporter_ReadingSoilProfiles, currentStep++, totalNumberOfSteps); + NotifyProgress(RingtoetsPluginResources.PipingSoilProfilesImporter_ReadingSoilProfiles, currentStep++, totalNumberOfSteps); profiles.Add(soilProfileReader.ReadProfile()); } catch (PipingSoilProfileReadException e) { - var message = string.Format(ApplicationResources.PipingSoilProfilesImporter_ReadSoilProfiles_ParseErrorMessage_0_SoilProfile_skipped, + var message = string.Format(RingtoetsPluginResources.PipingSoilProfilesImporter_ReadSoilProfiles_ParseErrorMessage_0_SoilProfile_skipped, e.Message); log.Error(message); } catch (CriticalFileReadException e) { - var message = string.Format(ApplicationResources.PipingSoilProfilesImporter_CriticalErrorMessage_0_File_Skipped, + var message = string.Format(RingtoetsPluginResources.PipingSoilProfilesImporter_CriticalErrorMessage_0_File_Skipped, path, e.Message); log.Error(message); return new ReadResult(true); @@ -159,24 +252,6 @@ }; } - private void AddImportedDataToModel(object target, ReadResult imported) - { - var targetCollection = (ICollection) target; - - int totalProfileCount = imported.ImportedItems.Count; - NotifyProgress(ApplicationResources.PipingSoilProfilesImporter_Adding_imported_data_to_model, totalProfileCount, totalProfileCount); - - foreach (var item in imported.ImportedItems) - { - targetCollection.Add(item); - } - } - - private void HandleUserCancellingImport() - { - log.Info(ApplicationResources.PipingSoilProfilesImporter_Import_Import_cancelled); - - ImportIsCancelled = false; - } + #endregion } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs =================================================================== diff -u -r10779bb6a6db2d00f4627b2bc190e7e35e1fee3e -r619f3fd6896edb6d7f6ac160fcfc66054883dce4 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision 10779bb6a6db2d00f4627b2bc190e7e35e1fee3e) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision 619f3fd6896edb6d7f6ac160fcfc66054883dce4) @@ -24,12 +24,10 @@ using System.Drawing; using System.IO; using System.Linq; - using Core.Common.Base.Geometry; using Core.Common.Base.IO; using Core.Common.IO.Exceptions; using Core.Common.IO.Readers; - using log4net; using Ringtoets.Common.Data; using Ringtoets.Piping.Forms.PresentationObjects; @@ -101,7 +99,7 @@ return false; } - var surfaceLinesContext = (RingtoetsPipingSurfaceLinesContext)targetItem; + var surfaceLinesContext = (RingtoetsPipingSurfaceLinesContext) targetItem; var importSurfaceLinesResult = ReadPipingSurfaceLines(filePath); if (importSurfaceLinesResult.CriticalErrorOccurred) @@ -134,7 +132,7 @@ private static bool IsReferenceLineAvailable(object targetItem) { - return ((RingtoetsPipingSurfaceLinesContext)targetItem).AssessmentSection.ReferenceLine != null; + return ((RingtoetsPipingSurfaceLinesContext) targetItem).AssessmentSection.ReferenceLine != null; } private ReadResult HandleCriticalReadError(Exception e) @@ -195,7 +193,7 @@ { return true; } - + if (intersections.Count == 0) { log.ErrorFormat(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_CheckReferenceLineInterSections_Surfaceline_0_does_not_correspond_to_current_referenceline_1_, @@ -231,6 +229,7 @@ private ReadResult ReadPipingSurfaceLines(string path) { + NotifyProgress(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_Reading_surface_line_file, 1, 1); using (PipingSurfaceLinesCsvReader reader = CreateSurfaceLineReader(path)) { if (reader == null) @@ -373,6 +372,7 @@ private ReadResult ReadCharacteristicPoints(string surfaceLineFilePath) { + NotifyProgress(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_Reading_characteristic_points_file, 1, 1); string path = GetCharacteristicPointsFilePath(surfaceLineFilePath); if (path == null) { Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -rd36a95d2e88d98b7b92ff5d091abf711d1dd31d9 -r619f3fd6896edb6d7f6ac160fcfc66054883dce4 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d36a95d2e88d98b7b92ff5d091abf711d1dd31d9) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 619f3fd6896edb6d7f6ac160fcfc66054883dce4) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17929 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -302,6 +302,24 @@ } /// + /// Looks up a localized string similar to Inlezen van het karakteristieke punten-bestand.. + /// + public static string PipingSurfaceLinesCsvImporter_Reading_characteristic_points_file { + get { + return ResourceManager.GetString("PipingSurfaceLinesCsvImporter_Reading_characteristic_points_file", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Inlezen van het profielmetingenbestand.. + /// + public static string PipingSurfaceLinesCsvImporter_Reading_surface_line_file { + get { + return ResourceManager.GetString("PipingSurfaceLinesCsvImporter_Reading_surface_line_file", resourceCulture); + } + } + + /// /// Looks up a localized string similar to {0} ///Deze profielmeting wordt overgeslagen.. /// Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx =================================================================== diff -u -rd36a95d2e88d98b7b92ff5d091abf711d1dd31d9 -r619f3fd6896edb6d7f6ac160fcfc66054883dce4 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision d36a95d2e88d98b7b92ff5d091abf711d1dd31d9) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 619f3fd6896edb6d7f6ac160fcfc66054883dce4) @@ -206,4 +206,10 @@ Er is geen referentielijn beschikbaar om profielmetingen voor te definiëren. + + Inlezen van het karakteristieke punten-bestand. + + + Inlezen van het profielmetingenbestand. + \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs =================================================================== diff -u -rd36a95d2e88d98b7b92ff5d091abf711d1dd31d9 -r619f3fd6896edb6d7f6ac160fcfc66054883dce4 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision d36a95d2e88d98b7b92ff5d091abf711d1dd31d9) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision 619f3fd6896edb6d7f6ac160fcfc66054883dce4) @@ -131,7 +131,7 @@ var observer = mocks.StrictMock(); var assessmentSection = mocks.Stub(); var referenceLine = new ReferenceLine(); - referenceLine.SetGeometry(new [] + referenceLine.SetGeometry(new[] { new Point2D(3.3, -1), new Point2D(3.3, 1), @@ -147,8 +147,23 @@ var importer = new PipingSurfaceLinesCsvImporter(); int callCount = 0; + bool progressStarted = false; + bool progressCharacteristicPointsStarted = false; importer.ProgressChanged = delegate(string currentStepName, int currentStep, int totalNumberOfSteps) { + if (!progressStarted && callCount == 0) + { + progressStarted = true; + Assert.AreEqual(ApplicationResources.PipingSurfaceLinesCsvImporter_Reading_surface_line_file, currentStepName); + return; + } + if (!progressCharacteristicPointsStarted && callCount == expectedNumberOfSurfaceLines + 1) + { + progressCharacteristicPointsStarted = true; + Assert.AreEqual(ApplicationResources.PipingSurfaceLinesCsvImporter_Reading_characteristic_points_file, currentStepName); + return; + } + if (callCount <= expectedNumberOfSurfaceLines) { Assert.AreEqual(String.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_Read_PipingSurfaceLines_0_, twovalidsurfacelinesCsv), currentStepName); @@ -549,7 +564,7 @@ var observer = mocks.StrictMock(); var assessmentSection = mocks.Stub(); var referenceLine = new ReferenceLine(); - referenceLine.SetGeometry(new [] + referenceLine.SetGeometry(new[] { new Point2D(94270, 427700), new Point2D(94270, 427900) @@ -640,8 +655,10 @@ Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "Rotterdam1")); Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "ArtifcialLocal")); - Assert.AreEqual(5, progressCallCount, - "Expect 1 call for each surfaceline (3 in total) +1 for 0/N progress, and 1 for putting data in model."); + Assert.AreEqual(7, progressCallCount, + "Expect 1 call for start reading surface lines file" + + ", 1 call for start reading characteristic points file" + + ", 1 call for each surfaceline (3 in total) +1 for 0/N progress, and 1 for putting data in model."); mocks.VerifyAll(); // Ensure there are no calls to UpdateObserver } @@ -677,7 +694,7 @@ .WithLocation("op regel 2") .WithSubject("profielmeting 'Rotterdam1'") .Build(PipingIOResources.PipingSurfaceLinesCsvReader_ReadLine_SurfaceLine_has_reclining_geometry); - var expectedLogMessages = new [] + var expectedLogMessages = new[] { string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadPipingSurfaceLines_ParseErrorMessage_0_SurfaceLine_skipped, internalErrorMessage), @@ -1022,7 +1039,7 @@ // Assert var duplicateDefinitionMessage = string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_Duplicate_definitions_for_same_characteristic_point_location_0_, - "Rotterdam1"); + "Rotterdam1"); var expectedLogMessages = new[] { string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, corruptPath), @@ -1081,12 +1098,12 @@ .Build(PipingIOResources.Error_CharacteristicPoint_has_not_double); var expectedLogMessages = new[] { - string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, - corruptPath), + string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, + corruptPath), string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_ParseErrorMessage_0_CharacteristicPoints_skipped, - internalErrorMessage), - string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_No_characteristic_points_for_SurfaceLine_0_, - "Rotterdam1Invalid") + internalErrorMessage), + string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_No_characteristic_points_for_SurfaceLine_0_, + "Rotterdam1Invalid") }; TestHelper.AssertLogMessagesAreGenerated(call, expectedLogMessages, 3); Assert.IsTrue(importResult); @@ -1096,8 +1113,11 @@ Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "Rotterdam1Invalid")); Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "ArtifcialLocal")); - Assert.AreEqual(7, progressCallCount, - "Expect 1 call for each surfaceline (2 in total) +1 for 0/N progress and for each characteristic point location (2 in total) +1 for 0/N progress, and 1 for putting data in model."); + Assert.AreEqual(9, progressCallCount, + "Expect 1 call for start reading surface lines file" + + ", 1 call for start reading characteristic points file" + + ", 1 call for each surfaceline (2 in total) +1 for 0/N progress and for each characteristic point location (2 in total) " + + "+1 for 0/N progress, and 1 for putting data in model."); mocks.VerifyAll(); // Ensure there are no calls to UpdateObserver } @@ -1139,10 +1159,10 @@ // Assert var expectedLogMessages = new[] { - string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, - corruptPath), - string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_No_characteristic_points_for_SurfaceLine_0_, - "Rotterdam1") + string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, + corruptPath), + string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_No_characteristic_points_for_SurfaceLine_0_, + "Rotterdam1") }; TestHelper.AssertLogMessagesAreGenerated(call, expectedLogMessages, 2); Assert.IsTrue(importResult); @@ -1152,8 +1172,11 @@ Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "Rotterdam1")); Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "ArtifcialLocal")); - Assert.AreEqual(6, progressCallCount, - "Expect 1 call for each surfaceline (2 in total) +1 for 0/N progress and for each characteristic point location (1 in total) +1 for 0/N progress, and 1 for putting data in model."); + Assert.AreEqual(8, progressCallCount, + "Expect 1 call for start reading surface lines file" + + ", 1 call for start reading characteristic points file" + + ", 1 call for each surfaceline (2 in total) +1 for 0/N progress and for each characteristic point location (1 in total) " + + "+1 for 0/N progress, and 1 for putting data in model."); mocks.VerifyAll(); // Ensure there are no calls to UpdateObserver } @@ -1195,10 +1218,10 @@ // Assert var expectedLogMessages = new[] { - string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, - corruptPath), - string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_Characteristic_points_found_for_unknown_SurfaceLine_0_, - "Extra") + string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, + corruptPath), + string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_AddImportedDataToModel_Characteristic_points_found_for_unknown_SurfaceLine_0_, + "Extra") }; TestHelper.AssertLogMessagesAreGenerated(call, expectedLogMessages, 2); Assert.IsTrue(importResult); @@ -1208,10 +1231,12 @@ Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "Rotterdam1")); Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "ArtifcialLocal")); - Assert.AreEqual(8, progressCallCount, - "Expect 1 call for each surfaceline (2 in total) +1 for 0/N progress and for " + + Assert.AreEqual(10, progressCallCount, + "Expect 1 call for start reading surface lines file" + + ", 1 call for start reading characteristic points file" + + ", 1 call for each surfaceline (2 in total) +1 for 0/N progress and for " + "each characteristic point location (2 in total) +1 for 0/N progress, " + - "one for the 'Extra' characteristic point definition " + + "one for the 'Extra' characteristic point definition " + "and 1 for putting data in model."); mocks.VerifyAll(); // Ensure there are no calls to UpdateObserver } @@ -1258,15 +1283,15 @@ // Assert var pointFormat = string.Format(PipingDataResources.RingtoetsPipingSurfaceLine_SetCharacteristicPointAt_Geometry_does_not_contain_point_at_0_to_assign_as_characteristic_point_1_, - new Point3D(0, 1, 2), - characteristicPointName); + new Point3D(0, 1, 2), + characteristicPointName); var expectedLogMessages = new[] { - string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, - corruptPath), + string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_ReadCharacteristicPoints_Start_reading_characteristic_points_from_file_0_, + corruptPath), string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_CharacteristicPoint_of_SurfaceLine_0_skipped_cause_1_, - "Rotterdam1Invalid", - pointFormat) + "Rotterdam1Invalid", + pointFormat) }; TestHelper.AssertLogMessagesAreGenerated(call, expectedLogMessages, 2); Assert.IsTrue(importResult); @@ -1276,10 +1301,12 @@ Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "Rotterdam1Invalid")); Assert.AreEqual(1, context.FailureMechanism.SurfaceLines.Count(sl => sl.Name == "ArtifcialLocal")); - Assert.AreEqual(7, progressCallCount, - "Expect 1 call for each surfaceline (2 in total) +1 for 0/N progress and for " + + Assert.AreEqual(9, progressCallCount, + "Expect 1 call for start reading surface lines file" + + ", 1 call for start reading characteristic points file" + + ", 1 call for each surfaceline (2 in total) +1 for 0/N progress and for " + "each characteristic point location (2 in total) +1 for 0/N progress, " + - "and 1 for putting data in model."); + ", 1 for putting data in model."); mocks.VerifyAll(); // Ensure there are no calls to UpdateObserver } @@ -1291,7 +1318,7 @@ const int expectedNumberOfCharacteristicPointsDefinitions = 2; const string fileName = "TwoValidSurfaceLines_WithCharacteristicPoints"; - string twovalidsurfacelinesCsv =string.Format(surfaceLineFormat, fileName); + string twovalidsurfacelinesCsv = string.Format(surfaceLineFormat, fileName); string twovalidsurfacelinesCharacteristicPointsCsv = string.Format(krpFormat, fileName); string validSurfaceLinesFilePath = Path.Combine(pluginSurfaceLinesTestDataPath, twovalidsurfacelinesCsv); @@ -1317,8 +1344,23 @@ var importer = new PipingSurfaceLinesCsvImporter(); int callCount = 0; + bool progressStarted = false; + bool progressCharacteristicPointsStarted = false; importer.ProgressChanged = delegate(string currentStepName, int currentStep, int totalNumberOfSteps) { + if (!progressStarted && callCount == 0) + { + progressStarted = true; + Assert.AreEqual(ApplicationResources.PipingSurfaceLinesCsvImporter_Reading_surface_line_file, currentStepName); + return; + } + if (!progressCharacteristicPointsStarted && callCount == expectedNumberOfSurfaceLines + 1) + { + progressCharacteristicPointsStarted = true; + Assert.AreEqual(ApplicationResources.PipingSurfaceLinesCsvImporter_Reading_characteristic_points_file, currentStepName); + return; + } + if (callCount <= expectedNumberOfSurfaceLines) { Assert.AreEqual(string.Format(ApplicationResources.PipingSurfaceLinesCsvImporter_Read_PipingSurfaceLines_0_, twovalidsurfacelinesCsv), currentStepName); @@ -1410,7 +1452,7 @@ var context = new RingtoetsPipingSurfaceLinesContext(failureMechanism, assessmentSection); context.Attach(observer); - var importer = new PipingSurfaceLinesCsvImporter(); + var importer = new PipingSurfaceLinesCsvImporter(); // Precondition CollectionAssert.IsEmpty(context.FailureMechanism.SurfaceLines);