Index: Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs =================================================================== diff -u -r7fb7b486bcbdd216ef834eaed0c89a1362e119e2 -rfc5dec9b2a89e3593042a84dcc1f2709946b291f --- Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision 7fb7b486bcbdd216ef834eaed0c89a1362e119e2) +++ Core/Common/src/Core.Common.Gui/Commands/GuiImportHandler.cs (.../GuiImportHandler.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) @@ -146,11 +146,15 @@ { RunImportActivity(importInfo.CreateFileImporter(target, fileDialogResult), importInfo.Name); } + else + { + log.InfoFormat(Resources.GuiImportHandler_ImportItemsUsingDialog_Importing_cancelled); + } } private void RunImportActivity(IFileImporter importer, string importName) { - log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data); + log.Info(Resources.GuiImportHandler_RunImportActivity_Start_importing_data); var activity = new FileImportActivity(importer, importName ?? string.Empty); ActivityProgressDialogRunner.Run(dialogParent, activity); Index: Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs =================================================================== diff -u -r7fb7b486bcbdd216ef834eaed0c89a1362e119e2 -rfc5dec9b2a89e3593042a84dcc1f2709946b291f --- Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs (.../GuiUpdateHandler.cs) (revision 7fb7b486bcbdd216ef834eaed0c89a1362e119e2) +++ Core/Common/src/Core.Common.Gui/Commands/GuiUpdateHandler.cs (.../GuiUpdateHandler.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) @@ -140,7 +140,8 @@ private void UpdateItemsUsingDialog(UpdateInfo updateInfo, object target) { - string filePath = updateInfo.CurrentPath(target); + string oldPath = updateInfo.CurrentPath(target); + string filePath = oldPath; if (!File.Exists(filePath)) { filePath = inquiryHelper.GetSourceFileLocation(updateInfo.FileFilterGenerator); @@ -149,11 +150,15 @@ { RunUpdateActivity(updateInfo.CreateFileImporter(target, filePath), updateInfo.Name); } + else + { + log.InfoFormat(Resources.GuiUpdateHandler_UpdateItemsUsingDialog_Updating_from_Path_0_cancelled, oldPath); + } } private void RunUpdateActivity(IFileImporter importer, string importName) { - log.Info(Resources.GuiImportHandler_ImportItemsUsingDialog_Start_importing_data); + log.Info(Resources.GuiUpdateHandler_RunUpdateActivity_Start_importing_data); var activity = new FileImportActivity(importer, importName ?? string.Empty); ActivityProgressDialogRunner.Run(dialogParent, activity); Index: Core/Common/src/Core.Common.Gui/IInquiryHelper.cs =================================================================== diff -u -r8eb717ca45b6518cccfef85e481e0da52ce1df4e -rfc5dec9b2a89e3593042a84dcc1f2709946b291f --- Core/Common/src/Core.Common.Gui/IInquiryHelper.cs (.../IInquiryHelper.cs) (revision 8eb717ca45b6518cccfef85e481e0da52ce1df4e) +++ Core/Common/src/Core.Common.Gui/IInquiryHelper.cs (.../IInquiryHelper.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) @@ -28,26 +28,23 @@ public interface IInquiryHelper { /// - /// Returns a containing a path to an existing file - /// if the user did not cancel the inquiry. + /// Returns the path of an existing file if the user did not cancel the inquiry. /// - /// A new . + /// A file location, or null if no location was chosen. string GetSourceFileLocation(); /// - /// Returns a containing a path to an existing file - /// if the user did not cancel the inquiry. + /// Returns the path of an existing file if the user did not cancel the inquiry. /// - /// A filter to which the path in the returned - /// complies. - /// A new . + /// A filter to which the path returned complies. + /// A file location, or null if no location was chosen. string GetSourceFileLocation(FileFilterGenerator filter); /// - /// Returns a containing a path to a (non-existing) file - /// if the user did not cancel the inquiry. + /// Returns the path to a (non-existing) file if the user did not cancel the inquiry. /// - /// A containing a path to a (non-existing) file. + /// A path to a (non-existing) file, or null if no location + /// was chosen. string GetTargetFileLocation(); /// Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs =================================================================== diff -u -r45440093089496f59ed420e772136756c229e30b -rfc5dec9b2a89e3593042a84dcc1f2709946b291f --- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 45440093089496f59ed420e772136756c229e30b) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) @@ -889,11 +889,20 @@ } /// + /// Looks up a localized string similar to Importeren van gegevens is door de gebruiker geannuleerd.. + /// + public static string GuiImportHandler_ImportItemsUsingDialog_Importing_cancelled { + get { + return ResourceManager.GetString("GuiImportHandler_ImportItemsUsingDialog_Importing_cancelled", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Begonnen met het importeren van gegevens.. /// - public static string GuiImportHandler_ImportItemsUsingDialog_Start_importing_data { + public static string GuiImportHandler_RunImportActivity_Start_importing_data { get { - return ResourceManager.GetString("GuiImportHandler_ImportItemsUsingDialog_Start_importing_data", resourceCulture); + return ResourceManager.GetString("GuiImportHandler_RunImportActivity_Start_importing_data", resourceCulture); } } @@ -945,6 +954,24 @@ } /// + /// Looks up a localized string similar to Begonnen met het bijwerken van gegevens.. + /// + public static string GuiUpdateHandler_RunUpdateActivity_Start_importing_data { + get { + return ResourceManager.GetString("GuiUpdateHandler_RunUpdateActivity_Start_importing_data", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bijwerken van gegevens in '{0}' is door de gebruiker geannuleerd.. + /// + public static string GuiUpdateHandler_UpdateItemsUsingDialog_Updating_from_Path_0_cancelled { + get { + return ResourceManager.GetString("GuiUpdateHandler_UpdateItemsUsingDialog_Updating_from_Path_0_cancelled", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap icon_clear_all_messages { Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx =================================================================== diff -u -r45440093089496f59ed420e772136756c229e30b -rfc5dec9b2a89e3593042a84dcc1f2709946b291f --- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 45440093089496f59ed420e772136756c229e30b) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) @@ -247,9 +247,12 @@ ..\Resources\error.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - + Begonnen met het importeren van gegevens. + + Begonnen met het bijwerken van gegevens. + Fout @@ -595,4 +598,10 @@ ..\resources\table_refresh.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Bijwerken van gegevens in '{0}' is door de gebruiker geannuleerd. + + + Importeren van gegevens is door de gebruiker geannuleerd. + \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs =================================================================== diff -u -r7fb7b486bcbdd216ef834eaed0c89a1362e119e2 -rfc5dec9b2a89e3593042a84dcc1f2709946b291f --- Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision 7fb7b486bcbdd216ef834eaed0c89a1362e119e2) +++ Core/Common/test/Core.Common.Gui.Test/Commands/GuiImportHandlerTest.cs (.../GuiImportHandlerTest.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) @@ -26,6 +26,7 @@ using Core.Common.Gui.Commands; using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -327,7 +328,10 @@ }, inquiryHelper); // Call - importHandler.ImportOn(targetObject); + Action call = () => importHandler.ImportOn(targetObject); + + // Assert + TestHelper.AssertLogMessageIsGenerated(call, "Begonnen met het importeren van gegevens."); } // Assert @@ -337,6 +341,44 @@ } [Test] + public void UpdateOn_InquiryHelperReturnsNoPath_UpdateCancelledWithLogMessage() + { + // Setup + var generator = new FileFilterGenerator(); + var targetObject = new object(); + + var mockRepository = new MockRepository(); + var inquiryHelper = mockRepository.Stub(); + inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator)).Return(null); + IFileImporter fileImporter = mockRepository.Stub(); + mockRepository.ReplayAll(); + + using (var form = new Form()) + { + var importHandler = new GuiImportHandler(form, new ImportInfo[] + { + new ImportInfo + { + CreateFileImporter = (o, s) => + { + Assert.Fail("CreateFileImporter is not expected to be called when no file path is chosen."); + return fileImporter; + }, + FileFilterGenerator = generator, + VerifyUpdates = o => true + } + }, inquiryHelper); + + // Call + Action call = () => importHandler.ImportOn(targetObject); + + // Assert + TestHelper.AssertLogMessageIsGenerated(call, "Importeren van gegevens is door de gebruiker geannuleerd."); + } + mockRepository.VerifyAll(); + } + + [Test] public void ImportOn_MultipleSupportedImportInfoAvailableVerifyUpdatesUnsuccesful_ActivityNotCreated() { // Setup Index: Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs =================================================================== diff -u -r7fb7b486bcbdd216ef834eaed0c89a1362e119e2 -rfc5dec9b2a89e3593042a84dcc1f2709946b291f --- Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs (.../GuiUpdateHandlerTest.cs) (revision 7fb7b486bcbdd216ef834eaed0c89a1362e119e2) +++ Core/Common/test/Core.Common.Gui.Test/Commands/GuiUpdateHandlerTest.cs (.../GuiUpdateHandlerTest.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f) @@ -26,6 +26,7 @@ using Core.Common.Gui.Commands; using Core.Common.Gui.Forms.MainWindow; using Core.Common.Gui.Plugin; +using Core.Common.TestUtil; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -327,7 +328,10 @@ }, inquiryHelper); // Call - updateHandler.UpdateOn(targetObject); + Action call = () => updateHandler.UpdateOn(targetObject); + + // Assert + TestHelper.AssertLogMessageIsGenerated(call, "Begonnen met het bijwerken van gegevens."); } // Assert @@ -337,6 +341,44 @@ } [Test] + public void UpdateOn_InquiryHelperReturnsNoPath_UpdateCancelledWithLogMessage() + { + // Setup + var generator = new FileFilterGenerator(); + var targetObject = new object(); + + var mockRepository = new MockRepository(); + var inquiryHelper = mockRepository.Stub(); + inquiryHelper.Expect(ih => ih.GetSourceFileLocation(generator)).Return(null); + IFileImporter fileImporter = mockRepository.Stub(); + mockRepository.ReplayAll(); + + using (var form = new Form()) + { + var updateHandler = new GuiUpdateHandler(form, new UpdateInfo[] + { + new UpdateInfo + { + CreateFileImporter = (o, s) => + { + Assert.Fail("CreateFileImporter is not expected to be called when no file path is chosen."); + return fileImporter; + }, + FileFilterGenerator = generator, + VerifyUpdates = o => true + } + }, inquiryHelper); + + // Call + Action call = () => updateHandler.UpdateOn(targetObject); + + // Assert + TestHelper.AssertLogMessageIsGenerated(call, "Bijwerken van gegevens in '' is door de gebruiker geannuleerd."); + } + mockRepository.VerifyAll(); + } + + [Test] public void UpdateOn_SupportedUpdateInfoAvailableVerifyUpdatesUnsuccesful_ActivityNotCreated() { // Setup