Index: Riskeer/Migration/test/Riskeer.Migration.Core.Test/test-data/MigrationTestProject211NoManualAssessmentLevels.risk =================================================================== diff -u Binary files differ Index: Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo212IntegrationTest.cs =================================================================== diff -u -r33d80f2fbc1d5c535837caec95ccf7a550170292 -rd4b552d9f1238fcc75a3f943a7e5ed378913a890 --- Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo212IntegrationTest.cs (.../MigrationTo212IntegrationTest.cs) (revision 33d80f2fbc1d5c535837caec95ccf7a550170292) +++ Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo212IntegrationTest.cs (.../MigrationTo212IntegrationTest.cs) (revision d4b552d9f1238fcc75a3f943a7e5ed378913a890) @@ -19,7 +19,9 @@ // 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; @@ -32,11 +34,12 @@ private const string newVersion = "21.2"; [Test] - public void Given211Project_WhenUpgradedTo212_ThenProjectAsExpected() + [TestCaseSource(nameof(GetMigrationProjectsWithMessages))] + public void Given211Project_WhenUpgradedTo212_ThenProjectAsExpected(string filePath, string[] expectedMessages) { // Given string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Migration.Core, - "MigrationTestProject211.risk"); + filePath); var fromVersionedFile = new ProjectVersionedFile(sourceFilePath); string targetFilePath = TestHelper.GetScratchPadPath(nameof(Given211Project_WhenUpgradedTo212_ThenProjectAsExpected)); @@ -77,7 +80,7 @@ AssertPipingScenarioConfigurationPerFailureMechanismSection(reader, sourceFilePath); AssertPipingFailureMechanismSectionResults(reader, sourceFilePath); AssertSemiProbabilisticPipingOutput(reader, sourceFilePath); - + AssertProbabilisticPipingOutput(reader); AssertGrassCoverErosionInwardsFailureMechanismMetaEntity(reader, sourceFilePath); @@ -121,14 +124,35 @@ AssertWaterPressureAsphaltCoverSectionResults(reader, sourceFilePath); AssertGrassCoverSlipOffOutwardsSectionResults(reader, sourceFilePath); AssertGrassCoverSlipOffInwardsSectionResults(reader, sourceFilePath); - + AssertIllustrationPointResults(reader); } - AssertLogDatabase(logFilePath); + AssertLogDatabase(logFilePath, expectedMessages); } } + private static IEnumerable GetMigrationProjectsWithMessages() + { + yield return new TestCaseData("MigrationTestProject211.risk", new[] + { + "* Alle berekende resultaten zijn verwijderd, behalve die van het faalmechanisme 'Piping' waarbij de waterstand handmatig is ingevuld.", + "* De oorspronkelijke faalmechanismen zijn omgezet naar het nieuwe formaat.\r\n* Alle toetsoordelen zijn verwijderd.", + "* Traject: 'Traject 12-2 GEKB signaleringsparameter'", + " + Faalmechanisme: 'Grasbekleding erosie kruin en binnentalud'", + " - De waarden van de doelkans voor HBN en overslagdebiet zijn veranderd naar de trajectnorm.", + "* Traject: 'Traject 12-2 GEKB omgevingswaarde'", + " + Faalmechanisme: 'Grasbekleding erosie kruin en binnentalud'", + " - De waarden van de doelkans voor HBN en overslagdebiet zijn veranderd naar de trajectnorm." + }); + + yield return new TestCaseData("MigrationTestProject211NoManualAssessmentLevels.risk", new[] + { + "* Alle berekende resultaten zijn verwijderd.", + "* De oorspronkelijke faalmechanismen zijn omgezet naar het nieuwe formaat.\r\n* Alle toetsoordelen zijn verwijderd." + }); + } + private static void AssertTablesContentMigrated(MigratedDatabaseReader reader, string sourceFilePath) { string[] tables = @@ -208,6 +232,27 @@ } } + 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("21.1", newVersion, "Gevolgen van de migratie van versie 21.1 naar versie 21.2:"), + messages[i++]); + + foreach (string expectedMessage in expectedMessages) + { + MigrationLogTestHelper.AssertMigrationLogMessageEqual( + new MigrationLogMessage("21.1", newVersion, $"{expectedMessage}"), + messages[i++]); + } + } + } + private static void AssertLogDatabase(string logFilePath) { using (var reader = new MigrationLogDatabaseReader(logFilePath)) @@ -368,7 +413,7 @@ { AssertMigratedSpecificFailurePath(reader, sourceFilePath, 13, "Macrostabiliteit buitenwaarts", "STBU", 1); } - + private static void AssertMacroStabilityOutwardsSections(MigratedDatabaseReader reader, string sourceFilePath) { AssertNonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity(reader, "MacroStabilityOutwardsSectionResultEntity", sourceFilePath); @@ -379,7 +424,7 @@ { AssertMigratedSpecificFailurePath(reader, sourceFilePath, 17, "Sterkte en stabiliteit langsconstructies", "STKWl", 2); } - + private static void AssertStrengthStabilityLengthwiseConstructionSections(MigratedDatabaseReader reader, string sourceFilePath) { AssertNonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity(reader, "StrengthStabilityLengthwiseConstructionSectionResultEntity", sourceFilePath); @@ -390,7 +435,7 @@ { AssertMigratedSpecificFailurePath(reader, sourceFilePath, 18, "Technische innovaties", "INN", 3); } - + private static void AssertTechnicalInnovationSections(MigratedDatabaseReader reader, string sourceFilePath) { AssertNonAdoptableWithProfileProbabilityFailureMechanismSectionResultEntity(reader, "TechnicalInnovationSectionResultEntity", sourceFilePath); @@ -508,13 +553,85 @@ #endregion + #region StabilityStoneCover + + private static void AssertStabilityStoneCoverSectionResults(MigratedDatabaseReader reader, string sourceFilePath) + { + AssertNonAdoptableWithProfileProbabilityFailureMechanismSectionResults(reader, "StabilityStoneCoverSectionResultEntity", sourceFilePath); + } + + #endregion + + private static void AssertIllustrationPointResults(MigratedDatabaseReader reader) + { + const string validateFaultTreeIllustrationPoint = + "SELECT COUNT() = 0 " + + "FROM [FaultTreeIllustrationPointEntity]; "; + reader.AssertReturnedDataIsValid(validateFaultTreeIllustrationPoint); + + const string validateFaultTreeIllustrationPointStochast = + "SELECT COUNT() = 0 " + + "FROM [FaultTreeIllustrationPointStochastEntity]; "; + reader.AssertReturnedDataIsValid(validateFaultTreeIllustrationPointStochast); + + const string validateFaultTreeSubmechanismIllustrationPoint = + "SELECT COUNT() = 0 " + + "FROM [FaultTreeSubmechanismIllustrationPointEntity]; "; + reader.AssertReturnedDataIsValid(validateFaultTreeSubmechanismIllustrationPoint); + + const string validateGeneralResultFaultTreeIllustrationPoint = + "SELECT COUNT() = 0 " + + "FROM [GeneralResultFaultTreeIllustrationPointEntity]; "; + reader.AssertReturnedDataIsValid(validateGeneralResultFaultTreeIllustrationPoint); + + const string validateGeneralResultFaultTreeIllustrationPointStochast = + "SELECT COUNT() = 0 " + + "FROM [GeneralResultFaultTreeIllustrationPointStochastEntity]; "; + reader.AssertReturnedDataIsValid(validateGeneralResultFaultTreeIllustrationPointStochast); + + const string validateGeneralResultSubMechanismIllustrationPoint = + "SELECT COUNT() = 0 " + + "FROM [GeneralResultSubMechanismIllustrationPointEntity]; "; + reader.AssertReturnedDataIsValid(validateGeneralResultSubMechanismIllustrationPoint); + + const string validateGeneralResultSubMechanismIllustrationPointStochast = + "SELECT COUNT() = 0 " + + "FROM [GeneralResultSubMechanismIllustrationPointStochastEntity]; "; + reader.AssertReturnedDataIsValid(validateGeneralResultSubMechanismIllustrationPointStochast); + + const string validateIllustrationPointResult = + "SELECT COUNT() = 0 " + + "FROM [IllustrationPointResultEntity]; "; + reader.AssertReturnedDataIsValid(validateIllustrationPointResult); + + const string validateSubMechanismIllustrationPoint = + "SELECT COUNT() = 0 " + + "FROM [SubMechanismIllustrationPointEntity]; "; + reader.AssertReturnedDataIsValid(validateSubMechanismIllustrationPoint); + + const string validateSubMechanismIllustrationPointStochast = + "SELECT COUNT() = 0 " + + "FROM [SubMechanismIllustrationPointStochastEntity]; "; + reader.AssertReturnedDataIsValid(validateSubMechanismIllustrationPointStochast); + + const string validateTopLevelFaultTreeIllustrationPoint = + "SELECT COUNT() = 0 " + + "FROM [TopLevelFaultTreeIllustrationPointEntity]; "; + reader.AssertReturnedDataIsValid(validateTopLevelFaultTreeIllustrationPoint); + + const string validateTopLevelSubMechanismIllustrationPoint = + "SELECT COUNT() = 0 " + + "FROM [TopLevelSubMechanismIllustrationPointEntity]; "; + reader.AssertReturnedDataIsValid(validateTopLevelSubMechanismIllustrationPoint); + } + #region HeightStructures private static void AssertHeightStructuresSectionResults(MigratedDatabaseReader reader, string sourceFilePath) { AssertAdoptableFailureMechanismSectionResults(reader, "HeightStructuresSectionResultEntity", sourceFilePath); } - + private static void AssertHeightStructuresOutput(MigratedDatabaseReader reader) { const string validateOutput = @@ -531,7 +648,7 @@ { AssertAdoptableFailureMechanismSectionResults(reader, "ClosingStructuresSectionResultEntity", sourceFilePath); } - + private static void AssertClosingStructuresOutput(MigratedDatabaseReader reader) { const string validateOutput = @@ -548,7 +665,7 @@ { AssertAdoptableFailureMechanismSectionResults(reader, "StabilityPointStructuresSectionResultEntity", sourceFilePath); } - + private static void AssertStabilityPointStructuresOutput(MigratedDatabaseReader reader) { const string validateOutput = @@ -559,15 +676,6 @@ #endregion - #region StabilityStoneCover - - private static void AssertStabilityStoneCoverSectionResults(MigratedDatabaseReader reader, string sourceFilePath) - { - AssertNonAdoptableWithProfileProbabilityFailureMechanismSectionResults(reader, "StabilityStoneCoverSectionResultEntity", sourceFilePath); - } - - #endregion - #region MacroStabilityInwards private static void AssertMacroStabilityInwardsOutput(MigratedDatabaseReader reader) @@ -916,7 +1024,7 @@ { AssertAdoptableWithProfileProbabilityFailureMechanismSectionResults(reader, "PipingSectionResultEntity", sourceFilePath); } - + private static void AssertSemiProbabilisticPipingOutput(MigratedDatabaseReader reader, string sourceFilePath) { string validateOutput = @@ -943,7 +1051,7 @@ "DETACH SOURCEPROJECT;"; reader.AssertReturnedDataIsValid(validateOutput); } - + private static void AssertProbabilisticPipingOutput(MigratedDatabaseReader reader) { const string validateOutput = @@ -1117,7 +1225,7 @@ "SELECT COUNT() = 0 " + "FROM [GrassCoverErosionInwardsOutputEntity]; "; reader.AssertReturnedDataIsValid(validateOutput); - + const string validateDikeHeightOutput = "SELECT COUNT() = 0 " + "FROM [GrassCoverErosionInwardsDikeHeightOutputEntity]; "; @@ -1389,68 +1497,5 @@ } #endregion - - private static void AssertIllustrationPointResults(MigratedDatabaseReader reader) - { - const string validateFaultTreeIllustrationPoint = - "SELECT COUNT() = 0 " + - "FROM [FaultTreeIllustrationPointEntity]; "; - reader.AssertReturnedDataIsValid(validateFaultTreeIllustrationPoint); - - const string validateFaultTreeIllustrationPointStochast = - "SELECT COUNT() = 0 " + - "FROM [FaultTreeIllustrationPointStochastEntity]; "; - reader.AssertReturnedDataIsValid(validateFaultTreeIllustrationPointStochast); - - const string validateFaultTreeSubmechanismIllustrationPoint = - "SELECT COUNT() = 0 " + - "FROM [FaultTreeSubmechanismIllustrationPointEntity]; "; - reader.AssertReturnedDataIsValid(validateFaultTreeSubmechanismIllustrationPoint); - - const string validateGeneralResultFaultTreeIllustrationPoint = - "SELECT COUNT() = 0 " + - "FROM [GeneralResultFaultTreeIllustrationPointEntity]; "; - reader.AssertReturnedDataIsValid(validateGeneralResultFaultTreeIllustrationPoint); - - const string validateGeneralResultFaultTreeIllustrationPointStochast = - "SELECT COUNT() = 0 " + - "FROM [GeneralResultFaultTreeIllustrationPointStochastEntity]; "; - reader.AssertReturnedDataIsValid(validateGeneralResultFaultTreeIllustrationPointStochast); - - const string validateGeneralResultSubMechanismIllustrationPoint = - "SELECT COUNT() = 0 " + - "FROM [GeneralResultSubMechanismIllustrationPointEntity]; "; - reader.AssertReturnedDataIsValid(validateGeneralResultSubMechanismIllustrationPoint); - - const string validateGeneralResultSubMechanismIllustrationPointStochast = - "SELECT COUNT() = 0 " + - "FROM [GeneralResultSubMechanismIllustrationPointStochastEntity]; "; - reader.AssertReturnedDataIsValid(validateGeneralResultSubMechanismIllustrationPointStochast); - - const string validateIllustrationPointResult = - "SELECT COUNT() = 0 " + - "FROM [IllustrationPointResultEntity]; "; - reader.AssertReturnedDataIsValid(validateIllustrationPointResult); - - const string validateSubMechanismIllustrationPoint = - "SELECT COUNT() = 0 " + - "FROM [SubMechanismIllustrationPointEntity]; "; - reader.AssertReturnedDataIsValid(validateSubMechanismIllustrationPoint); - - const string validateSubMechanismIllustrationPointStochast = - "SELECT COUNT() = 0 " + - "FROM [SubMechanismIllustrationPointStochastEntity]; "; - reader.AssertReturnedDataIsValid(validateSubMechanismIllustrationPointStochast); - - const string validateTopLevelFaultTreeIllustrationPoint = - "SELECT COUNT() = 0 " + - "FROM [TopLevelFaultTreeIllustrationPointEntity]; "; - reader.AssertReturnedDataIsValid(validateTopLevelFaultTreeIllustrationPoint); - - const string validateTopLevelSubMechanismIllustrationPoint = - "SELECT COUNT() = 0 " + - "FROM [TopLevelSubMechanismIllustrationPointEntity]; "; - reader.AssertReturnedDataIsValid(validateTopLevelSubMechanismIllustrationPoint); - } } } \ No newline at end of file