Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/test-data/AssessmentSectionProvider/project.risk =================================================================== diff -u -rd7250e6a0949ba63de3e9c107fa3916a1835a388 -r8a393aff75ea9968eb993b07f2cffb4e8da289c2 Binary files differ Index: Riskeer/Migration/test/Riskeer.Migration.Core.Test/test-data/MigrationTestProject251NoOutput.risk =================================================================== diff -u Binary files differ Index: Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo261IntegrationTest.cs =================================================================== diff -u --- Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo261IntegrationTest.cs (revision 0) +++ Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo261IntegrationTest.cs (revision 8a393aff75ea9968eb993b07f2cffb4e8da289c2) @@ -0,0 +1,199 @@ +// Copyright (C) Stichting Deltares and State of the Netherlands 2026. 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.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using Core.Common.TestUtil; +using NUnit.Framework; +using Riskeer.Migration.Core; +using Riskeer.Migration.Core.TestUtil; + +namespace Riskeer.Migration.Integration.Test +{ + public class MigrationTo261IntegrationTest + { + private const string newVersion = "26.1"; + + [Test] + [TestCaseSource(nameof(GetMigrationProjectsWithMessages))] + public void Given251Project_WhenUpgradedTo261_ThenProjectAsExpected(string fileName, IEnumerable expectedMessages) + { + // Given + string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Migration.Core, fileName); + var fromVersionedFile = new ProjectVersionedFile(sourceFilePath); + + string targetFilePath = TestHelper.GetScratchPadPath(nameof(Given251Project_WhenUpgradedTo261_ThenProjectAsExpected)); + string logFilePath = TestHelper.GetScratchPadPath(string.Concat(nameof(Given251Project_WhenUpgradedTo261_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, expectedMessages); + } + } + + private static IEnumerable GetMigrationProjectsWithMessages() + { + yield return new TestCaseData("MigrationTestProject251NoOutput.risk", new[] + { + "* Geen aanpassingen." + }); + } + + private static void AssertTablesContentMigrated(MigratedDatabaseReader reader, string sourceFilePath) + { + string[] tables = + { + "AdoptableFailureMechanismSectionResultEntity", + "AssessmentSectionEntity", + "BackgroundDataEntity", + "BackgroundDataMetaEntity", + "CalculationGroupEntity", + "ClosingStructureEntity", + "ClosingStructuresCalculationEntity", + "ClosingStructuresFailureMechanismMetaEntity", + "DikeProfileEntity", + "DuneErosionFailureMechanismMetaEntity", + "DuneLocationCalculationEntity", + "DuneLocationCalculationForTargetProbabilityCollectionEntity", + "DuneLocationEntity", + "FailureMechanismEntity", + "FailureMechanismFailureMechanismSectionEntity", + "FailureMechanismSectionEntity", + "ForeshoreProfileEntity", + "GrassCoverErosionInwardsCalculationEntity", + "GrassCoverErosionInwardsFailureMechanismMetaEntity", + "GrassCoverErosionOutwardsFailureMechanismMetaEntity", + "GrassCoverErosionOutwardsWaveConditionsCalculationEntity", + "HeightStructureEntity", + "HeightStructuresCalculationEntity", + "HeightStructuresFailureMechanismMetaEntity", + "HydraulicBoundaryDataEntity", + "HydraulicBoundaryDatabaseEntity", + "HydraulicLocationCalculationCollectionEntity", + "HydraulicLocationCalculationCollectionHydraulicLocationCalculationEntity", + "HydraulicLocationCalculationEntity", + "HydraulicLocationCalculationForTargetProbabilityCollectionEntity", + "HydraulicLocationCalculationForTargetProbabilityCollectionHydraulicLocationCalculationEntity", + "HydraulicLocationEntity", + "MacroStabilityInwardsCalculationEntity", + "MacroStabilityInwardsCharacteristicPointEntity", + "MacroStabilityInwardsFailureMechanismMetaEntity", + "MacroStabilityInwardsFailureMechanismSectionConfigurationEntity", + "MacroStabilityInwardsPreconsolidationStressEntity", + "MacroStabilityInwardsSoilLayerOneDEntity", + "MacroStabilityInwardsSoilLayerTwoDEntity", + "MacroStabilityInwardsSoilProfileOneDEntity", + "MacroStabilityInwardsSoilProfileTwoDEntity", + "MacroStabilityInwardsSoilProfileTwoDSoilLayerTwoDEntity", + "MacroStabilityInwardsStochasticSoilProfileEntity", + "NonAdoptableFailureMechanismSectionResultEntity", + "PipingCharacteristicPointEntity", + "PipingFailureMechanismMetaEntity", + "PipingFailureMechanismSectionConfigurationEntity", + "PipingSoilLayerEntity", + "PipingSoilProfileEntity", + "PipingStochasticSoilProfileEntity", + "ProbabilisticPipingCalculationEntity", + "ProjectEntity", + "SemiProbabilisticPipingCalculationEntity", + "SpecificFailureMechanismEntity", + "SpecificFailureMechanismFailureMechanismSectionEntity", + "StabilityPointStructureEntity", + "StabilityPointStructuresCalculationEntity", + "StabilityPointStructuresFailureMechanismMetaEntity", + "StabilityStoneCoverFailureMechanismMetaEntity", + "StabilityStoneCoverWaveConditionsCalculationEntity", + "StochastEntity", + "StochasticSoilModelEntity", + "SurfaceLineEntity", + "VersionEntity", + "WaveImpactAsphaltCoverFailureMechanismMetaEntity", + "WaveImpactAsphaltCoverWaveConditionsCalculationEntity" + }; + + 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, IEnumerable expectedMessages) + { + using (var reader = new MigrationLogDatabaseReader(logFilePath)) + { + ReadOnlyCollection messages = reader.GetMigrationLogMessages(); + + Assert.AreEqual(expectedMessages.Count() + 1, messages.Count); + var i = 0; + MigrationLogTestHelper.AssertMigrationLogMessageEqual( + new MigrationLogMessage("25.1", newVersion, $"Gevolgen van de migratie van versie 25.1 naar versie {newVersion}:"), + messages[i++]); + + foreach (string expectedMessage in expectedMessages) + { + MigrationLogTestHelper.AssertMigrationLogMessageEqual( + new MigrationLogMessage("25.1", newVersion, $"{expectedMessage}"), + messages[i++]); + } + } + } + + private static void AssertVersions(MigratedDatabaseReader reader) + { + const string validateVersion = + "SELECT COUNT() = 1 " + + "FROM [VersionEntity] " + + "WHERE [Version] = \"26.1\";"; + reader.AssertReturnedDataIsValid(validateVersion); + } + + private static void AssertDatabase(MigratedDatabaseReader reader) + { + const string validateForeignKeys = + "PRAGMA foreign_keys;"; + reader.AssertReturnedDataIsValid(validateForeignKeys); + } + } +} \ No newline at end of file