Index: Riskeer/Migration/test/Riskeer.Migration.Core.Test/ProjectFileMigratorTest.cs =================================================================== diff -u -rdabcb057747ff6edfd9e1735cae761c45ae4c004 -r10b69794656806369ef41511ccdeb2914207d221 --- Riskeer/Migration/test/Riskeer.Migration.Core.Test/ProjectFileMigratorTest.cs (.../ProjectFileMigratorTest.cs) (revision dabcb057747ff6edfd9e1735cae761c45ae4c004) +++ Riskeer/Migration/test/Riskeer.Migration.Core.Test/ProjectFileMigratorTest.cs (.../ProjectFileMigratorTest.cs) (revision 10b69794656806369ef41511ccdeb2914207d221) @@ -76,7 +76,7 @@ [Test] [TestCase("16.4")] [TestCase("20.1")] - [TestCase("21.1")] + [TestCase("21.2")] public void IsVersionSupported_UnsupportedVersion_ReturnsFalse(string fromVersion) { // Setup Index: Riskeer/Migration/test/Riskeer.Migration.Core.Test/test-data/Empty valid Release 21.1.risk =================================================================== diff -u Binary files differ Index: Riskeer/Migration/test/Riskeer.Migration.Core.Test/test-data/MigrationTestProject212.risk =================================================================== diff -u Binary files differ Index: Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationIntegrationTest.cs =================================================================== diff -u -rdabcb057747ff6edfd9e1735cae761c45ae4c004 -r10b69794656806369ef41511ccdeb2914207d221 --- Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationIntegrationTest.cs (.../MigrationIntegrationTest.cs) (revision dabcb057747ff6edfd9e1735cae761c45ae4c004) +++ Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationIntegrationTest.cs (.../MigrationIntegrationTest.cs) (revision 10b69794656806369ef41511ccdeb2914207d221) @@ -102,7 +102,7 @@ using (var reader = new MigrationLogDatabaseReader(logFilePath)) { ReadOnlyCollection messages = reader.GetMigrationLogMessages(); - Assert.AreEqual(12, messages.Count); + Assert.AreEqual(14, messages.Count); MigrationLogTestHelper.AssertMigrationLogMessageEqual( new MigrationLogMessage("5", "17.1", "Gevolgen van de migratie van versie 16.4 naar versie 17.1:"), messages[0]); @@ -134,11 +134,17 @@ new MigrationLogMessage("18.1", "19.1", "* Geen aanpassingen."), messages[9]); MigrationLogTestHelper.AssertMigrationLogMessageEqual( - new MigrationLogMessage("19.1", $"{latestVersion}", $"Gevolgen van de migratie van versie 19.1 naar versie {latestVersion}:"), + new MigrationLogMessage("19.1", "21.1", "Gevolgen van de migratie van versie 19.1 naar versie 21.1:"), messages[10]); MigrationLogTestHelper.AssertMigrationLogMessageEqual( - new MigrationLogMessage("19.1", $"{latestVersion}", "* Geen aanpassingen."), + new MigrationLogMessage("19.1", "21.1", "* Geen aanpassingen."), messages[11]); + MigrationLogTestHelper.AssertMigrationLogMessageEqual( + new MigrationLogMessage("21.1", $"{latestVersion}", $"Gevolgen van de migratie van versie 21.1 naar versie {latestVersion}:"), + messages[12]); + MigrationLogTestHelper.AssertMigrationLogMessageEqual( + new MigrationLogMessage("21.1", $"{latestVersion}", "* Geen aanpassingen."), + messages[13]); } } } @@ -160,6 +166,7 @@ yield return new FileToMigrate("Empty valid Release 17.3.rtd", "18.1"); yield return new FileToMigrate("Empty valid Release 18.1.rtd", "19.1"); yield return new FileToMigrate("Empty valid Release 19.1.risk", "21.1"); + yield return new FileToMigrate("Empty valid Release 21.1.risk", "21.2"); } private class FileToMigrate Index: Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo212IntegrationTest.cs =================================================================== diff -u --- Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo212IntegrationTest.cs (revision 0) +++ Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo212IntegrationTest.cs (revision 10b69794656806369ef41511ccdeb2914207d221) @@ -0,0 +1,219 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Collections.ObjectModel; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.Migration.Core; +using Riskeer.Migration.Core.TestUtil; + +namespace Riskeer.Migration.Integration.Test +{ + public class MigrationTo212IntegrationTest + { + private const string newVersion = "21.2"; + + [Test] + public void Given172Project_WhenUpgradedTo173_ThenProjectAsExpected() + { + // Given + string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Migration.Core, + "MigrationTestProject211.risk"); + var fromVersionedFile = new ProjectVersionedFile(sourceFilePath); + + string targetFilePath = TestHelper.GetScratchPadPath(nameof(Given172Project_WhenUpgradedTo173_ThenProjectAsExpected)); + string logFilePath = TestHelper.GetScratchPadPath(string.Concat(nameof(Given172Project_WhenUpgradedTo173_ThenProjectAsExpected), ".log")); + var migrator = new ProjectFileMigrator + { + LogPath = logFilePath + }; + + using (new FileDisposeHelper(logFilePath)) + using (new FileDisposeHelper(targetFilePath)) + { + // When + migrator.Migrate(fromVersionedFile, newVersion, targetFilePath); + + // Then + using (var reader = new MigratedDatabaseReader(targetFilePath)) + { + AssertTablesContentMigrated(reader, sourceFilePath); + + AssertVersions(reader); + AssertDatabase(reader); + } + + AssertLogDatabase(logFilePath); + } + } + + private static void AssertTablesContentMigrated(MigratedDatabaseReader reader, string sourceFilePath) + { + string[] tables = + { + "AssessmentSectionEntity", + "BackgroundDataEntity", + "BackgroundDataMetaEntity", + "CalculationGroupEntity", + "ClosingStructureEntity", + "ClosingStructuresCalculationEntity", + "ClosingStructuresFailureMechanismMetaEntity", + "ClosingStructuresOutputEntity", + "ClosingStructuresSectionResultEntity", + "DikeProfileEntity", + "DuneErosionFailureMechanismMetaEntity", + "DuneErosionSectionResultEntity", + "DuneLocationCalculationCollectionEntity", + "DuneLocationCalculationEntity", + "DuneLocationCalculationOutputEntity", + "DuneLocationEntity", + "FailureMechanismEntity", + "FailureMechanismSectionEntity", + "FaultTreeIllustrationPointEntity", + "FaultTreeIllustrationPointStochastEntity", + "FaultTreeSubmechanismIllustrationPointEntity", + "ForeshoreProfileEntity", + "GeneralResultFaultTreeIllustrationPointEntity", + "GeneralResultFaultTreeIllustrationPointStochastEntity", + "GeneralResultSubMechanismIllustrationPointEntity", + "GeneralResultSubMechanismIllustrationPointStochastEntity", + "GrassCoverErosionInwardsCalculationEntity", + "GrassCoverErosionInwardsDikeHeightOutputEntity", + "GrassCoverErosionInwardsFailureMechanismMetaEntity", + "GrassCoverErosionInwardsOutputEntity", + "GrassCoverErosionInwardsOvertoppingRateOutputEntity", + "GrassCoverErosionInwardsSectionResultEntity", + "GrassCoverErosionOutwardsFailureMechanismMetaEntity", + "GrassCoverErosionOutwardsSectionResultEntity", + "GrassCoverErosionOutwardsWaveConditionsCalculationEntity", + "GrassCoverErosionOutwardsWaveConditionsOutputEntity", + "GrassCoverSlipOffInwardsSectionResultEntity", + "GrassCoverSlipOffOutwardsSectionResultEntity", + "HeightStructureEntity", + "HeightStructuresCalculationEntity", + "HeightStructuresFailureMechanismMetaEntity", + "HeightStructuresOutputEntity", + "HeightStructuresSectionResultEntity", + "HydraulicBoundaryDatabaseEntity", + "HydraulicLocationCalculationCollectionEntity", + "HydraulicLocationCalculationEntity", + "HydraulicLocationEntity", + "HydraulicLocationOutputEntity", + "IllustrationPointResultEntity", + "MacroStabilityInwardsCalculationEntity", + "MacroStabilityInwardsCalculationOutputEntity", + "MacroStabilityInwardsCharacteristicPointEntity", + "MacroStabilityInwardsFailureMechanismMetaEntity", + "MacroStabilityInwardsPreconsolidationStressEntity", + "MacroStabilityInwardsSectionResultEntity", + "MacroStabilityInwardsSoilLayerOneDEntity", + "MacroStabilityInwardsSoilLayerTwoDEntity", + "MacroStabilityInwardsSoilProfileOneDEntity", + "MacroStabilityInwardsSoilProfileTwoDEntity", + "MacroStabilityInwardsSoilProfileTwoDSoilLayerTwoDEntity", + "MacroStabilityInwardsStochasticSoilProfileEntity", + "MacroStabilityOutwardsFailureMechanismMetaEntity", + "MacroStabilityOutwardsSectionResultEntity", + "MicrostabilitySectionResultEntity", + "PipingCharacteristicPointEntity", + "PipingFailureMechanismMetaEntity", + "PipingSectionResultEntity", + "PipingSoilLayerEntity", + "PipingSoilProfileEntity", + "PipingStochasticSoilProfileEntity", + "PipingStructureFailureMechanismMetaEntity", + "PipingStructureSectionResultEntity", + "ProbabilisticPipingCalculationEntity", + "ProbabilisticPipingCalculationOutputEntity", + "ProjectEntity", + "SemiProbabilisticPipingCalculationEntity", + "SemiProbabilisticPipingCalculationOutputEntity", + "StabilityPointStructureEntity", + "StabilityPointStructuresCalculationEntity", + "StabilityPointStructuresFailureMechanismMetaEntity", + "StabilityPointStructuresOutputEntity", + "StabilityPointStructuresSectionResultEntity", + "StabilityStoneCoverFailureMechanismMetaEntity", + "StabilityStoneCoverSectionResultEntity", + "StabilityStoneCoverWaveConditionsCalculationEntity", + "StabilityStoneCoverWaveConditionsOutputEntity", + "StochastEntity", + "StochasticSoilModelEntity", + "StrengthStabilityLengthwiseConstructionSectionResultEntity", + "SubMechanismIllustrationPointEntity", + "SubMechanismIllustrationPointStochastEntity", + "SurfaceLineEntity", + "TechnicalInnovationSectionResultEntity", + "TopLevelFaultTreeIllustrationPointEntity", + "TopLevelSubMechanismIllustrationPointEntity", + "VersionEntity", + "WaterPressureAsphaltCoverSectionResultEntity", + "WaveImpactAsphaltCoverFailureMechanismMetaEntity", + "WaveImpactAsphaltCoverSectionResultEntity", + "WaveImpactAsphaltCoverWaveConditionsCalculationEntity", + "WaveImpactAsphaltCoverWaveConditionsOutputEntity" + }; + + foreach (string table in tables) + { + string validateMigratedTable = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + $"SELECT COUNT() = (SELECT COUNT() FROM [SOURCEPROJECT].{table}) " + + $"FROM {table};" + + "DETACH SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateMigratedTable); + } + } + + private static void AssertLogDatabase(string logFilePath) + { + using (var reader = new MigrationLogDatabaseReader(logFilePath)) + { + ReadOnlyCollection messages = reader.GetMigrationLogMessages(); + + Assert.AreEqual(2, messages.Count); + var i = 0; + MigrationLogTestHelper.AssertMigrationLogMessageEqual( + new MigrationLogMessage("21.1", newVersion, "Gevolgen van de migratie van versie 21.1 naar versie 21.2:"), + messages[i++]); + MigrationLogTestHelper.AssertMigrationLogMessageEqual( + new MigrationLogMessage("21.1", newVersion, "* Geen aanpassingen."), + messages[i]); + } + } + + private static void AssertVersions(MigratedDatabaseReader reader) + { + const string validateVersion = + "SELECT COUNT() = 1 " + + "FROM [VersionEntity] " + + "WHERE [Version] = \"21.2\";"; + reader.AssertReturnedDataIsValid(validateVersion); + } + + private static void AssertDatabase(MigratedDatabaseReader reader) + { + const string validateForeignKeys = + "PRAGMA foreign_keys;"; + reader.AssertReturnedDataIsValid(validateForeignKeys); + } + } +} \ No newline at end of file Index: Riskeer/Migration/test/Riskeer.Migration.Test/ProjectMigratorTest.cs =================================================================== diff -u -rdabcb057747ff6edfd9e1735cae761c45ae4c004 -r10b69794656806369ef41511ccdeb2914207d221 --- Riskeer/Migration/test/Riskeer.Migration.Test/ProjectMigratorTest.cs (.../ProjectMigratorTest.cs) (revision dabcb057747ff6edfd9e1735cae761c45ae4c004) +++ Riskeer/Migration/test/Riskeer.Migration.Test/ProjectMigratorTest.cs (.../ProjectMigratorTest.cs) (revision 10b69794656806369ef41511ccdeb2914207d221) @@ -522,6 +522,8 @@ migrationLog.AppendLine(" + De waarde voor de transparantie van de achtergrondkaart is aangepast naar 0.60."); migrationLog.AppendLine("Gevolgen van de migratie van versie 19.1 naar versie 21.1:"); migrationLog.AppendLine("* Geen aanpassingen."); + migrationLog.AppendLine("Gevolgen van de migratie van versie 21.1 naar versie 21.2:"); + migrationLog.AppendLine("* Geen aanpassingen."); Tuple[] expectedLogMessagesAndLevel = {