Index: Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs
===================================================================
diff -u -rae6f0c6b534ca650e160ae6d9c0bc90369d25c68 -rfd1d509e55af9d6961d8765545261f47cb61ee4d
--- Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision ae6f0c6b534ca650e160ae6d9c0bc90369d25c68)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/StorageSqLite.cs (.../StorageSqLite.cs) (revision fd1d509e55af9d6961d8765545261f47cb61ee4d)
@@ -204,6 +204,12 @@
}
}
+ public void CloseProject()
+ {
+ filePath = null;
+ connectionString = null;
+ }
+
public bool HasChanges(Project project)
{
if (string.IsNullOrWhiteSpace(connectionString))
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs
===================================================================
diff -u -rbc9552772d4e6a6bd786dfcaef808da1964e8c53 -rfd1d509e55af9d6961d8765545261f47cb61ee4d
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs (.../StorageSqLiteTest.cs) (revision bc9552772d4e6a6bd786dfcaef808da1964e8c53)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/StorageSqLiteTest.cs (.../StorageSqLiteTest.cs) (revision fd1d509e55af9d6961d8765545261f47cb61ee4d)
@@ -551,6 +551,33 @@
}
[Test]
+ public void HasChanges_ValidProjectLoadedAndThenClosed_ReturnsTrue()
+ {
+ // Setup
+ StorageSqLite storageSqLite = new StorageSqLite();
+ Project storedProject = new Project();
+
+ FileDisposeHelper fileDisposeHelper = new FileDisposeHelper(tempRingtoetsFile);
+ try
+ {
+ SqLiteDatabaseHelper.CreateValidRingtoetsDatabase(tempRingtoetsFile, storedProject);
+ Project loadedProject = storageSqLite.LoadProject(tempRingtoetsFile);
+ storageSqLite.CloseProject();
+
+ // Call
+ bool hasChanges = storageSqLite.HasChanges(loadedProject);
+
+ // Assert
+ Assert.IsTrue(hasChanges);
+ }
+ finally
+ {
+ CallGarbageCollector();
+ fileDisposeHelper.Dispose();
+ }
+ }
+
+ [Test]
public void HasChanges_ValidProjectLoadedWithUnaffectedChange_ReturnsFalse()
{
// Setup
Index: Core/Common/src/Core.Common.Base/Storage/IStoreProject.cs
===================================================================
diff -u -r78144c676f04f1b9c94f6256b3e764cf527f378e -rfd1d509e55af9d6961d8765545261f47cb61ee4d
--- Core/Common/src/Core.Common.Base/Storage/IStoreProject.cs (.../IStoreProject.cs) (revision 78144c676f04f1b9c94f6256b3e764cf527f378e)
+++ Core/Common/src/Core.Common.Base/Storage/IStoreProject.cs (.../IStoreProject.cs) (revision fd1d509e55af9d6961d8765545261f47cb61ee4d)
@@ -88,6 +88,11 @@
Project LoadProject(string connectionArguments);
///
+ /// Removes the connection to a database that has been made previously.
+ ///
+ void CloseProject();
+
+ ///
/// Checks if differs from the last saved or loaded , if any.
///
/// The to save.
Index: Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs
===================================================================
diff -u -rb45253e05c4d283273a39672c5ca8aaf1b398d71 -rfd1d509e55af9d6961d8765545261f47cb61ee4d
--- Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision b45253e05c4d283273a39672c5ca8aaf1b398d71)
+++ Core/Common/src/Core.Common.Gui/Commands/StorageCommandHandler.cs (.../StorageCommandHandler.cs) (revision fd1d509e55af9d6961d8765545261f47cb61ee4d)
@@ -162,6 +162,7 @@
projectOwner.Project = null;
projectOwner.ProjectFilePath = "";
+ projectPersistor.CloseProject();
applicationSelection.Selection = null;
mainWindowController.RefreshGui();
Index: Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs
===================================================================
diff -u -r78144c676f04f1b9c94f6256b3e764cf527f378e -rfd1d509e55af9d6961d8765545261f47cb61ee4d
--- Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision 78144c676f04f1b9c94f6256b3e764cf527f378e)
+++ Core/Common/test/Core.Common.Gui.Test/Commands/StorageCommandHandlerTest.cs (.../StorageCommandHandlerTest.cs) (revision fd1d509e55af9d6961d8765545261f47cb61ee4d)
@@ -133,6 +133,7 @@
viewCommands.Expect(g => g.RemoveAllViewsForItem(projectMock));
var projectStorage = mocks.Stub();
+ projectStorage.Expect(ps => ps.CloseProject());
var projectOwner = mocks.Stub();
projectOwner.Project = projectMock;
@@ -456,6 +457,7 @@
var projectStorage = mocks.Stub();
projectStorage.Stub(ps => ps.LoadProject(pathToSomeInvalidFile))
.Return(loadedProject);
+ projectStorage.Stub(ps => ps.CloseProject());
var applicationSelection = mocks.Stub();
applicationSelection.Selection = originalProject;