Index: Application/Ringtoets/src/Application.Ringtoets.Migration/Application.Ringtoets.Migration.csproj
===================================================================
diff -u -r58d375a1c6b920e8597eae37dde622fda6a456ee -r090bf03ca13a96b9e7c0a71b89f6853c303f7c02
--- Application/Ringtoets/src/Application.Ringtoets.Migration/Application.Ringtoets.Migration.csproj (.../Application.Ringtoets.Migration.csproj) (revision 58d375a1c6b920e8597eae37dde622fda6a456ee)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration/Application.Ringtoets.Migration.csproj (.../Application.Ringtoets.Migration.csproj) (revision 090bf03ca13a96b9e7c0a71b89f6853c303f7c02)
@@ -34,6 +34,11 @@
+
+
+ ..\..\..\..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net40\System.Data.SQLite.dll
+ True
+
@@ -46,16 +51,26 @@
Resources.resx
+
+
+
+
Copying.licenseheader
+
+
+ {3BBFD65B-B277-4E50-AE6D-BD24C3434609}
+ Core.Common.Base
+ False
+ {e344867e-9ac9-44c8-88a5-8185681679a9}Core.Common.IO
@@ -96,6 +111,13 @@
+
+
+
+ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
+
+
+
+
+
+
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj
===================================================================
diff -u -r58d375a1c6b920e8597eae37dde622fda6a456ee -r090bf03ca13a96b9e7c0a71b89f6853c303f7c02
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj (.../Application.Ringtoets.Migration.Test.csproj) (revision 58d375a1c6b920e8597eae37dde622fda6a456ee)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj (.../Application.Ringtoets.Migration.Test.csproj) (revision 090bf03ca13a96b9e7c0a71b89f6853c303f7c02)
@@ -56,6 +56,9 @@
Properties\GlobalAssembly.cs
+
+
+
@@ -67,6 +70,10 @@
+
+ {3BBFD65B-B277-4E50-AE6D-BD24C3434609}
+ Core.Common.Base
+ {E344867E-9AC9-44C8-88A5-8185681679A9}Core.Common.IO
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseFileTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseFileTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseFileTest.cs (revision 090bf03ca13a96b9e7c0a71b89f6853c303f7c02)
@@ -0,0 +1,233 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Data.SQLite;
+using System.IO;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Migration.Test
+{
+ [TestFixture]
+ public class RingtoetsDatabaseFileTest
+ {
+ [Test]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase(null)]
+ public void Constructor_FilePathNullOrWhiteSpace_ThrowsArgumentException(string filePath)
+ {
+ // Call
+ TestDelegate call = () =>
+ {
+ using (new RingtoetsDatabaseFile(filePath)) {}
+ };
+
+ // Assert
+ ArgumentException exception = Assert.Throws(call);
+ Assert.AreEqual($"Fout bij het lezen van bestand '{filePath}': bestandspad mag niet leeg of ongedefinieerd zijn.", exception.Message);
+ }
+
+ [Test]
+ public void Constructor_FileNotWritable_ThrowsArgumentException()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ using (new FileDisposeHelper(filePath))
+ {
+ FileAttributes attributes = File.GetAttributes(filePath);
+ File.SetAttributes(filePath, attributes | FileAttributes.ReadOnly);
+ try
+ {
+ // Call
+ TestDelegate call = () =>
+ {
+ using (new RingtoetsDatabaseFile(filePath)) {}
+ };
+
+ // Assert
+ string expectedMessage = $"Er is een onverwachte fout opgetreden tijdens het schrijven van het bestand '{filePath}'.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+ }
+ finally
+ {
+ File.SetAttributes(filePath, attributes);
+ }
+ }
+ }
+
+ [Test]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase(null)]
+ public void CreateStructure_QueryIsNullOrWhiteSpace_ThrowsArgumentException(string query)
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ using (new FileDisposeHelper(filePath))
+ using (var databaseFile = new RingtoetsDatabaseFile(filePath))
+ {
+ databaseFile.OpenDatabaseConnection();
+
+ // Call
+ TestDelegate call = () => databaseFile.CreateStructure(query);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("query", paramName);
+ }
+ }
+
+ [Test]
+ public void CreateStructure_InvalidQuery_ThrowsSQLiteException()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ using (new FileDisposeHelper(filePath))
+ using (var databaseFile = new RingtoetsDatabaseFile(filePath))
+ {
+ databaseFile.OpenDatabaseConnection();
+
+ // Call
+ TestDelegate call = () => databaseFile.CreateStructure("THIS WILL FAIL");
+
+ // Assert
+ Assert.Throws(call);
+ }
+ }
+
+ [Test]
+ public void CreateStructure_ValidQuery_CreatesFile()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ using (var databaseFile = new RingtoetsDatabaseFile(filePath))
+ {
+ databaseFile.OpenDatabaseConnection();
+
+ // Call
+ databaseFile.CreateStructure(";");
+
+ // Assert
+ Assert.IsTrue(File.Exists(filePath));
+ }
+
+ using (new FileDisposeHelper(filePath)) {}
+ }
+
+ [Test]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase(null)]
+ public void ExecuteMigration_QueryIsNullOrWhiteSpace_ThrowsArgumentException(string query)
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ using (new FileDisposeHelper(filePath))
+ using (var databaseFile = new RingtoetsDatabaseFile(filePath))
+ {
+ databaseFile.OpenDatabaseConnection();
+
+ // Call
+ TestDelegate call = () => databaseFile.ExecuteMigration(query);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("query", paramName);
+ }
+ }
+
+ [Test]
+ public void ExecuteMigration_InvalidQuery_ThrowsSQLiteException()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ using (new FileDisposeHelper(filePath))
+ using (var databaseFile = new RingtoetsDatabaseFile(filePath))
+ {
+ databaseFile.OpenDatabaseConnection();
+
+ // Call
+ TestDelegate call = () => databaseFile.ExecuteMigration("THIS WILL FAIL");
+
+ // Assert
+ Assert.Throws(call);
+ }
+ }
+
+ [Test]
+ public void ExecuteMigration_ValidQuery_CreatesFile()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ using (var databaseFile = new RingtoetsDatabaseFile(filePath))
+ {
+ databaseFile.OpenDatabaseConnection();
+
+ // Call
+ databaseFile.ExecuteMigration(";");
+
+ // Assert
+ Assert.IsTrue(File.Exists(filePath));
+ }
+
+ using (new FileDisposeHelper(filePath)) {}
+ }
+
+ [Test]
+ public void Dispose_AlreadyDisposed_DoesNotThrowException()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ // Call
+ TestDelegate call = () =>
+ {
+ using (var databaseFile = new RingtoetsDatabaseFile(filePath))
+ {
+ databaseFile.Dispose();
+ }
+ };
+
+ using (new FileDisposeHelper(filePath))
+ {
+ // Assert
+ Assert.DoesNotThrow(call);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseQueryBuilderTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseQueryBuilderTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseQueryBuilderTest.cs (revision 090bf03ca13a96b9e7c0a71b89f6853c303f7c02)
@@ -0,0 +1,40 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Migration.Test
+{
+ [TestFixture]
+ public class RingtoetsDatabaseQueryBuilderTest
+ {
+ [Test]
+ public void GetVersionQuery_ReturnsExpectedQuery()
+ {
+ // Call
+ string getVersionQuery = RingtoetsDatabaseQueryBuilder.GetVersionQuery();
+
+ // Assert
+ Assert.AreEqual("SELECT Version FROM VersionEntity Order by Timestamp DESC LIMIT 1",
+ getVersionQuery);
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseSourceFileTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseSourceFileTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsDatabaseSourceFileTest.cs (revision 090bf03ca13a96b9e7c0a71b89f6853c303f7c02)
@@ -0,0 +1,122 @@
+// Copyright (C) Stichting Deltares 2016. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.IO;
+using Core.Common.Base.Storage;
+using Core.Common.IO.Exceptions;
+using Core.Common.IO.Readers;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+
+namespace Application.Ringtoets.Migration.Test
+{
+ [TestFixture]
+ public class RingtoetsDatabaseSourceFileTest
+ {
+ [Test]
+ public void Constructor_NonExistingPath_ThrowsCriticalFileReadException()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ // Call
+ TestDelegate test = () =>
+ {
+ using (new RingtoetsDatabaseSourceFile(filePath)) {}
+ };
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual($"Fout bij het lezen van bestand '{filePath}': {"het bestand bestaat niet."}",
+ exception.Message);
+ }
+
+ [Test]
+ [TestCase(null)]
+ [TestCase("")]
+ public void Constructor_FileNullOrEmpty_ThrowsCriticalFileReadException(string filePath)
+ {
+ // Call
+ TestDelegate test = () =>
+ {
+ using (new RingtoetsDatabaseSourceFile(filePath)) {}
+ };
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual($"Fout bij het lezen van bestand '{filePath}': {"bestandspad mag niet leeg of ongedefinieerd zijn."}",
+ exception.Message);
+ }
+
+ [Test]
+ public void Constructor_ValidPath_ExpectedProperties()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ // Call
+ using (new FileDisposeHelper(filePath))
+ using (var file = new RingtoetsDatabaseSourceFile(filePath))
+ {
+ // Assert
+ Assert.IsInstanceOf(file);
+ }
+ }
+
+ [Test]
+ public void GetVersion_EmptyFile_ThrowsStorageValidationException()
+ {
+ // Setup
+ string filename = Path.GetRandomFileName();
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, filename);
+
+ using (new FileDisposeHelper(filePath))
+ using (var file = new RingtoetsDatabaseSourceFile(filePath))
+ {
+ // Call
+ TestDelegate call = () => file.GetVersion();
+
+ // Assert
+ string message = Assert.Throws(call).Message;
+ Assert.AreEqual($"Het bestand '{filePath}' is moet een geldig Ringtoets database bestand zijn.",
+ message);
+ }
+ }
+
+ [Test]
+ public void GetVersion_EmptyRingtoetsDatabaseFile_ReturnsEmpty()
+ {
+ // Setup
+ string filePath = TestHelper.GetTestDataPath(TestDataPath.Migration.Core.Storage, "EmptyDatabase.rtd");
+
+ using (var file = new RingtoetsDatabaseSourceFile(filePath))
+ {
+ // Call
+ string version = file.GetVersion();
+
+ // Assert
+ Assert.AreEqual(string.Empty, version);
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsUpgradeScriptTest.cs
===================================================================
diff -u -r58d375a1c6b920e8597eae37dde622fda6a456ee -r090bf03ca13a96b9e7c0a71b89f6853c303f7c02
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsUpgradeScriptTest.cs (.../RingtoetsUpgradeScriptTest.cs) (revision 58d375a1c6b920e8597eae37dde622fda6a456ee)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsUpgradeScriptTest.cs (.../RingtoetsUpgradeScriptTest.cs) (revision 090bf03ca13a96b9e7c0a71b89f6853c303f7c02)
@@ -102,50 +102,6 @@
}
[Test]
- public void Upgrade_SourceNull_ThrowsArgumentNullException()
- {
- // Setup
- var mockRepository = new MockRepository();
- var targetVersionedFile = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- const string fromVersion = "fromVersion";
- const string toVersion = "toVersion";
- const string query = ";";
- var upgradeScript = new RingtoetsUpgradeScript(fromVersion, toVersion, query);
-
- // Call
- TestDelegate call = () => upgradeScript.Upgrade(null, targetVersionedFile);
-
- // Assert
- string paramName = Assert.Throws(call).ParamName;
- Assert.AreEqual("source", paramName);
- mockRepository.VerifyAll();
- }
-
- [Test]
- public void Upgrade_TargetNull_ThrowsArgumentNullException()
- {
- // Setup
- var mockRepository = new MockRepository();
- var sourceVersionedFile = mockRepository.Stub();
- mockRepository.ReplayAll();
-
- const string fromVersion = "fromVersion";
- const string toVersion = "toVersion";
- const string query = ";";
- var upgradeScript = new RingtoetsUpgradeScript(fromVersion, toVersion, query);
-
- // Call
- TestDelegate call = () => upgradeScript.Upgrade(sourceVersionedFile, null);
-
- // Assert
- string paramName = Assert.Throws(call).ParamName;
- Assert.AreEqual("target", paramName);
- mockRepository.VerifyAll();
- }
-
- [Test]
public void Upgrade_UpgradeFails_ThrowsSQLiteException()
{
// Setup
Index: Migration/Scripts/src/Migration.Scripts.Data/Migration.Scripts.Data.csproj
===================================================================
diff -u -rdcce1c8c694a59962a2c0cdf4c4f71cacbff0e74 -r090bf03ca13a96b9e7c0a71b89f6853c303f7c02
--- Migration/Scripts/src/Migration.Scripts.Data/Migration.Scripts.Data.csproj (.../Migration.Scripts.Data.csproj) (revision dcce1c8c694a59962a2c0cdf4c4f71cacbff0e74)
+++ Migration/Scripts/src/Migration.Scripts.Data/Migration.Scripts.Data.csproj (.../Migration.Scripts.Data.csproj) (revision 090bf03ca13a96b9e7c0a71b89f6853c303f7c02)
@@ -54,11 +54,7 @@
TrueResources.resx
-
-
-
-
Fisheye: Tag 090bf03ca13a96b9e7c0a71b89f6853c303f7c02 refers to a dead (removed) revision in file `Migration/Scripts/src/Migration.Scripts.Data/RingtoetsDatabaseFile.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 090bf03ca13a96b9e7c0a71b89f6853c303f7c02 refers to a dead (removed) revision in file `Migration/Scripts/src/Migration.Scripts.Data/RingtoetsDatabaseQueryBuilder.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 090bf03ca13a96b9e7c0a71b89f6853c303f7c02 refers to a dead (removed) revision in file `Migration/Scripts/src/Migration.Scripts.Data/RingtoetsDatabaseSourceFile.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 090bf03ca13a96b9e7c0a71b89f6853c303f7c02 refers to a dead (removed) revision in file `Migration/Scripts/src/Migration.Scripts.Data/VersionTableDefinitions.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj
===================================================================
diff -u -r58d375a1c6b920e8597eae37dde622fda6a456ee -r090bf03ca13a96b9e7c0a71b89f6853c303f7c02
--- Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj (.../Migration.Scripts.Data.Test.csproj) (revision 58d375a1c6b920e8597eae37dde622fda6a456ee)
+++ Migration/Scripts/test/Migration.Scripts.Data.Test/Migration.Scripts.Data.Test.csproj (.../Migration.Scripts.Data.Test.csproj) (revision 090bf03ca13a96b9e7c0a71b89f6853c303f7c02)
@@ -49,11 +49,6 @@
-
-
- ..\..\..\..\packages\System.Data.SQLite.Core.1.0.104.0\lib\net40\System.Data.SQLite.dll
- True
-
@@ -63,9 +58,6 @@
-
-
-
@@ -78,14 +70,6 @@
-
- {3BBFD65B-B277-4E50-AE6D-BD24C3434609}
- Core.Common.Base
-
-
- {E344867E-9AC9-44C8-88A5-8185681679A9}
- Core.Common.IO
- {D749EE4C-CE50-4C17-BF01-9A953028C126}Core.Common.TestUtil
@@ -97,13 +81,6 @@
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-