Index: Application/Ringtoets/src/Application.Ringtoets.Migration.Core/Resources/Migration_5_17.1.sql
===================================================================
diff -u -r063f989ee6aa547f5102ac539951387c31d36329 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/src/Application.Ringtoets.Migration.Core/Resources/Migration_5_17.1.sql (.../Migration_5_17.1.sql) (revision 063f989ee6aa547f5102ac539951387c31d36329)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration.Core/Resources/Migration_5_17.1.sql (.../Migration_5_17.1.sql) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -288,6 +288,55 @@
"WellKnownTileSource",
"2"
FROM BackgroundDataEntity;
+
+/* Do logging */
+
+CREATE TEMP TABLE logs_temp ('LogMessage' TEXT);
+INSERT INTO logs_temp
+SELECT "De resultaten van de betrouwbaarheid sluiting kunstwerken berekeningen (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].ClosingStructuresOutputEntity;
+INSERT INTO logs_temp
+SELECT "De resultaten van de dijkhoogte berekeningen (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].GrassCoverErosionInwardsDikeHeightOutputEntity;
+INSERT INTO logs_temp
+SELECT "De resultaten van de grasbekleding erosie kruin en binnentalud berekeningen (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].GrassCoverErosionInwardsOutputEntity;
+INSERT INTO logs_temp
+SELECT "De resultaten van de hydraulische randvoorwaardenlocatie berekeningen van het toetsspoor grasbekleding erosie buitentalud (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationOutputEntity;
+INSERT INTO logs_temp
+SELECT "De resultaten van de hoogte kunstwerken berekeningen (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].HeightStructuresOutputEntity;
+INSERT INTO logs_temp
+SELECT "Alle (" || COUNT('x') || ") berekende resultaten voor alle hydraulische randvoorwaardenlocaties zijn verwijderd."
+ FROM [SOURCEPROJECT].HydraulicLocationOutputEntity;
+INSERT INTO logs_temp
+SELECT "De resultaten van de piping berekeningen (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].PipingCalculationOutputEntity LEFT JOIN [SOURCEPROJECT].PipingSemiProbabilisticOutputEntity;
+INSERT INTO logs_temp
+SELECT "De resultaten van de sterkte en stabiliteit puntconstructies kunstwerken berekeningen (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].StabilityPointStructuresOutputEntity;
+INSERT INTO logs_temp
+SELECT "De resultaten van de stabiliteit steenzetting berekeningen (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].StabilityStoneCoverWaveConditionsOutputEntity;
+INSERT INTO logs_temp
+SELECT "De resultaten van de golfklappen op asfaltbekleding berekeningen (" || COUNT('x') || " in totaal) zijn verwijderd."
+ FROM [SOURCEPROJECT].WaveImpactAsphaltCoverWaveConditionsOutputEntity;
+
+ATTACH DATABASE [{1}] AS LOGDATABASE;
+
+ CREATE TABLE IF NOT EXISTS [LOGDATABASE].'MigrationLogEntity'
+ (
+ 'MigrationLogEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
+ 'FromVersion' VARCHAR(20),
+ 'ToVersion' VARCHAR(20),
+ 'LogMessage' TEXT
+ );
+
+ INSERT INTO [LOGDATABASE].MigrationLogEntity([FromVersion], [ToVersion], [LogMessage])
+ SELECT "5", "17.1", logs_temp.[LogMessage] FROM logs_temp WHERE logs_temp.[LogMessage] != NULL;
+DETACH LOGDATABASE;
+
DETACH SOURCEPROJECT;
PRAGMA foreign_keys = ON;
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Migration.Core/RingtoetsSqLiteDatabaseFileMigrator.cs
===================================================================
diff -u -r9d68a734d8da9bfadd3bdd349ddb56fb70d461ec -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/src/Application.Ringtoets.Migration.Core/RingtoetsSqLiteDatabaseFileMigrator.cs (.../RingtoetsSqLiteDatabaseFileMigrator.cs) (revision 9d68a734d8da9bfadd3bdd349ddb56fb70d461ec)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration.Core/RingtoetsSqLiteDatabaseFileMigrator.cs (.../RingtoetsSqLiteDatabaseFileMigrator.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -46,6 +46,11 @@
scriptResource = typeof(Resources).Assembly;
}
+ ///
+ /// Gets or sets the path to the logging database.
+ ///
+ public string LogPath { private get; set; }
+
private static string GetStringOfStream(Stream stream)
{
using (var reader = new StreamReader(stream))
@@ -82,7 +87,7 @@
var upgradeQuery = GetStringOfStream(upgradeStream);
- return new RingtoetsUpgradeScript(fromVersion, toVersion, upgradeQuery);
+ return new RingtoetsUpgradeScript(fromVersion, toVersion, upgradeQuery, LogPath);
}
#endregion
Index: Application/Ringtoets/src/Application.Ringtoets.Migration.Core/RingtoetsUpgradeScript.cs
===================================================================
diff -u -r9d68a734d8da9bfadd3bdd349ddb56fb70d461ec -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/src/Application.Ringtoets.Migration.Core/RingtoetsUpgradeScript.cs (.../RingtoetsUpgradeScript.cs) (revision 9d68a734d8da9bfadd3bdd349ddb56fb70d461ec)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration.Core/RingtoetsUpgradeScript.cs (.../RingtoetsUpgradeScript.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -34,20 +34,22 @@
public class RingtoetsUpgradeScript : UpgradeScript
{
private readonly string upgradeQuery;
+ private readonly string logDatabaseLocation;
///
/// Creates a new instance of the class.
///
/// The source version was designed for.
/// The target version was designed for.
/// The SQL query to upgrade from to .
+ /// The location to the log database.
/// Thrown when:
///
/// - is not a valid Ringtoets database version,
/// - is not a valid Ringtoets database version,
/// - is empty, null, or consists out of only whitespace characters.
///
- public RingtoetsUpgradeScript(string fromVersion, string toVersion, string query)
+ public RingtoetsUpgradeScript(string fromVersion, string toVersion, string query, string logDatabaseLocation)
: base(fromVersion, toVersion)
{
if (string.IsNullOrWhiteSpace(query))
@@ -59,13 +61,14 @@
RingtoetsVersionHelper.ValidateVersion(toVersion);
upgradeQuery = query;
+ this.logDatabaseLocation = logDatabaseLocation;
}
protected override void PerformUpgrade(string sourceLocation, string targetLocation)
{
try
{
- var query = string.Format(upgradeQuery, sourceLocation);
+ string query = string.Format(upgradeQuery, sourceLocation, logDatabaseLocation);
using (var databaseFile = new RingtoetsDatabaseFile(targetLocation))
{
databaseFile.OpenDatabaseConnection();
Index: Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs
===================================================================
diff -u -rdd694bc76d6e75bcda83ff3f42edacf16451c58d -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs (.../RingtoetsProjectMigrator.cs) (revision dd694bc76d6e75bcda83ff3f42edacf16451c58d)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs (.../RingtoetsProjectMigrator.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -25,6 +25,7 @@
using Application.Ringtoets.Migration.Properties;
using Core.Common.Base.Storage;
using Core.Common.Gui;
+using Core.Common.Gui.Settings;
using Core.Common.Utils;
using log4net;
using Migration.Scripts.Data.Exceptions;
@@ -138,8 +139,8 @@
try
{
var versionedFile = new RingtoetsVersionedFile(sourceFilePath);
+ fileMigrator.LogPath = CreateInitializedDatabaseLogFile();
fileMigrator.Migrate(versionedFile, currentDatabaseVersion, targetLocation);
-
string message = string.Format(Resources.RingtoetsProjectMigrator_MigrateToTargetLocation_Outdated_projectfile_0_succesfully_updated_to_target_filepath_1_version_2_,
sourceFilePath, targetLocation, currentDatabaseVersion);
log.Info(message);
@@ -155,6 +156,13 @@
}
}
+ private static string CreateInitializedDatabaseLogFile()
+ {
+ string path = Path.Combine(SettingsHelper.Instance.GetLocalUserTemporaryDirectory(), "RingtoetsMigrationLog.sqlite");
+ IOUtils.CreateFileIfNotExists(path);
+ return path;
+ }
+
private static string GetSuggestedFileName(string sourceFilePath)
{
string fileName = Path.GetFileNameWithoutExtension(sourceFilePath);
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsSqLiteDatabaseFileMigratorTest.cs
===================================================================
diff -u -r0ec3500b27a04d8b0d942662301e03d10c277a02 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsSqLiteDatabaseFileMigratorTest.cs (.../RingtoetsSqLiteDatabaseFileMigratorTest.cs) (revision 0ec3500b27a04d8b0d942662301e03d10c277a02)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsSqLiteDatabaseFileMigratorTest.cs (.../RingtoetsSqLiteDatabaseFileMigratorTest.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -101,14 +101,14 @@
}
[Test]
- public void Migrate_ValidFiles_SavesFileAtNewLocation()
+ public void Migrate_ValidFilesWithoutLogFile_SavesFileAtNewLocation()
{
// Setup
const string newVersion = "17.1";
string sourceFilePath = RingtoetsProjectMigrationTestHelper.GetOutdatedSupportedProjectFilePath();
var fromVersionedFile = new RingtoetsVersionedFile(sourceFilePath);
- string targetFilePath = TestHelper.GetScratchPadPath(nameof(Migrate_ValidFiles_SavesFileAtNewLocation));
+ string targetFilePath = TestHelper.GetScratchPadPath(nameof(Migrate_ValidFilesWithoutLogFile_SavesFileAtNewLocation));
var migrator = new RingtoetsSqLiteDatabaseFileMigrator();
using (new FileDisposeHelper(targetFilePath))
@@ -123,6 +123,33 @@
}
[Test]
+ public void Migrate_ValidFilesWithLogFile_SavesFileAtNewLocation()
+ {
+ // Setup
+ const string newVersion = "17.1";
+ string sourceFilePath = RingtoetsProjectMigrationTestHelper.GetOutdatedSupportedProjectFilePath();
+ var fromVersionedFile = new RingtoetsVersionedFile(sourceFilePath);
+
+ string targetFilePath = TestHelper.GetScratchPadPath(nameof(Migrate_ValidFilesWithLogFile_SavesFileAtNewLocation));
+ string logFilePath = TestHelper.GetScratchPadPath(string.Concat(nameof(Migrate_ValidFilesWithLogFile_SavesFileAtNewLocation), ".log"));
+ var migrator = new RingtoetsSqLiteDatabaseFileMigrator
+ {
+ LogPath = logFilePath
+ };
+
+ using (new FileDisposeHelper(logFilePath))
+ using (new FileDisposeHelper(targetFilePath))
+ {
+ // Call
+ migrator.Migrate(fromVersionedFile, newVersion, targetFilePath);
+
+ // Assert
+ var toVersionedFile = new RingtoetsVersionedFile(targetFilePath);
+ Assert.AreEqual(newVersion, toVersionedFile.GetVersion());
+ }
+ }
+
+ [Test]
public void Migrate_TargetFileInUse_ThrowsCriticalDatabaseMigrationException()
{
// Setup
@@ -141,7 +168,7 @@
TestDelegate call = () => migrator.Migrate(fromVersionedFile, newVersion, targetFilePath);
// Assert
- CriticalMigrationException exception = Assert.Throws(call);
+ var exception = Assert.Throws(call);
StringAssert.StartsWith("Het gemigreerde projectbestand is aangemaakt op '", exception.Message);
StringAssert.EndsWith($"', maar er is een onverwachte fout opgetreden tijdens het verplaatsen naar '{targetFilePath}'.",
exception.Message);
@@ -162,7 +189,7 @@
TestDelegate call = () => migrator.Migrate(fromVersionedFile, newVersion, sourceFilePath);
// Assert
- CriticalMigrationException exception = Assert.Throws(call);
+ var exception = Assert.Throws(call);
Assert.AreEqual("Het doelprojectpad moet anders zijn dan het bronprojectpad.",
exception.Message);
}
@@ -189,7 +216,7 @@
TestDelegate call = () => migrator.Migrate(fromVersionedFile, newVersion, targetFilePath);
// Assert
- CriticalMigrationException exception = Assert.Throws(call);
+ var exception = Assert.Throws(call);
StringAssert.StartsWith("Het gemigreerde projectbestand is aangemaakt op '",
exception.Message);
StringAssert.EndsWith($"', maar er is een onverwachte fout opgetreden tijdens het verplaatsen naar '{targetFilePath}'.",
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsUpgradeScriptTest.cs
===================================================================
diff -u -r28ab332db2d96ad9e766f19677af1c00fc88a644 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsUpgradeScriptTest.cs (.../RingtoetsUpgradeScriptTest.cs) (revision 28ab332db2d96ad9e766f19677af1c00fc88a644)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Core.Test/RingtoetsUpgradeScriptTest.cs (.../RingtoetsUpgradeScriptTest.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -43,7 +43,7 @@
string toVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
// Call
- TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query);
+ TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query, string.Empty);
// Assert
string paramName = Assert.Throws(call).ParamName;
@@ -60,7 +60,7 @@
const string query = "Valid query";
// Call
- TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query);
+ TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query, string.Empty);
// Assert
string paramName = Assert.Throws(call).ParamName;
@@ -76,7 +76,7 @@
string toVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
// Call
- TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query);
+ TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query, string.Empty);
// Assert
string expectedMessage = $@"'{fromVersion}' is geen geldige Ringtoets versie.";
@@ -92,7 +92,7 @@
const string query = "Valid query";
// Call
- TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query);
+ TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query, string.Empty);
// Assert
string expectedMessage = $@"'{toVersion}' is geen geldige Ringtoets versie.";
@@ -110,7 +110,7 @@
string toVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
// Call
- TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query);
+ TestDelegate call = () => new RingtoetsUpgradeScript(fromVersion, toVersion, query, string.Empty);
// Assert
string paramName = Assert.Throws(call).ParamName;
@@ -126,7 +126,7 @@
const string query = ";";
// Call
- var upgradeScript = new RingtoetsUpgradeScript(fromVersion, toVersion, query);
+ var upgradeScript = new RingtoetsUpgradeScript(fromVersion, toVersion, query, string.Empty);
// Assert
Assert.IsInstanceOf(upgradeScript);
@@ -142,7 +142,7 @@
string toVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
string fileLocation = TestHelper.GetScratchPadPath(nameof(Upgrade_UpgradeFails_ThrowsCriticalMigrationException));
- var upgradeScript = new RingtoetsUpgradeScript(fromVersion, toVersion, "THIS WILL FAIL");
+ var upgradeScript = new RingtoetsUpgradeScript(fromVersion, toVersion, "THIS WILL FAIL", string.Empty);
using (new FileDisposeHelper(fileLocation))
{
@@ -162,10 +162,11 @@
{
// Setup
string filePath = TestHelper.GetScratchPadPath(nameof(Upgrade_ValidParameters_ExpectedProperties));
+ string logFilePath = TestHelper.GetScratchPadPath(string.Concat(nameof(Upgrade_ValidParameters_ExpectedProperties),".log"));
string fromVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
string toVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
- var upgradeScript = new RingtoetsUpgradeScript(fromVersion, toVersion, ";");
+ var upgradeScript = new RingtoetsUpgradeScript(fromVersion, toVersion, ";", logFilePath);
// Call
upgradeScript.Upgrade("c:\\file.ext", filePath);
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj
===================================================================
diff -u -r0ec3500b27a04d8b0d942662301e03d10c277a02 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj (.../Application.Ringtoets.Migration.Test.csproj) (revision 0ec3500b27a04d8b0d942662301e03d10c277a02)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/Application.Ringtoets.Migration.Test.csproj (.../Application.Ringtoets.Migration.Test.csproj) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -72,6 +72,10 @@
{30E4C2AE-719E-4D70-9FA9-668A9767FBFA}
Core.Common.Gui
+
+ {26214BD0-DAFB-4CFC-8EB2-80C5D53C859E}
+ Core.Common.Gui.TestUtil
+
{D749EE4C-CE50-4C17-BF01-9A953028C126}
Core.Common.TestUtil
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs
===================================================================
diff -u -ra5c5133ec23681679e77ff31b89e6410d366f247 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs (.../RingtoetsProjectMigratorTest.cs) (revision a5c5133ec23681679e77ff31b89e6410d366f247)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs (.../RingtoetsProjectMigratorTest.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -27,6 +27,7 @@
using Application.Ringtoets.Storage.TestUtil;
using Core.Common.Base.Storage;
using Core.Common.Gui;
+using Core.Common.Gui.TestUtil.Settings;
using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
@@ -117,7 +118,8 @@
// Assert
string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(
- call, "Bronprojectpad moet een geldig projectpad zijn.").ParamName;
+ call, "Bronprojectpad moet een geldig projectpad zijn.")
+ .ParamName;
Assert.AreEqual("filePath", paramName);
mocks.VerifyAll();
@@ -168,7 +170,7 @@
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
// Call
- MigrationRequired shouldMigrate = MigrationRequired.No;
+ var shouldMigrate = MigrationRequired.No;
Action call = () => shouldMigrate = migrator.ShouldMigrate(sourceFilePath);
// Assert
@@ -180,9 +182,7 @@
}
TestHelper.AssertLogMessagesWithLevelAreGenerated(call, expectedLogMessages, expectedLogMessages.Count);
- var expectedResult = confirmContinuation ?
- MigrationRequired.Yes :
- MigrationRequired.Aborted;
+ MigrationRequired expectedResult = confirmContinuation ? MigrationRequired.Yes : MigrationRequired.Aborted;
Assert.AreEqual(expectedResult, shouldMigrate);
mocks.VerifyAll();
@@ -244,7 +244,8 @@
// Assert
string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(
- call, "Bronprojectpad moet een geldig projectpad zijn.").ParamName;
+ call, "Bronprojectpad moet een geldig projectpad zijn.")
+ .ParamName;
Assert.AreEqual("originalFilePath", paramName);
mocks.VerifyAll();
@@ -301,14 +302,14 @@
mocks.ReplayAll();
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
- string targetFilePath = "arbitraryPath";
+ var targetFilePath = "arbitraryPath";
// Call
Action call = () => targetFilePath = migrator.DetermineMigrationLocation(validFilePath);
// Assert
Tuple expectedLogMessage = Tuple.Create($"Het migreren van het projectbestand '{validFilePath}' is geannuleerd.",
- LogLevelConstant.Warn);
+ LogLevelConstant.Warn);
TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedLogMessage, 1);
@@ -378,7 +379,8 @@
// Assert
string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(
- call, "Bronprojectpad moet een geldig projectpad zijn.").ParamName;
+ call, "Bronprojectpad moet een geldig projectpad zijn.")
+ .ParamName;
Assert.AreEqual("sourceFilePath", paramName);
mocks.VerifyAll();
@@ -402,7 +404,8 @@
// Assert
string paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(
- call, "Doelprojectpad moet een geldig projectpad zijn.").ParamName;
+ call, "Doelprojectpad moet een geldig projectpad zijn.")
+ .ParamName;
Assert.AreEqual("targetFilePath", paramName);
mocks.VerifyAll();
@@ -424,21 +427,32 @@
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
- bool migrationSuccessful = false;
+ var migrationSuccessful = false;
- // When
- Action call = () => migrationSuccessful = migrator.Migrate(sourceFilePath, targetFilePath);
+ using (new UseCustomSettingsHelper(new TestSettingsHelper
+ {
+ TempPath = TestHelper.GetScratchPadPath(testDirectory)
+ }))
+ {
+ // When
+ Action call = () => migrationSuccessful = migrator.Migrate(sourceFilePath, targetFilePath);
- // Then
- string expectedMessage = $"Het projectbestand '{sourceFilePath}' is succesvol gemigreerd naar '{targetFilePath}' (versie {currentDatabaseVersion}).";
- Tuple expectedLogMessageAndLevel = Tuple.Create(expectedMessage, LogLevelConstant.Info);
- TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedLogMessageAndLevel, 1);
+ // Then
+ string expectedMessage = $"Het projectbestand '{sourceFilePath}' is succesvol gemigreerd naar '{targetFilePath}' (versie {currentDatabaseVersion}).";
+ Tuple expectedLogMessageAndLevel = Tuple.Create(expectedMessage, LogLevelConstant.Info);
+ TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedLogMessageAndLevel, 1);
- Assert.IsTrue(migrationSuccessful);
+ Assert.IsTrue(migrationSuccessful);
- var toVersionedFile = new RingtoetsVersionedFile(targetFilePath);
- Assert.AreEqual(currentDatabaseVersion, toVersionedFile.GetVersion());
+ var toVersionedFile = new RingtoetsVersionedFile(targetFilePath);
+ Assert.AreEqual(currentDatabaseVersion, toVersionedFile.GetVersion());
+ }
+ string logPath = Path.Combine(TestHelper.GetScratchPadPath(), testDirectory, "RingtoetsMigrationLog.sqlite");
+
+ Assert.IsTrue(File.Exists(logPath));
+ File.Delete(logPath);
+
mocks.VerifyAll();
}
@@ -462,7 +476,7 @@
{
fileDisposeHelper.LockFiles();
- bool migrationSuccessful = true;
+ var migrationSuccessful = true;
// Call
Action call = () => migrationSuccessful = migrator.Migrate(sourceFilePath, targetFilePath);
@@ -495,7 +509,7 @@
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
- bool migrationSuccessful = true;
+ var migrationSuccessful = true;
// Call
Action call = () => migrationSuccessful = migrator.Migrate(sourceFilePath, targetFilePath);
@@ -524,7 +538,7 @@
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
- bool migrationSuccessful = true;
+ var migrationSuccessful = true;
// Call
Action call = () => migrationSuccessful = migrator.Migrate(sourceFilePath, sourceFilePath);
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r4b64e4ff0b3de19a9905981f3f82305009f1d8fc -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 4b64e4ff0b3de19a9905981f3f82305009f1d8fc)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -257,6 +257,10 @@
{E344867E-9AC9-44C8-88A5-8185681679A9}
Core.Common.IO
+
+ {26214BD0-DAFB-4CFC-8EB2-80C5D53C859E}
+ Core.Common.Gui.TestUtil
+
{D749EE4C-CE50-4C17-BF01-9A953028C126}
Core.Common.TestUtil
Index: Core/Common/src/Core.Common.Gui/Settings/ISettingsHelper.cs
===================================================================
diff -u -r1de256e81f3fa2c070810593152e87ad6affab97 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Core/Common/src/Core.Common.Gui/Settings/ISettingsHelper.cs (.../ISettingsHelper.cs) (revision 1de256e81f3fa2c070810593152e87ad6affab97)
+++ Core/Common/src/Core.Common.Gui/Settings/ISettingsHelper.cs (.../ISettingsHelper.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -49,5 +49,11 @@
/// The sub path to use after the common documents folder (if any).
/// Directory path where the common documents can be found.
string GetCommonDocumentsDirectory(params string[] subPath);
+
+ ///
+ /// Gets the directory of the current user's temporary folder.
+ ///
+ /// Directory path of the current user's temporary folder.
+ string GetLocalUserTemporaryDirectory();
}
}
\ No newline at end of file
Index: Core/Common/src/Core.Common.Gui/Settings/SettingsHelper.cs
===================================================================
diff -u -r1de256e81f3fa2c070810593152e87ad6affab97 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Core/Common/src/Core.Common.Gui/Settings/SettingsHelper.cs (.../SettingsHelper.cs) (revision 1de256e81f3fa2c070810593152e87ad6affab97)
+++ Core/Common/src/Core.Common.Gui/Settings/SettingsHelper.cs (.../SettingsHelper.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -76,6 +76,11 @@
return GetFullPath(commonDocumentsPath, subPath);
}
+ public string GetLocalUserTemporaryDirectory()
+ {
+ return Path.GetTempPath();
+ }
+
private static string GetFullPath(string rootPath, string[] subPath)
{
var directorypath = new List
Index: Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs
===================================================================
diff -u -r1de256e81f3fa2c070810593152e87ad6affab97 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs (.../SettingsHelperTest.cs) (revision 1de256e81f3fa2c070810593152e87ad6affab97)
+++ Core/Common/test/Core.Common.Gui.Test/Settings/SettingsHelperTest.cs (.../SettingsHelperTest.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -118,5 +118,16 @@
string testDataPath = Path.Combine(userSettingsDirectory, subFolder, subSubFolder);
Assert.AreEqual(testDataPath, directory);
}
+
+ [Test]
+ public void GetLocalUserTemporaryDirectory_ReturnsTempPath()
+ {
+ // Call
+ string pathFromSettings = SettingsHelper.Instance.GetLocalUserTemporaryDirectory();
+
+ // Assert
+ string tempPath = Path.GetTempPath();
+ Assert.AreEqual(tempPath, pathFromSettings);
+ }
}
}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Gui.TestUtil.Test/Settings/TestSettingsHelperTest.cs
===================================================================
diff -u -r1de256e81f3fa2c070810593152e87ad6affab97 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Core/Common/test/Core.Common.Gui.TestUtil.Test/Settings/TestSettingsHelperTest.cs (.../TestSettingsHelperTest.cs) (revision 1de256e81f3fa2c070810593152e87ad6affab97)
+++ Core/Common/test/Core.Common.Gui.TestUtil.Test/Settings/TestSettingsHelperTest.cs (.../TestSettingsHelperTest.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -163,5 +163,36 @@
// Assert
Assert.AreEqual(expectedApplicationVersion, applicationVersion);
}
+
+ [Test]
+ public void GetLocalUserTemporaryDirectory_WithoutExpectedSet_ReturnsExpectedTempPath()
+ {
+ // Setup
+ var settingsHelper = new TestSettingsHelper();
+
+ // Call
+ string pathFromSettings = settingsHelper.GetLocalUserTemporaryDirectory();
+
+ // Assert
+ string tempPath = TestHelper.GetScratchPadPath();
+ Assert.AreEqual(tempPath, pathFromSettings);
+ }
+
+ [Test]
+ public void GetLocalUserTemporaryDirectory_WithExpectedSet_ReturnsExpectedPath()
+ {
+ // Setup
+ const string folder = "folder";
+ var settingsHelper = new TestSettingsHelper
+ {
+ TempPath = folder
+ };
+
+ // Call
+ string pathFromSettings = settingsHelper.GetLocalUserTemporaryDirectory();
+
+ // Assert
+ Assert.AreEqual(folder, pathFromSettings);
+ }
}
}
\ No newline at end of file
Index: Core/Common/test/Core.Common.Gui.TestUtil/Settings/TestSettingsHelper.cs
===================================================================
diff -u -r1de256e81f3fa2c070810593152e87ad6affab97 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Core/Common/test/Core.Common.Gui.TestUtil/Settings/TestSettingsHelper.cs (.../TestSettingsHelper.cs) (revision 1de256e81f3fa2c070810593152e87ad6affab97)
+++ Core/Common/test/Core.Common.Gui.TestUtil/Settings/TestSettingsHelper.cs (.../TestSettingsHelper.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -40,6 +40,7 @@
{
ApplicationLocalUserSettingsDirectory = TestHelper.GetScratchPadPath();
CommonDocumentsDirectory = TestHelper.GetScratchPadPath();
+ TempPath = TestHelper.GetScratchPadPath();
ApplicationName = string.Empty;
ApplicationVersion = string.Empty;
}
@@ -84,6 +85,16 @@
return GetFullPath(CommonDocumentsDirectory, subPath);
}
+ ///
+ /// Gets or sets the directory to use in .
+ ///
+ public string TempPath { private get; set; }
+
+ public string GetLocalUserTemporaryDirectory()
+ {
+ return TempPath;
+ }
+
private static string GetFullPath(string rootPath, string[] subPath)
{
var directorypath = new List
Index: Migration/Scripts/src/Migration.Scripts.Data/UpgradeScript.cs
===================================================================
diff -u -r85ff91388190d242a5bd74e110b2c5f8b177bff3 -r6e8799128485ac9ff7eb5a8ddac37ce805ba6642
--- Migration/Scripts/src/Migration.Scripts.Data/UpgradeScript.cs (.../UpgradeScript.cs) (revision 85ff91388190d242a5bd74e110b2c5f8b177bff3)
+++ Migration/Scripts/src/Migration.Scripts.Data/UpgradeScript.cs (.../UpgradeScript.cs) (revision 6e8799128485ac9ff7eb5a8ddac37ce805ba6642)
@@ -30,8 +30,8 @@
///
public abstract class UpgradeScript
{
- private readonly string fromVersion;
- private readonly string toVersion;
+ protected readonly string fromVersion;
+ protected readonly string toVersion;
///
/// Creates a new instance of the class.