Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs
===================================================================
diff -u -r11a119a0e7355031786e31913541fb653691d7eb -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 11a119a0e7355031786e31913541fb653691d7eb)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -210,7 +210,7 @@
var expectedMessages = new[]
{
"Openen van bestaand Ringtoetsproject...",
- "Bestaand Ringtoetsproject succesvol geopend."
+ "Uitvoeren van 'Openen van bestaand project' is gelukt."
};
TestHelper.AssertLogMessagesAreGenerated(action, expectedMessages, 3);
Assert.AreEqual(tempRingtoetsFile, gui.ProjectFilePath);
Index: Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs
===================================================================
diff -u -r206804512fc341a06a08565ee0a9711768079ed9 -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs (.../IMigrateProject.cs) (revision 206804512fc341a06a08565ee0a9711768079ed9)
+++ Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs (.../IMigrateProject.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -44,6 +44,8 @@
///
/// The file path to be used as location for the migration result. Value
/// will be null if no target file path an be provided.
+ /// Thrown when is null.
+ /// Thrown when is an invalid file path.
string DetermineMigrationLocation(string originalFilePath);
///
Index: Core/Common/src/Core.Common.Base/Storage/MigrationNeeded.cs
===================================================================
diff -u -rac9f1f110b53f4bf66b4f2fe04d34178273ac4fd -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/src/Core.Common.Base/Storage/MigrationNeeded.cs (.../MigrationNeeded.cs) (revision ac9f1f110b53f4bf66b4f2fe04d34178273ac4fd)
+++ Core/Common/src/Core.Common.Base/Storage/MigrationNeeded.cs (.../MigrationNeeded.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -27,14 +27,14 @@
public enum MigrationNeeded
{
///
- /// Migration is required.
+ /// Migration is not needed.
///
- Yes,
+ No,
///
- /// Migration is not needed.
+ /// Migration is required.
///
- No,
+ Yes,
///
/// Migration workflow aborted.
Index: Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs
===================================================================
diff -u -r0d01d77a85f997d3cbe2e3f83d6bf3438ec6806d -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision 0d01d77a85f997d3cbe2e3f83d6bf3438ec6806d)
+++ Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -24,7 +24,9 @@
using System.IO;
using System.Windows.Forms;
using Core.Common.Base.Data;
+using Core.Common.Base.Service;
using Core.Common.Base.Storage;
+using Core.Common.Gui.Forms.ProgressDialog;
using Core.Common.Gui.Properties;
using log4net;
@@ -130,54 +132,17 @@
{
log.Info(Resources.StorageCommandHandler_OpenExistingProject_Opening_existing_project);
- string migratedProjectFilePath = filePath;
- var isOpenProjectSuccessful = false;
-
try
{
- MigrationNeeded migrationNeeded = projectMigrator.ShouldMigrate(filePath);
- if (migrationNeeded == MigrationNeeded.Yes)
- {
- migratedProjectFilePath = projectMigrator.DetermineMigrationLocation(filePath);
- if (!string.IsNullOrWhiteSpace(migratedProjectFilePath))
- {
- isOpenProjectSuccessful = projectMigrator.Migrate(filePath, migratedProjectFilePath);
- }
- }
- else if (migrationNeeded == MigrationNeeded.Aborted)
- {
- migratedProjectFilePath = null;
- isOpenProjectSuccessful = false;
- }
+ return OpenExistingProjectCore(filePath);
}
catch (ArgumentException e)
{
- migratedProjectFilePath = null;
- isOpenProjectSuccessful = false;
log.Error(e.Message, e);
- }
-
- IProject newProject = null;
- if (!string.IsNullOrEmpty(migratedProjectFilePath))
- {
- newProject = LoadProjectFromStorage(migratedProjectFilePath);
- isOpenProjectSuccessful = newProject != null;
- }
-
- if (isOpenProjectSuccessful)
- {
- log.Info(Resources.StorageCommandHandler_OpeningExistingProject_Opening_existing_project_successful);
- projectOwner.SetProject(newProject, migratedProjectFilePath);
- newProject.Name = Path.GetFileNameWithoutExtension(migratedProjectFilePath);
- newProject.NotifyObservers();
- }
- else
- {
log.Error(Resources.StorageCommandHandler_OpeningExistingProject_Opening_existing_project_failed);
projectOwner.SetProject(projectFactory.CreateNewProject(), null);
+ return false;
}
-
- return isOpenProjectSuccessful;
}
public bool SaveProjectAs()
@@ -228,6 +193,94 @@
return true;
}
+ ///
+ /// Opens the given project file and determines if migration to the current version is
+ /// required and performs migration if needed.
+ ///
+ /// The project file to open.
+ /// Returns true if the project was successfully opened; Returns
+ /// false if an error occurred or when opening the project has been cancelled.
+ /// Thrown when is
+ /// not a valid filepath.
+ /// Thrown when
+ /// is null.
+ private bool OpenExistingProjectCore(string filePath)
+ {
+ OpenProjectActivity.ProjectMigrationConstructionProperties migrationProperties;
+ if (PrepareProjectMigration(filePath, out migrationProperties) == MigrationNeeded.Aborted)
+ {
+ log.Info(Resources.StorageCommandHandler_OpenExistingProject_Opening_existing_project_canceled);
+ return false;
+ }
+
+ return MigrateAndOpenProject(filePath, migrationProperties);
+ }
+
+ ///
+ /// Check if migration is required and if so the migration settings are initialized.
+ ///
+ /// The project file to open.
+ /// Output: Will be null is this method
+ /// returns or .
+ /// Will be a concrete instance if this method returns .
+ /// Indicates if migration is required or not, or that the operation has
+ /// been cancelled.
+ /// Thrown when is
+ /// not a valid filepath.
+ /// Thrown when
+ /// is null.
+ private MigrationNeeded PrepareProjectMigration(string filePath,
+ out OpenProjectActivity.ProjectMigrationConstructionProperties migrationConstructionProperties)
+ {
+ migrationConstructionProperties = null;
+ MigrationNeeded migrationNeeded = projectMigrator.ShouldMigrate(filePath);
+ if (migrationNeeded == MigrationNeeded.Yes)
+ {
+ string projectFilePathTakingIntoAccountMigration = projectMigrator.DetermineMigrationLocation(filePath);
+ if (string.IsNullOrWhiteSpace(projectFilePathTakingIntoAccountMigration))
+ {
+ migrationNeeded = MigrationNeeded.Aborted;
+ }
+ else
+ {
+ migrationConstructionProperties = new OpenProjectActivity.ProjectMigrationConstructionProperties
+ {
+ Migrator = projectMigrator,
+ MigrationFilePath = projectFilePathTakingIntoAccountMigration
+ };
+ }
+ }
+
+ return migrationNeeded;
+ }
+
+ ///
+ /// Starts an activity that can migrate the project if required, then opens the project.
+ ///
+ /// The project file to open.
+ /// The construction properties related to migrating
+ /// a project. Can be null.
+ /// Returns true if the operation completed successfully; Returns
+ /// false otherwise (for example when the operation failed or was cancelled).
+ /// Thrown when is
+ /// not a valid filepath.
+ /// Thrown when
+ /// is null.
+ private bool MigrateAndOpenProject(string filePath, OpenProjectActivity.ProjectMigrationConstructionProperties migrationProperties)
+ {
+ var openProjectProperties = new OpenProjectActivity.OpenProjectConstructionProperties
+ {
+ FilePath = filePath,
+ ProjectOwner = projectOwner,
+ ProjectFactory = projectFactory,
+ ProjectStorage = projectPersistor
+ };
+ var activity = new OpenProjectActivity(openProjectProperties, migrationProperties);
+ ActivityProgressDialogRunner.Run(dialogParent, activity);
+
+ return activity.State == ActivityState.Finished;
+ }
+
private bool IsCurrentNew()
{
return projectOwner.Project.Equals(projectFactory.CreateNewProject());
Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj
===================================================================
diff -u -r150266cb90055d70e7dc2510962aff5f5c5b1ede -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 150266cb90055d70e7dc2510962aff5f5c5b1ede)
+++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -181,7 +181,6 @@
ActivityProgressDialog.cs
-
Index: Core/Common/src/Core.Common.Gui/Forms/ProgressDialog/ActivityProgressDialog.cs
===================================================================
diff -u -r4faae1433690b9b06b40c18ff322140aa16df739 -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/src/Core.Common.Gui/Forms/ProgressDialog/ActivityProgressDialog.cs (.../ActivityProgressDialog.cs) (revision 4faae1433690b9b06b40c18ff322140aa16df739)
+++ Core/Common/src/Core.Common.Gui/Forms/ProgressDialog/ActivityProgressDialog.cs (.../ActivityProgressDialog.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -41,11 +41,34 @@
{
private readonly IEnumerable activities;
private readonly CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
- private readonly ProgressReporter progressReporter = new ProgressReporter();
private Task task;
private Activity runningActivity;
///
+ /// Method prototype for updating the progress step visualization user controls.
+ ///
+ /// The current step number.
+ /// The total number of activities.
+ private delegate void UpdateActivityStepControlsDelegate(int stepNumberForProgressNotification, int activityCount);
+
+ ///
+ /// Method prototype for updating the progress bar control.
+ ///
+ /// The new progress bar value.
+ private delegate void UpdateProgressBarDelegate(int progressBarValue);
+
+ ///
+ /// Method prototype for calling and closing this dialog.
+ ///
+ private delegate void FinishActivitiesAndCloseDialogDelegate();
+
+ ///
+ /// Method prototype for updating controls visualizing the progress of the activities.
+ ///
+ /// The activity currently raising .
+ private delegate void UpdateProgressControlsDelegate(Activity activity);
+
+ ///
/// Initializes a new instance of the class.
///
/// The dialog parent for which this dialog should be shown on top.
@@ -78,21 +101,16 @@
runningActivity = activities.ElementAt(i);
int stepNumberForProgressNotification = i + 1;
- progressReporter.ReportProgress(() =>
+ if (InvokeRequired)
{
- // Update the activity description label
- labelActivityDescription.Text = runningActivity.Name;
+ UpdateActivityStepControlsDelegate updateDelegate = UpdateProgressControls;
+ Invoke(updateDelegate, stepNumberForProgressNotification, activityCount);
+ }
+ else
+ {
+ UpdateProgressControls(stepNumberForProgressNotification, activityCount);
+ }
- // Update the visibility of the activity progress text related controls
- pictureBoxActivityProgressText.Visible = false;
- labelActivityProgressText.Visible = false;
-
- // Update the activity counter label
- labelActivityCounter.Text = string.Format(CultureInfo.CurrentCulture,
- Resources.ActivityProgressDialog_OnShown_Executing_step_0_of_1,
- stepNumberForProgressNotification, activityCount);
- });
-
try
{
if (RenderedMessageLogAppender.Instance != null)
@@ -115,26 +133,33 @@
runningActivity.ProgressChanged -= ActivityOnProgressChanged;
}
- progressReporter.ReportProgress(() =>
+ // Update the progress bar
+ int progressBarValue = (int) Math.Round(100.0 / activityCount * stepNumberForProgressNotification);
+ if (InvokeRequired)
{
- // Update the progress bar
- progressBar.Value = (int) Math.Round(100.0 / activityCount * stepNumberForProgressNotification);
- });
+ UpdateProgressBarDelegate updateDelegate = UpdateProgressBar;
+ Invoke(updateDelegate, progressBarValue);
+ }
+ else
+ {
+ UpdateProgressBar(progressBarValue);
+ }
}
}, cancellationToken);
- // Afterwards, perform actions that (might) affect the UI thread
- progressReporter.RegisterContinuation(task, () =>
+ // Afterwards, perform actions that (might) affect the UI thread.
+ task.ContinueWith(t =>
{
- // Finish all activities
- foreach (var activity in activities)
+ if (InvokeRequired)
{
- activity.Finish();
+ FinishActivitiesAndCloseDialogDelegate wrappingUpDelegate = FinishAllActivitiesAndCloseDialog;
+ Invoke(wrappingUpDelegate);
}
-
- // Close the dialog
- Close();
- });
+ else
+ {
+ FinishAllActivitiesAndCloseDialog();
+ }
+ }, CancellationToken.None);
}
protected override Button GetCancelButton()
@@ -169,6 +194,36 @@
base.Dispose(disposing);
}
+ private void FinishAllActivitiesAndCloseDialog()
+ {
+ foreach (Activity activity in activities)
+ {
+ activity.Finish();
+ }
+
+ Close();
+ }
+
+ private void UpdateProgressBar(int progressBarValue)
+ {
+ progressBar.Value = progressBarValue;
+ }
+
+ private void UpdateProgressControls(int stepNumberForProgressNotification, int activityCount)
+ {
+ // Update the activity description label
+ labelActivityDescription.Text = runningActivity.Name;
+
+ // Update the visibility of the activity progress text related controls
+ pictureBoxActivityProgressText.Visible = false;
+ labelActivityProgressText.Visible = false;
+
+ // Update the activity counter label
+ labelActivityCounter.Text = string.Format(CultureInfo.CurrentCulture,
+ Resources.ActivityProgressDialog_OnShown_Executing_step_0_of_1,
+ stepNumberForProgressNotification, activityCount);
+ }
+
private void ButtonCancelClick(object sender, EventArgs e)
{
CancelActivities();
@@ -206,17 +261,27 @@
return;
}
- progressReporter.ReportProgress(() =>
+ if (InvokeRequired)
{
- var progressTextNullOrEmpty = string.IsNullOrEmpty(activity.ProgressText);
+ UpdateProgressControlsDelegate updateDelegate = UpdateProgressControls;
+ Invoke(updateDelegate, activity);
+ }
+ else
+ {
+ UpdateProgressControls(activity);
+ }
+ }
- // Update the visibility of the activity progress text related controls
- pictureBoxActivityProgressText.Visible = !progressTextNullOrEmpty;
- labelActivityProgressText.Visible = !progressTextNullOrEmpty;
+ private void UpdateProgressControls(Activity activity)
+ {
+ var progressTextNullOrEmpty = string.IsNullOrEmpty(activity.ProgressText);
- // Update the activity progress text label
- labelActivityProgressText.Text = progressTextNullOrEmpty ? string.Empty : activity.ProgressText;
- });
+ // Update the visibility of the activity progress text related controls
+ pictureBoxActivityProgressText.Visible = !progressTextNullOrEmpty;
+ labelActivityProgressText.Visible = !progressTextNullOrEmpty;
+
+ // Update the activity progress text label
+ labelActivityProgressText.Text = progressTextNullOrEmpty ? string.Empty : activity.ProgressText;
}
}
}
\ No newline at end of file
Fisheye: Tag 8502d1a9cd739b227208f2f6ae6ea00fab758023 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Gui/Forms/ProgressDialog/ProgressReporter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Common/src/Core.Common.Gui/OpenProjectActivity.cs
===================================================================
diff -u -r150266cb90055d70e7dc2510962aff5f5c5b1ede -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/src/Core.Common.Gui/OpenProjectActivity.cs (.../OpenProjectActivity.cs) (revision 150266cb90055d70e7dc2510962aff5f5c5b1ede)
+++ Core/Common/src/Core.Common.Gui/OpenProjectActivity.cs (.../OpenProjectActivity.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -47,6 +47,7 @@
/// Optional: Properties for migrating
/// the project to the current version.
/// Thrown when any input argument is null.
+ /// Thrown when any input argument has invalid values.
public OpenProjectActivity(OpenProjectConstructionProperties requiredOpenProjectProperties,
ProjectMigrationConstructionProperties optionalProjectMigrationProperties = null)
{
@@ -93,10 +94,10 @@
return;
}
}
-
+
try
{
- openedProject = storage.LoadProject(migratedProjectFilePath ?? filePath);
+ openedProject = storage.LoadProject(FilePathTakingMigrationIntoAccount);
}
catch (StorageException e)
{
@@ -115,8 +116,8 @@
{
if (State == ActivityState.Executed)
{
- projectOwner.SetProject(openedProject, filePath);
- openedProject.Name = Path.GetFileNameWithoutExtension(filePath);
+ projectOwner.SetProject(openedProject, FilePathTakingMigrationIntoAccount);
+ openedProject.Name = Path.GetFileNameWithoutExtension(FilePathTakingMigrationIntoAccount);
openedProject.NotifyObservers();
}
@@ -131,6 +132,20 @@
}
}
+ private string FilePathTakingMigrationIntoAccount
+ {
+ get
+ {
+ return migratedProjectFilePath ?? filePath;
+ }
+ }
+
+ ///
+ /// Validates the construction arguments required for opening a project file.
+ ///
+ /// The construction arguments to be validated.
+ /// Thrown when any construction property of
+ /// is invalid.
private static void ValidateOpenProjectProperties(OpenProjectConstructionProperties requiredOpenProjectProperties)
{
if (requiredOpenProjectProperties.FilePath == null)
Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs
===================================================================
diff -u -rfc5dec9b2a89e3593042a84dcc1f2709946b291f -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f)
+++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -1530,15 +1530,6 @@
}
///
- /// Looks up a localized string similar to Bestaand Ringtoetsproject succesvol geopend..
- ///
- public static string StorageCommandHandler_OpeningExistingProject_Opening_existing_project_successful {
- get {
- return ResourceManager.GetString("StorageCommandHandler_OpeningExistingProject_Opening_existing_project_successful", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Sla wijzigingen in het project op: {0}?.
///
public static string StorageCommandHandler_OpenSaveOrDiscardProjectDialog_SaveChangesToProject_0 {
Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx
===================================================================
diff -u -rfc5dec9b2a89e3593042a84dcc1f2709946b291f -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision fc5dec9b2a89e3593042a84dcc1f2709946b291f)
+++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -502,9 +502,6 @@
Het is niet gelukt om het Ringtoetsproject te laden.
-
- Bestaand Ringtoetsproject succesvol geopend.
-
Opslaan van het Ringtoetsproject geannuleerd.
Index: Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs
===================================================================
diff -u -r0d01d77a85f997d3cbe2e3f83d6bf3438ec6806d -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision 0d01d77a85f997d3cbe2e3f83d6bf3438ec6806d)
+++ Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -213,6 +213,11 @@
projectOwner,
mainWindowController);
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Activity dialog opened and will be closed automatically once done.
+ };
+
// Call
bool result = false;
Action call = () => result = storageCommandHandler.OpenExistingProject(pathToSomeValidFile);
@@ -221,7 +226,7 @@
var expectedMessages = new[]
{
"Openen van bestaand Ringtoetsproject...",
- "Bestaand Ringtoetsproject succesvol geopend."
+ "Uitvoeren van 'Openen van bestaand project' is gelukt."
};
TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 2);
Assert.IsTrue(result);
@@ -230,7 +235,7 @@
}
[Test]
- public void OpenExistingProject_MigrationNeededButCancelled_LogFailureAndCreateNewProjectAndReturnsFalse()
+ public void OpenExistingProject_ShouldMigrateCancelled_LogCancellationAndLeaveCurrentProjectUnaffectedAndReturnsFalse()
{
// Setup
const string fileName = "newProject";
@@ -239,6 +244,54 @@
var projectStorage = mocks.StrictMock();
var projectMigrator = mocks.StrictMock();
+ projectMigrator.Expect(pm => pm.ShouldMigrate(pathToSomeValidFile)).Return(MigrationNeeded.Aborted);
+
+ var project = mocks.Stub();
+ var projectFactory = mocks.StrictMock();
+ projectFactory.Expect(pf => pf.CreateNewProject()).Return(project)
+ .Repeat.Never();
+
+ var projectOwner = mocks.StrictMock();
+ projectOwner.Stub(po => po.Project).Return(project);
+ projectOwner.Expect(po => po.SetProject(project, null))
+ .Repeat.Never();
+
+ var mainWindowController = mocks.Stub();
+ mocks.ReplayAll();
+
+ var storageCommandHandler = new StorageCommandHandler(
+ projectStorage,
+ projectMigrator,
+ projectFactory,
+ projectOwner,
+ mainWindowController);
+
+ // Call
+ bool result = true;
+ Action call = () => result = storageCommandHandler.OpenExistingProject(pathToSomeValidFile);
+
+ // Assert
+ var expectedMessages = new[]
+ {
+ "Openen van bestaand Ringtoetsproject...",
+ "Openen van bestaand Ringtoetsproject geannuleerd."
+ };
+ TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 2);
+ Assert.IsFalse(result);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void OpenExistingProject_DetermineMigrationLocationButCancelled_LogCancellationAndLeaveCurrentProjectUnaffectedAndReturnsFalse()
+ {
+ // Setup
+ const string fileName = "newProject";
+ string pathToSomeValidFile = $"C://folder/directory/{fileName}.rtd";
+
+ var projectStorage = mocks.StrictMock();
+
+ var projectMigrator = mocks.StrictMock();
using (mocks.Ordered())
{
projectMigrator.Expect(pm => pm.ShouldMigrate(pathToSomeValidFile)).Return(MigrationNeeded.Yes);
@@ -247,11 +300,13 @@
var project = mocks.Stub();
var projectFactory = mocks.StrictMock();
- projectFactory.Expect(pf => pf.CreateNewProject()).Return(project);
+ projectFactory.Expect(pf => pf.CreateNewProject()).Return(project)
+ .Repeat.Never();
var projectOwner = mocks.StrictMock();
projectOwner.Stub(po => po.Project).Return(project);
- projectOwner.Expect(po => po.SetProject(project, null));
+ projectOwner.Expect(po => po.SetProject(project, null))
+ .Repeat.Never();
var mainWindowController = mocks.Stub();
mocks.ReplayAll();
@@ -271,7 +326,7 @@
var expectedMessages = new[]
{
"Openen van bestaand Ringtoetsproject...",
- "Het is niet gelukt om het Ringtoetsproject te laden."
+ "Openen van bestaand Ringtoetsproject geannuleerd."
};
TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 2);
Assert.IsFalse(result);
@@ -341,7 +396,7 @@
{
projectMigrator.Expect(pm => pm.ShouldMigrate(pathToSomeValidFile)).Return(MigrationNeeded.Yes);
projectMigrator.Expect(pm => pm.DetermineMigrationLocation(pathToSomeValidFile))
- .Throw(new ArgumentException(errorMessage));
+ .Throw(new ArgumentException(errorMessage));
}
var project = mocks.Stub();
@@ -398,7 +453,7 @@
projectMigrator.Expect(pm => pm.Migrate(pathToSomeValidFile, pathToMigratedFile))
.Throw(new ArgumentException(errorMessage));
}
-
+
var project = mocks.Stub();
var projectFactory = mocks.StrictMock();
projectFactory.Expect(pf => pf.CreateNewProject()).Return(project);
@@ -417,6 +472,11 @@
projectOwner,
mainWindowController);
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Activity dialog opened and will be closed automatically once done.
+ };
+
// Call
bool result = true;
Action call = () => result = storageCommandHandler.OpenExistingProject(pathToSomeValidFile);
@@ -426,7 +486,7 @@
{
"Openen van bestaand Ringtoetsproject...",
errorMessage,
- "Het is niet gelukt om het Ringtoetsproject te laden."
+ "Uitvoeren van 'Openen van bestaand project' is mislukt."
};
TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 3);
Assert.IsFalse(result);
@@ -462,6 +522,11 @@
projectOwner,
mainWindowController);
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Activity dialog opened and will be closed automatically once done.
+ };
+
// Call
bool result = true;
Action call = () => result = storageCommandHandler.OpenExistingProject(pathToSomeInvalidFile);
@@ -471,7 +536,7 @@
{
"Openen van bestaand Ringtoetsproject...",
goodErrorMessageText,
- "Het is niet gelukt om het Ringtoetsproject te laden."
+ "Uitvoeren van 'Openen van bestaand project' is mislukt."
};
TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 3);
Assert.IsFalse(result);
@@ -486,13 +551,16 @@
const string pathToSomeInvalidFile = "";
IProject project = mocks.Stub();
+ var mainWindowController = mocks.Stub();
var projectStorage = mocks.Stub();
projectStorage.Stub(ps => ps.LoadProject(pathToSomeInvalidFile))
.Return(null);
+
var projectMigrator = mocks.Stub();
+
var projectFactory = mocks.Stub();
projectFactory.Stub(pf => pf.CreateNewProject()).Return(project);
- var mainWindowController = mocks.Stub();
+
var projectOwner = mocks.Stub();
projectOwner.Stub(po => po.Project).Return(project);
projectOwner.Stub(po => po.SetProject(project, null));
@@ -505,6 +573,11 @@
projectOwner,
mainWindowController);
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Activity dialog opened and will be closed automatically once done.
+ };
+
// Call
bool result = true;
Action call = () => result = storageCommandHandler.OpenExistingProject(pathToSomeInvalidFile);
@@ -513,7 +586,7 @@
var expectedMessages = new[]
{
"Openen van bestaand Ringtoetsproject...",
- "Het is niet gelukt om het Ringtoetsproject te laden."
+ "Uitvoeren van 'Openen van bestaand project' is mislukt."
};
TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 2);
Assert.IsFalse(result);
@@ -549,6 +622,11 @@
projectOwner,
mainWindowController);
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Activity dialog opened and will be closed automatically once done.
+ };
+
// Call
bool result = false;
Action call = () => result = storageCommandHandler.OpenExistingProject(pathToSomeValidFile);
@@ -557,7 +635,7 @@
var expectedMessages = new[]
{
"Openen van bestaand Ringtoetsproject...",
- "Bestaand Ringtoetsproject succesvol geopend."
+ "Uitvoeren van 'Openen van bestaand project' is gelukt."
};
TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 2);
Assert.IsTrue(result);
@@ -601,6 +679,11 @@
projectOwner,
mainWindowController);
+ DialogBoxHandler = (name, wnd) =>
+ {
+ // Activity dialog opened and will be closed automatically once done.
+ };
+
// Call
bool result = false;
Action call = () => result = storageCommandHandler.OpenExistingProject(pathToSomeValidFile);
@@ -609,7 +692,7 @@
var expectedMessages = new[]
{
"Openen van bestaand Ringtoetsproject...",
- "Bestaand Ringtoetsproject succesvol geopend."
+ "Uitvoeren van 'Openen van bestaand project' is gelukt."
};
TestHelper.AssertLogMessagesAreGenerated(call, expectedMessages, 2);
Assert.IsTrue(result);
Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj
===================================================================
diff -u -r150266cb90055d70e7dc2510962aff5f5c5b1ede -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 150266cb90055d70e7dc2510962aff5f5c5b1ede)
+++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -103,7 +103,6 @@
-
Index: Core/Common/test/Core.Common.Gui.Test/Forms/ProgressDialog/ActivityProgressDialogTest.cs
===================================================================
diff -u -r6ee6b537ca4662ee984ce1ee0b6ec7ae20396ca3 -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/test/Core.Common.Gui.Test/Forms/ProgressDialog/ActivityProgressDialogTest.cs (.../ActivityProgressDialogTest.cs) (revision 6ee6b537ca4662ee984ce1ee0b6ec7ae20396ca3)
+++ Core/Common/test/Core.Common.Gui.Test/Forms/ProgressDialog/ActivityProgressDialogTest.cs (.../ActivityProgressDialogTest.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -20,7 +20,6 @@
// All rights reserved.
using System.Linq;
-using System.Threading;
using System.Windows.Forms;
using Core.Common.Base.Service;
using Core.Common.Controls.Dialogs;
@@ -34,12 +33,6 @@
[TestFixture]
public class ActivityProgressDialogTest : NUnitFormTest
{
- [SetUp]
- public void SetUp()
- {
- SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());
- }
-
[Test]
public void DefaultConstructor_ExpectedValue()
{
Fisheye: Tag 8502d1a9cd739b227208f2f6ae6ea00fab758023 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Gui.Test/Forms/ProgressDialog/ProgressReporterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs
===================================================================
diff -u -r206804512fc341a06a08565ee0a9711768079ed9 -r8502d1a9cd739b227208f2f6ae6ea00fab758023
--- Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 206804512fc341a06a08565ee0a9711768079ed9)
+++ Core/Common/test/Core.Common.Gui.Test/GuiCoreTest.cs (.../GuiCoreTest.cs) (revision 8502d1a9cd739b227208f2f6ae6ea00fab758023)
@@ -536,7 +536,7 @@
var expectedMessages = new[]
{
Tuple.Create("Openen van bestaand Ringtoetsproject...", LogLevelConstant.Info),
- Tuple.Create("Bestaand Ringtoetsproject succesvol geopend.", LogLevelConstant.Info)
+ Tuple.Create("Uitvoeren van 'Openen van bestaand project' is gelukt.", LogLevelConstant.Info)
};
TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedMessages);
Assert.AreEqual(testFile, gui.ProjectFilePath);
@@ -588,7 +588,7 @@
var expectedMessages = new[]
{
Tuple.Create("Openen van bestaand Ringtoetsproject...", LogLevelConstant.Info),
- Tuple.Create("Het is niet gelukt om het Ringtoetsproject te laden.", LogLevelConstant.Error)
+ Tuple.Create("Openen van bestaand Ringtoetsproject geannuleerd.", LogLevelConstant.Info)
};
TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedMessages);
@@ -695,7 +695,7 @@
{
Tuple.Create("Openen van bestaand Ringtoetsproject...", LogLevelConstant.Info),
Tuple.Create(expectedErrorMessage, LogLevelConstant.Error),
- Tuple.Create("Het is niet gelukt om het Ringtoetsproject te laden.", LogLevelConstant.Error)
+ Tuple.Create("Uitvoeren van 'Openen van bestaand project' is mislukt.", LogLevelConstant.Error)
};
TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedMessages);
@@ -745,7 +745,7 @@
{
Tuple.Create("Openen van bestaand Ringtoetsproject...", LogLevelConstant.Info),
Tuple.Create(storageExceptionText, LogLevelConstant.Error),
- Tuple.Create("Het is niet gelukt om het Ringtoetsproject te laden.", LogLevelConstant.Error)
+ Tuple.Create("Uitvoeren van 'Openen van bestaand project' is mislukt.", LogLevelConstant.Error)
};
TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedMessages);