Index: Application/Ringtoets/src/Application.Ringtoets.Migration/Properties/Resources.Designer.cs
===================================================================
diff -u -rb6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6 -r5af1b7c1e22ec02a2a7395e2de7482cc91681a4e
--- Application/Ringtoets/src/Application.Ringtoets.Migration/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5af1b7c1e22ec02a2a7395e2de7482cc91681a4e)
@@ -110,12 +110,12 @@
}
///
- /// Looks up a localized string similar to Het project dat u wilt openen is opgeslagen met een oudere versie van Ringtoets. Wilt u het bestand converteren naar uw huidige Ringtoetsversie?.
+ /// Looks up a localized string similar to Het project dat u wilt openen is opgeslagen in het formaat van een eerdere versie van Ringtoets. Weet u zeker dat u het bestand wilt migreren naar het formaat van uw huidige Ringtoetsversie ({0})?.
///
- internal static string RingtoetsProjectMigrator_Migrate_Outdated_project_file_update_to_current_version_inquire {
+ internal static string RingtoetsProjectMigrator_Migrate_Outdated_project_file_update_to_current_version_0_inquire {
get {
return ResourceManager.GetString("RingtoetsProjectMigrator_Migrate_Outdated_project_file_update_to_current_version_" +
- "inquire", resourceCulture);
+ "0_inquire", resourceCulture);
}
}
Index: Application/Ringtoets/src/Application.Ringtoets.Migration/Properties/Resources.resx
===================================================================
diff -u -rb6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6 -r5af1b7c1e22ec02a2a7395e2de7482cc91681a4e
--- Application/Ringtoets/src/Application.Ringtoets.Migration/Properties/Resources.resx (.../Resources.resx) (revision b6d487f36edb7b6ca133a0e26d1ab7bda4c6bab6)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration/Properties/Resources.resx (.../Resources.resx) (revision 5af1b7c1e22ec02a2a7395e2de7482cc91681a4e)
@@ -117,8 +117,8 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- Het project dat u wilt openen is opgeslagen met een oudere versie van Ringtoets. Wilt u het bestand converteren naar uw huidige Ringtoetsversie?
+
+ Het project dat u wilt openen is opgeslagen in het formaat van een eerdere versie van Ringtoets. Weet u zeker dat u het bestand wilt migreren naar het formaat van uw huidige Ringtoetsversie ({0})?
rtd
Index: Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs
===================================================================
diff -u -r7963bd77ea5540754906c7e994f2687e33a89dde -r5af1b7c1e22ec02a2a7395e2de7482cc91681a4e
--- Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs (.../RingtoetsProjectMigrator.cs) (revision 7963bd77ea5540754906c7e994f2687e33a89dde)
+++ Application/Ringtoets/src/Application.Ringtoets.Migration/RingtoetsProjectMigrator.cs (.../RingtoetsProjectMigrator.cs) (revision 5af1b7c1e22ec02a2a7395e2de7482cc91681a4e)
@@ -38,7 +38,7 @@
///
public class RingtoetsProjectMigrator : IMigrateProject
{
- private static readonly string currentProjectVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
+ private static readonly string currentDatabaseVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
private readonly ILog log = LogManager.GetLogger(typeof(RingtoetsProjectMigrator));
private readonly RingtoetsSqLiteDatabaseFileMigrator fileMigrator;
@@ -74,7 +74,7 @@
var versionedFile = new RingtoetsVersionedFile(filePath);
string version = versionedFile.GetVersion();
- if (version.Equals(currentProjectVersion))
+ if (version.Equals(currentDatabaseVersion))
{
return false;
}
@@ -83,7 +83,7 @@
if (!isVersionSupported)
{
string errorMessage = string.Format(MigrationCoreStorageResources.Migrate_From_Version_0_To_Version_1_Not_Supported,
- version, currentProjectVersion);
+ version, currentDatabaseVersion);
log.Error(errorMessage);
}
return isVersionSupported;
@@ -98,7 +98,9 @@
ValidateProjectPath(filePath);
- string query = Resources.RingtoetsProjectMigrator_Migrate_Outdated_project_file_update_to_current_version_inquire;
+ string query = string.Format(
+ Resources.RingtoetsProjectMigrator_Migrate_Outdated_project_file_update_to_current_version_0_inquire,
+ currentDatabaseVersion);
if (inquiryHelper.InquireContinuation(query))
{
string suggestedFileName = GetSuggestedFileName(filePath);
@@ -119,10 +121,10 @@
try
{
var versionedFile = new RingtoetsVersionedFile(sourceFilePath);
- fileMigrator.Migrate(versionedFile, currentProjectVersion, targetLocation);
+ 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, currentProjectVersion);
+ sourceFilePath, targetLocation, currentDatabaseVersion);
log.Info(message);
return targetLocation;
@@ -139,7 +141,7 @@
private static string GetSuggestedFileName(string sourceFilePath)
{
string fileName = Path.GetFileNameWithoutExtension(sourceFilePath);
- string versionSuffix = currentProjectVersion.Replace(".", "-");
+ string versionSuffix = currentDatabaseVersion.Replace(".", "-");
string suggestedFileName = $"{fileName}_{versionSuffix}";
return suggestedFileName;
Index: Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs
===================================================================
diff -u -r7963bd77ea5540754906c7e994f2687e33a89dde -r5af1b7c1e22ec02a2a7395e2de7482cc91681a4e
--- Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs (.../RingtoetsProjectMigratorTest.cs) (revision 7963bd77ea5540754906c7e994f2687e33a89dde)
+++ Application/Ringtoets/test/Application.Ringtoets.Migration.Test/RingtoetsProjectMigratorTest.cs (.../RingtoetsProjectMigratorTest.cs) (revision 5af1b7c1e22ec02a2a7395e2de7482cc91681a4e)
@@ -36,7 +36,7 @@
[TestFixture]
public class RingtoetsProjectMigratorTest : NUnitFormTest
{
- private const string testDirectory = nameof(RingtoetsProjectMigratorTest);
+ private readonly string currentDatabaseVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
[Test]
public void Constructor_InquiryHelperNull_ThrowsArgumentNullException()
@@ -122,15 +122,13 @@
string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, file);
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
-
- var expectedVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
bool shouldMigrate = true;
// Call
Action call = () => shouldMigrate = migrator.ShouldMigrate(sourceFilePath);
// Assert
- string expectedMessage = $"Het migreren van een projectbestand met versie '{fileVersion}' naar versie '{expectedVersion}' is niet ondersteund.";
+ string expectedMessage = $"Het migreren van een projectbestand met versie '{fileVersion}' naar versie '{currentDatabaseVersion}' is niet ondersteund.";
TestHelper.AssertLogMessageIsGenerated(call, expectedMessage);
Assert.IsFalse(shouldMigrate);
@@ -172,13 +170,12 @@
var versionedFile = new RingtoetsVersionedFile(sourceFilePath);
string testProjectVersion = versionedFile.GetVersion();
- string currentVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
// Pre-condition
- string assertionMessage = $"Database version {testProjectVersion} of the testproject must match with the current database version {currentVersion}.";
- Assert.AreEqual(currentVersion, testProjectVersion, assertionMessage);
+ string assertionMessage = $"Database version {testProjectVersion} of the testproject must match with the current database version {currentDatabaseVersion}.";
+ Assert.AreEqual(currentDatabaseVersion, testProjectVersion, assertionMessage);
// Call
bool shouldMigrate = migrator.ShouldMigrate(sourceFilePath);
@@ -230,22 +227,50 @@
}
[Test]
+ [TestCase(true)]
+ [TestCase(false)]
+ public void Migrate_Always_DisplaysInquiryMessage(bool confirmMigration)
+ {
+ // Setup
+ string sourceFilePath = "Arbitrary/RingtoetsFile";
+
+ var mocks = new MockRepository();
+ var inquiryHelper = mocks.StrictMock();
+
+ string message = "Het project dat u wilt openen is opgeslagen in het formaat van een eerdere " +
+ "versie van Ringtoets. Weet u zeker dat u het bestand wilt migreren naar het formaat van" +
+ $" uw huidige Ringtoetsversie ({currentDatabaseVersion})?";
+ inquiryHelper.Expect(helper => helper.InquireContinuation(message)).Return(confirmMigration);
+ inquiryHelper.Stub(helper => helper.GetTargetFileLocation(null, null))
+ .IgnoreArguments()
+ .Return(null);
+ mocks.ReplayAll();
+
+ var migrator = new RingtoetsProjectMigrator(inquiryHelper);
+
+ // Call
+ migrator.Migrate(sourceFilePath);
+
+ // Assert
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void Migrate_Always_ReturnsSuggestedFileNameAndFileFilter()
{
// Setup
- string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, "FullTestProject164.rtd");
- string expectedVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
+ const string projectName = "FullTestProject164";
+ string sourceFilePath = $"Some/Path/{projectName}.rtd";
var mocks = new MockRepository();
var inquiryHelper = mocks.StrictMock();
- const string message = "Het project dat u wilt openen is opgeslagen met een oudere " +
- "versie van Ringtoets. Wilt u het bestand converteren naar uw " +
- "huidige Ringtoetsversie?";
- inquiryHelper.Expect(helper => helper.InquireContinuation(message)).Return(true);
+ inquiryHelper.Expect(helper => helper.InquireContinuation(null))
+ .IgnoreArguments()
+ .Return(true);
- string versionSuffix = expectedVersion.Replace(".", "-");
- string expectedSuggestedFileName = $"FullTestProject164_{versionSuffix}";
+ string versionSuffix = currentDatabaseVersion.Replace(".", "-");
+ string expectedSuggestedFileName = $"{projectName}_{versionSuffix}";
inquiryHelper.Expect(helper => helper.GetTargetFileLocation(new FileFilterGenerator("rtd", "Ringtoets project"),
expectedSuggestedFileName))
.Return(null);
@@ -266,36 +291,37 @@
// Given
string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, "FullTestProject164.rtd");
- string targetFile = $"{nameof(GivenMigratorAndSupportedFile_WhenContinuedAfterInquiryAndValidTargetLocationGiven_ThenFileSuccessFullyMigrates)}.rtd";
- string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), testDirectory, targetFile);
- string expectedVersion = RingtoetsVersionHelper.GetCurrentDatabaseVersion();
+ string targetFile = $"{nameof(RingtoetsProjectMigratorTest)}." +
+ $"{nameof(GivenMigratorAndSupportedFile_WhenContinuedAfterInquiryAndValidTargetLocationGiven_ThenFileSuccessFullyMigrates)}.rtd";
+ string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), targetFile);
var mocks = new MockRepository();
var inquiryHelper = mocks.StrictMock();
- const string message = "Het project dat u wilt openen is opgeslagen met een oudere " +
- "versie van Ringtoets. Wilt u het bestand converteren naar uw " +
- "huidige Ringtoetsversie?";
- inquiryHelper.Expect(helper => helper.InquireContinuation(message)).Return(true);
- inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null)).IgnoreArguments().Return(targetFilePath);
+ inquiryHelper.Expect(helper => helper.InquireContinuation(null))
+ .IgnoreArguments()
+ .Return(true);
+ inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null))
+ .IgnoreArguments()
+ .Return(targetFilePath);
mocks.ReplayAll();
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
- using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), testDirectory))
+ using (new FileDisposeHelper(targetFilePath))
{
string actualTargetFilePath = null;
// When
Action call = () => actualTargetFilePath = migrator.Migrate(sourceFilePath);
// Then
- string expectedMessage = $"Het projectbestand '{sourceFilePath}' is succesvol gemigreerd naar '{targetFilePath}' (versie {expectedVersion}).";
+ string expectedMessage = $"Het projectbestand '{sourceFilePath}' is succesvol gemigreerd naar '{targetFilePath}' (versie {currentDatabaseVersion}).";
TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
Assert.AreEqual(targetFilePath, actualTargetFilePath);
var toVersionedFile = new RingtoetsVersionedFile(targetFilePath);
- Assert.AreEqual(expectedVersion, toVersionedFile.GetVersion());
+ Assert.AreEqual(currentDatabaseVersion, toVersionedFile.GetVersion());
}
mocks.VerifyAll();
@@ -310,10 +336,9 @@
var mocks = new MockRepository();
var inquiryHelper = mocks.StrictMock();
- const string message = "Het project dat u wilt openen is opgeslagen met een oudere " +
- "versie van Ringtoets. Wilt u het bestand converteren naar uw " +
- "huidige Ringtoetsversie?";
- inquiryHelper.Expect(helper => helper.InquireContinuation(message)).Return(false);
+ inquiryHelper.Expect(helper => helper.InquireContinuation(null))
+ .IgnoreArguments()
+ .Return(false);
mocks.ReplayAll();
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
@@ -339,11 +364,12 @@
var mocks = new MockRepository();
var inquiryHelper = mocks.StrictMock();
- const string message = "Het project dat u wilt openen is opgeslagen met een oudere " +
- "versie van Ringtoets. Wilt u het bestand converteren naar uw " +
- "huidige Ringtoetsversie?";
- inquiryHelper.Expect(helper => helper.InquireContinuation(message)).Return(true);
- inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null)).IgnoreArguments().Return(null);
+ inquiryHelper.Expect(helper => helper.InquireContinuation(null))
+ .IgnoreArguments()
+ .Return(true);
+ inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null))
+ .IgnoreArguments()
+ .Return(null);
mocks.ReplayAll();
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
@@ -361,26 +387,72 @@
}
[Test]
+ public void Migrate_UnableToSaveAtTargetFilePath_MigrationFailsAndLogsError()
+ {
+ // Setup
+ string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, "FullTestProject164.rtd");
+ string targetFilePath = $"{nameof(RingtoetsProjectMigratorTest)}." +
+ $"{nameof(Migrate_UnableToSaveAtTargetFilePath_MigrationFailsAndLogsError)}.rtd";
+
+ var mocks = new MockRepository();
+ var inquiryHelper = mocks.StrictMock();
+
+ inquiryHelper.Expect(helper => helper.InquireContinuation(null))
+ .IgnoreArguments()
+ .Return(true);
+ inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null))
+ .IgnoreArguments()
+ .Return(sourceFilePath);
+ mocks.ReplayAll();
+
+ var migrator = new RingtoetsProjectMigrator(inquiryHelper);
+
+ // Assert
+ using (var fileDisposeHelper = new FileDisposeHelper(targetFilePath))
+ {
+ fileDisposeHelper.LockFiles();
+
+ string actualTargetFilePath = string.Empty;
+
+ // Call
+ Action call = () => actualTargetFilePath = migrator.Migrate(sourceFilePath);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ string[] msgs = messages.ToArray();
+ Assert.AreEqual(1, msgs.Length);
+ StringAssert.StartsWith(string.Format("Het migreren van het projectbestand '{0}' is mislukt: ", sourceFilePath), msgs[0]);
+ });
+ Assert.IsNull(actualTargetFilePath);
+ }
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
public void Migrate_UnsupportedSourceFileVersion_MigrationFailsAndLogsError()
{
// Setup
string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, "UnsupportedVersion8.rtd");
- string targetFile = $"{nameof(Migrate_UnsupportedSourceFileVersion_MigrationFailsAndLogsError)}";
- string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), testDirectory, targetFile);
+ string targetFile = $"{nameof(RingtoetsProjectMigratorTest)}." +
+ $"{nameof(Migrate_UnsupportedSourceFileVersion_MigrationFailsAndLogsError)}";
+ string targetFilePath = Path.Combine(TestHelper.GetScratchPadPath(), targetFile);
var mocks = new MockRepository();
var inquiryHelper = mocks.StrictMock();
- const string message = "Het project dat u wilt openen is opgeslagen met een oudere " +
- "versie van Ringtoets. Wilt u het bestand converteren naar uw " +
- "huidige Ringtoetsversie?";
- inquiryHelper.Expect(helper => helper.InquireContinuation(message)).Return(true);
- inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null)).IgnoreArguments().Return(targetFilePath);
+ inquiryHelper.Expect(helper => helper.InquireContinuation(null))
+ .IgnoreArguments()
+ .Return(true);
+ inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null))
+ .IgnoreArguments()
+ .Return(targetFilePath);
mocks.ReplayAll();
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
- using (new DirectoryDisposeHelper(TestHelper.GetScratchPadPath(), testDirectory))
+ using (new FileDisposeHelper(targetFilePath))
{
string actualTargetFilePath = string.Empty;
@@ -403,27 +475,28 @@
[Test]
public void Migrate_TargetFileSameAsSourceFile_MigrationFailsAndLogsError()
{
- // Given
+ // Setup
string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Application.Ringtoets.Migration, "FullTestProject164.rtd");
var mocks = new MockRepository();
var inquiryHelper = mocks.StrictMock();
- const string message = "Het project dat u wilt openen is opgeslagen met een oudere " +
- "versie van Ringtoets. Wilt u het bestand converteren naar uw " +
- "huidige Ringtoetsversie?";
- inquiryHelper.Expect(helper => helper.InquireContinuation(message)).Return(true);
- inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null)).IgnoreArguments().Return(sourceFilePath);
+ inquiryHelper.Expect(helper => helper.InquireContinuation(null))
+ .IgnoreArguments()
+ .Return(true);
+ inquiryHelper.Expect(helper => helper.GetTargetFileLocation(null, null))
+ .IgnoreArguments()
+ .Return(sourceFilePath);
mocks.ReplayAll();
var migrator = new RingtoetsProjectMigrator(inquiryHelper);
string actualTargetFilePath = string.Empty;
- // When
+ // Call
Action call = () => actualTargetFilePath = migrator.Migrate(sourceFilePath);
- // Then
+ // Assert
TestHelper.AssertLogMessages(call, messages =>
{
string[] msgs = messages.ToArray();
Index: Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs
===================================================================
diff -u -r4e4518eddf542f7f0d74b3f9125ee8326597ddda -r5af1b7c1e22ec02a2a7395e2de7482cc91681a4e
--- Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs (.../IMigrateProject.cs) (revision 4e4518eddf542f7f0d74b3f9125ee8326597ddda)
+++ Core/Common/src/Core.Common.Base/Storage/IMigrateProject.cs (.../IMigrateProject.cs) (revision 5af1b7c1e22ec02a2a7395e2de7482cc91681a4e)
@@ -49,7 +49,7 @@
/// The filepath of the project which needs to be migrated.
/// A filepath to the updated project file. null if:
///
- /// - The user cancelled.
+ /// - The user did not provide a target filepath.
/// - The migration failed.
///
/// Thrown when is null.