Index: Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/DatabaseStructure20.1.sql =================================================================== diff -u -r8f223d35ced102ff207cff304cefadde224a17ef -r222d49d381480a238c0dbbd319c104c5ccb6546b --- Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/DatabaseStructure20.1.sql (.../DatabaseStructure20.1.sql) (revision 8f223d35ced102ff207cff304cefadde224a17ef) +++ Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/DatabaseStructure20.1.sql (.../DatabaseStructure20.1.sql) (revision 222d49d381480a238c0dbbd319c104c5ccb6546b) @@ -1,6 +1,6 @@ /* ---------------------------------------------------- */ /* Generated by Enterprise Architect Version 14.1 */ -/* Created On : 22-jan-2021 11:40:21 */ +/* Created On : 05-feb-2021 08:37:48 */ /* DBMS : SQLite */ /* ---------------------------------------------------- */ @@ -456,7 +456,7 @@ 'DampingFactorExitMean' REAL NULL, 'DampingFactorExitStandardDeviation' REAL NULL, 'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false - 'ScenarioContribution' REAL NULL, + 'ScenarioContribution' REAL NOT NULL, 'AssessmentLevel' REAL NULL, 'UseAssessmentLevelManualInput' TINYINT (1) NOT NULL, -- true or false CONSTRAINT 'FK_SemiProbabilisticPipingCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, @@ -489,7 +489,7 @@ 'ShouldOvertoppingRateIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false 'ShouldOvertoppingOutputIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false 'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false - 'ScenarioContribution' REAL NULL, + 'ScenarioContribution' REAL NOT NULL, CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_DikeProfileEntity' FOREIGN KEY ('DikeProfileEntityId') REFERENCES 'DikeProfileEntity' ('DikeProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, CONSTRAINT 'FK_GrassCoverErosionInwardsCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade @@ -721,8 +721,8 @@ 'StormDurationMean' REAL NULL, 'FactorStormDurationOpenStructure' REAL NULL, 'ShouldIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false - 'RelevantForScenario' TINYINT (1) NOT NULL, - 'ScenarioContribution' REAL NULL, + 'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false + 'ScenarioContribution' REAL NOT NULL, CONSTRAINT 'FK_ClosingStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, CONSTRAINT 'FK_ClosingStructuresCalculationEntity_ClosingStructureEntity' FOREIGN KEY ('ClosingStructureEntityId') REFERENCES 'ClosingStructureEntity' ('ClosingStructureEntityId') ON DELETE Set Null ON UPDATE Cascade, CONSTRAINT 'FK_ClosingStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, @@ -1162,8 +1162,8 @@ 'BreakWaterType' TINYINT (1) NOT NULL, -- Enum: 1 = Wall, 2 = Caisson, 3 = Dam 'BreakWaterHeight' REAL NULL, 'ShouldIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false - 'RelevantForScenario' TINYINT (1) NOT NULL, - 'ScenarioContribution' REAL NULL, + 'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false + 'ScenarioContribution' REAL NOT NULL, CONSTRAINT 'FK_HeightStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, CONSTRAINT 'FK_HeightStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, CONSTRAINT 'FK_HeightStructuresCalculationEntity_HeightStructureEntity' FOREIGN KEY ('HeightStructureEntityId') REFERENCES 'HeightStructureEntity' ('HeightStructureEntityId') ON DELETE Set Null ON UPDATE Cascade, @@ -1285,7 +1285,7 @@ 'Name' VARCHAR (260) NULL, 'Comment' TEXT NULL, 'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false - 'ScenarioContribution' REAL NULL, + 'ScenarioContribution' REAL NOT NULL, 'AssessmentLevel' REAL NULL, 'UseAssessmentLevelManualInput' TINYINT (1) NOT NULL, -- true or false 'SlipPlaneMinimumDepth' REAL NULL, @@ -1815,8 +1815,8 @@ 'DrainCoefficientStandardDeviation' REAL NULL, 'FailureProbabilityStructureWithErosion' REAL NOT NULL, 'ShouldIllustrationPointsBeCalculated' TINYINT (1) NOT NULL, -- true or false - 'RelevantForScenario' TINYINT (1) NOT NULL, - 'ScenarioContribution' REAL NULL, + 'RelevantForScenario' TINYINT (1) NOT NULL, -- true or false + 'ScenarioContribution' REAL NOT NULL, CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_CalculationGroupEntity' FOREIGN KEY ('CalculationGroupEntityId') REFERENCES 'CalculationGroupEntity' ('CalculationGroupEntityId') ON DELETE Cascade ON UPDATE Cascade, CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_ForeshoreProfileEntity' FOREIGN KEY ('ForeshoreProfileEntityId') REFERENCES 'ForeshoreProfileEntity' ('ForeshoreProfileEntityId') ON DELETE Set Null ON UPDATE Cascade, CONSTRAINT 'FK_StabilityPointStructuresCalculationEntity_HydraulicLocationEntity' FOREIGN KEY ('HydraulicLocationEntityId') REFERENCES 'HydraulicLocationEntity' ('HydraulicLocationEntityId') ON DELETE Set Null ON UPDATE Cascade, Index: Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/Migration_19.1_20.1.sql =================================================================== diff -u -r33361cb42a2e4e591fc85609b2c15e24fad61ee8 -r222d49d381480a238c0dbbd319c104c5ccb6546b --- Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/Migration_19.1_20.1.sql (.../Migration_19.1_20.1.sql) (revision 33361cb42a2e4e591fc85609b2c15e24fad61ee8) +++ Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/Migration_19.1_20.1.sql (.../Migration_19.1_20.1.sql) (revision 222d49d381480a238c0dbbd319c104c5ccb6546b) @@ -357,7 +357,145 @@ INSERT INTO HydraulicLocationCalculationCollectionEntity SELECT * FROM [SOURCEPROJECT].HydraulicLocationCalculationCollectionEntity; INSERT INTO HydraulicLocationCalculationEntity SELECT * FROM [SOURCEPROJECT].HydraulicLocationCalculationEntity; INSERT INTO HydraulicLocationEntity SELECT * FROM [SOURCEPROJECT].HydraulicLocationEntity; -INSERT INTO MacroStabilityInwardsCalculationEntity SELECT * FROM [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity; +INSERT INTO MacroStabilityInwardsCalculationEntity ( + [MacroStabilityInwardsCalculationEntityId], + [CalculationGroupEntityId], + [SurfaceLineEntityId], + [MacroStabilityInwardsStochasticSoilProfileEntityId], + [HydraulicLocationEntityId], + [Order], + [Name], + [Comment], + [RelevantForScenario], + [ScenarioContribution], + [AssessmentLevel], + [UseAssessmentLevelManualInput], + [SlipPlaneMinimumDepth], + [SlipPlaneMinimumLength], + [MaximumSliceWidth], + [MoveGrid], + [GridDeterminationType], + [TangentLineDeterminationType], + [TangentLineZTop], + [TangentLineZBottom], + [TangentLineNumber], + [LeftGridXLeft], + [LeftGridXRight], + [LeftGridNrOfHorizontalPoints], + [LeftGridZTop], + [LeftGridZBottom], + [LeftGridNrOfVerticalPoints], + [RightGridXLeft], + [RightGridXRight], + [RightGridNrOfHorizontalPoints], + [RightGridZTop], + [RightGridZBottom], + [RightGridNrOfVerticalPoints], + [DikeSoilScenario], + [WaterLevelRiverAverage], + [DrainageConstructionPresent], + [DrainageConstructionCoordinateX], + [DrainageConstructionCoordinateZ], + [MinimumLevelPhreaticLineAtDikeTopRiver], + [MinimumLevelPhreaticLineAtDikeTopPolder], + [AdjustPhreaticLine3And4ForUplift], + [LeakageLengthOutwardsPhreaticLine3], + [LeakageLengthInwardsPhreaticLine3], + [LeakageLengthOutwardsPhreaticLine4], + [LeakageLengthInwardsPhreaticLine4], + [PiezometricHeadPhreaticLine2Outwards], + [PiezometricHeadPhreaticLine2Inwards], + [LocationInputExtremeWaterLevelPolder], + [LocationInputExtremeUseDefaultOffsets], + [LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver], + [LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder], + [LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside], + [LocationInputExtremePhreaticLineOffsetDikeToeAtPolder], + [LocationInputExtremePenetrationLength], + [LocationInputDailyWaterLevelPolder], + [LocationInputDailyUseDefaultOffsets], + [LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver], + [LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder], + [LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside], + [LocationInputDailyPhreaticLineOffsetDikeToeAtPolder], + [CreateZones], + [ZoningBoundariesDeterminationType], + [ZoneBoundaryLeft], + [ZoneBoundaryRight]) +SELECT + [MacroStabilityInwardsCalculationEntityId], + [CalculationGroupEntityId], + [SurfaceLineEntityId], + [MacroStabilityInwardsStochasticSoilProfileEntityId], + [HydraulicLocationEntityId], + [Order], + [Name], + [Comment], + [RelevantForScenario], + CASE + WHEN [ScenarioContribution] IS NULL + OR [ScenarioContribution] < 0 + THEN 0 + WHEN [ScenarioContribution] > 1 + THEN 1 + ELSE + [ScenarioContribution] + END, + [AssessmentLevel], + [UseAssessmentLevelManualInput], + [SlipPlaneMinimumDepth], + [SlipPlaneMinimumLength], + [MaximumSliceWidth], + [MoveGrid], + [GridDeterminationType], + [TangentLineDeterminationType], + [TangentLineZTop], + [TangentLineZBottom], + [TangentLineNumber], + [LeftGridXLeft], + [LeftGridXRight], + [LeftGridNrOfHorizontalPoints], + [LeftGridZTop], + [LeftGridZBottom], + [LeftGridNrOfVerticalPoints], + [RightGridXLeft], + [RightGridXRight], + [RightGridNrOfHorizontalPoints], + [RightGridZTop], + [RightGridZBottom], + [RightGridNrOfVerticalPoints], + [DikeSoilScenario], + [WaterLevelRiverAverage], + [DrainageConstructionPresent], + [DrainageConstructionCoordinateX], + [DrainageConstructionCoordinateZ], + [MinimumLevelPhreaticLineAtDikeTopRiver], + [MinimumLevelPhreaticLineAtDikeTopPolder], + [AdjustPhreaticLine3And4ForUplift], + [LeakageLengthOutwardsPhreaticLine3], + [LeakageLengthInwardsPhreaticLine3], + [LeakageLengthOutwardsPhreaticLine4], + [LeakageLengthInwardsPhreaticLine4], + [PiezometricHeadPhreaticLine2Outwards], + [PiezometricHeadPhreaticLine2Inwards], + [LocationInputExtremeWaterLevelPolder], + [LocationInputExtremeUseDefaultOffsets], + [LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver], + [LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder], + [LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside], + [LocationInputExtremePhreaticLineOffsetDikeToeAtPolder], + [LocationInputExtremePenetrationLength], + [LocationInputDailyWaterLevelPolder], + [LocationInputDailyUseDefaultOffsets], + [LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver], + [LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder], + [LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside], + [LocationInputDailyPhreaticLineOffsetDikeToeAtPolder], + [CreateZones], + [ZoningBoundariesDeterminationType], + [ZoneBoundaryLeft], + [ZoneBoundaryRight] +FROM [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity; INSERT INTO MacroStabilityInwardsCharacteristicPointEntity SELECT * FROM [SOURCEPROJECT].MacroStabilityInwardsCharacteristicPointEntity; INSERT INTO MacroStabilityInwardsFailureMechanismMetaEntity SELECT * FROM [SOURCEPROJECT].MacroStabilityInwardsFailureMechanismMetaEntity; INSERT INTO MacroStabilityInwardsPreconsolidationStressEntity SELECT * FROM [SOURCEPROJECT].MacroStabilityInwardsPreconsolidationStressEntity; @@ -406,7 +544,15 @@ [DampingFactorExitMean], [DampingFactorExitStandardDeviation], [RelevantForScenario], - [ScenarioContribution], + CASE + WHEN [ScenarioContribution] IS NULL + OR [ScenarioContribution] < 0 + THEN 0 + WHEN [ScenarioContribution] > 1 + THEN 1 + ELSE + [ScenarioContribution] + END, [AssessmentLevel], [UseAssessmentLevelManualInput] FROM [SOURCEPROJECT].PipingCalculationEntity; @@ -756,7 +902,59 @@ DROP TABLE TempLogOutputDeleted; DROP TABLE TempLogOutputRemaining; +CREATE TEMP TABLE TempPipingValuesAdjusted +( + 'NrAdjusted' INTEGER NOT NULL +); + +INSERT INTO TempPipingValuesAdjusted SELECT COUNT() FROM [SOURCEPROJECT].PipingCalculationEntity +WHERE ( + [ScenarioContribution] > 1.0 + OR [ScenarioContribution] < 0.0 + OR [ScenarioContribution] IS NULL + ); + INSERT INTO [LOGDATABASE].MigrationLogEntity ( + [FromVersion], + [ToVersion], + [LogMessage]) +SELECT + "19.1", + "20.1", + "* Alle scenario bijdragen van van het toetsspoor 'Piping' waarbij de bijdrage groter is dan 100% of kleiner dan 0% zijn aangepast naar respectievelijk 100% en 0%." +FROM TempPipingValuesAdjusted +WHERE [NrAdjusted] > 0 + LIMIT 1; + +DROP TABLE TempPipingValuesAdjusted; + +CREATE TEMP TABLE TempMacroStabilityInwardsValuesAdjusted +( + 'NrAdjusted' INTEGER NOT NULL +); + +INSERT INTO TempMacroStabilityInwardsValuesAdjusted SELECT COUNT() FROM [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity +WHERE ( + [ScenarioContribution] > 1.0 + OR [ScenarioContribution] < 0.0 + OR [ScenarioContribution] IS NULL + ); + +INSERT INTO [LOGDATABASE].MigrationLogEntity ( + [FromVersion], + [ToVersion], +[LogMessage]) +SELECT + "19.1", + "20.1", + "* Alle scenario bijdragen van het toetsspoor 'Macrostabiliteit Binnenwaarts' waarbij de bijdrage groter is dan 100% of kleiner dan 0% zijn aangepast naar respectievelijk 100% en 0%." +FROM TempMacroStabilityInwardsValuesAdjusted +WHERE [NrAdjusted] > 0 + LIMIT 1; + +DROP TABLE TempMacroStabilityInwardsValuesAdjusted; + +INSERT INTO [LOGDATABASE].MigrationLogEntity ( [FromVersion], [ToVersion], [LogMessage]) Index: Riskeer/Migration/test/Riskeer.Migration.Core.Test/test-data/MigrationTestProject191.risk =================================================================== diff -u -r32f73bceb7e6b93545799d74f5cd890d700fe7b7 -r222d49d381480a238c0dbbd319c104c5ccb6546b Binary files differ Index: Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo201IntegrationTest.cs =================================================================== diff -u -r32f73bceb7e6b93545799d74f5cd890d700fe7b7 -r222d49d381480a238c0dbbd319c104c5ccb6546b --- Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo201IntegrationTest.cs (.../MigrationTo201IntegrationTest.cs) (revision 32f73bceb7e6b93545799d74f5cd890d700fe7b7) +++ Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo201IntegrationTest.cs (.../MigrationTo201IntegrationTest.cs) (revision 222d49d381480a238c0dbbd319c104c5ccb6546b) @@ -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; @@ -33,10 +35,8 @@ private const string newVersion = "20.1"; [Test] - [TestCase("MigrationTestProject191.risk", "Alle berekende resultaten zijn verwijderd, behalve die van het toetsspoor 'Piping' waarbij de waterstand handmatig is ingevuld.")] - [TestCase("MigrationTestProject191NoManualAssessmentLevels.risk", "Alle berekende resultaten zijn verwijderd.")] - [TestCase("MigrationTestProject191NoOutput.risk", "Geen aanpassingen.")] - public void Given191Project_WhenUpgradedTo201_ThenProjectAsExpected(string filePath, string expectedMessage) + [TestCaseSource(nameof(GetMigrationProjectsWithMessages))] + public void Given191Project_WhenUpgradedTo201_ThenProjectAsExpected(string filePath, string[] expectedMessages) { // Given string sourceFilePath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Migration.Core, @@ -86,6 +86,7 @@ AssertStabilityPointStructuresOutput(reader); AssertStabilityPointStructuresSectionResult(reader, sourceFilePath); + AssertMacroStabilityInwardsCalculation(reader, sourceFilePath); AssertMacroStabilityInwardsOutput(reader); AssertPipingCalculation(reader, sourceFilePath); @@ -96,10 +97,30 @@ AssertIllustrationPointResults(reader); } - AssertLogDatabase(logFilePath, expectedMessage); + AssertLogDatabase(logFilePath, expectedMessages); } } + private static IEnumerable GetMigrationProjectsWithMessages() + { + yield return new TestCaseData("MigrationTestProject191.risk", new[] + { + "Alle berekende resultaten zijn verwijderd, behalve die van het toetsspoor 'Piping' waarbij de waterstand handmatig is ingevuld.", + "Alle scenario bijdragen van van het toetsspoor 'Piping' waarbij de bijdrage groter is dan 100% of kleiner dan 0% zijn aangepast naar respectievelijk 100% en 0%.", + "Alle scenario bijdragen van het toetsspoor 'Macrostabiliteit Binnenwaarts' waarbij de bijdrage groter is dan 100% of kleiner dan 0% zijn aangepast naar respectievelijk 100% en 0%." + }); + + yield return new TestCaseData("MigrationTestProject191NoManualAssessmentLevels.risk", new[] + { + "Alle berekende resultaten zijn verwijderd." + }); + + yield return new TestCaseData("MigrationTestProject191NoOutput.risk", new[] + { + "Geen aanpassingen." + }); + } + private static void AssertHydraulicLocationOutput(MigratedDatabaseReader reader) { const string validateOutput = @@ -712,6 +733,242 @@ reader.AssertReturnedDataIsValid(validateSectionResults); } + private static void AssertMacroStabilityInwardsCalculation(MigratedDatabaseReader reader, string sourceFilePath) + { + string validateCalculationWithScenarioContributionNullOrBelowZero = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = " + + "(" + + "SELECT COUNT() " + + "FROM [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity " + + "WHERE ScenarioContribution IS NULL " + + "OR ScenarioContribution <= 0 " + + ")" + + "FROM MacroStabilityInwardsCalculationEntity NEW " + + "JOIN [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity OLD USING(MacroStabilityInwardsCalculationEntityId) " + + "WHERE NEW.[MacroStabilityInwardsCalculationEntityId] = OLD.[MacroStabilityInwardsCalculationEntityId] " + + "AND NEW.[CalculationGroupEntityId] = OLD.[CalculationGroupEntityId] " + + "AND NEW.[SurfaceLineEntityId] IS OLD.[SurfaceLineEntityId] " + + "AND NEW.[MacroStabilityInwardsStochasticSoilProfileEntityId] IS OLD.[MacroStabilityInwardsStochasticSoilProfileEntityId] " + + "AND NEW.[HydraulicLocationEntityId] IS OLD.[HydraulicLocationEntityId] " + + "AND NEW.[Order] = OLD.[Order] " + + "AND NEW.[Name] IS OLD.[Name] " + + "AND NEW.[Comment] IS OLD.[Comment] " + + "AND NEW.[RelevantForScenario] = OLD.[RelevantForScenario] " + + "AND NEW.[ScenarioContribution] = 0 " + + "AND NEW.[AssessmentLevel] IS OLD.[AssessmentLevel] " + + "AND NEW.[UseAssessmentLevelManualInput] = OLD.[UseAssessmentLevelManualInput] " + + "AND NEW.[SlipPlaneMinimumDepth] IS OLD.[SlipPlaneMinimumDepth] " + + "AND NEW.[SlipPlaneMinimumLength] IS OLD.[SlipPlaneMinimumLength] " + + "AND NEW.[MaximumSliceWidth] IS OLD.[MaximumSliceWidth] " + + "AND NEW.[MoveGrid] = OLD.[MoveGrid] " + + "AND NEW.[GridDeterminationType] = OLD.[GridDeterminationType] " + + "AND NEW.[TangentLineDeterminationType] = OLD.[TangentLineDeterminationType] " + + "AND NEW.[TangentLineZTop] IS OLD.[TangentLineZTop] " + + "AND NEW.[TangentLineZBottom] IS OLD.[TangentLineZBottom] " + + "AND NEW.[TangentLineNumber] = OLD.[TangentLineNumber] " + + "AND NEW.[LeftGridXLeft] IS OLD.[LeftGridXLeft] " + + "AND NEW.[LeftGridXRight] IS OLD.[LeftGridXRight] " + + "AND NEW.[LeftGridNrOfHorizontalPoints] = OLD.[LeftGridNrOfHorizontalPoints] " + + "AND NEW.[LeftGridZTop] IS OLD.[LeftGridZTop] " + + "AND NEW.[LeftGridZBottom] IS OLD.[LeftGridZBottom] " + + "AND NEW.[LeftGridNrOfVerticalPoints] = OLD.[LeftGridNrOfVerticalPoints] " + + "AND NEW.[RightGridXLeft] IS OLD.[RightGridXLeft] " + + "AND NEW.[RightGridXRight] IS OLD.[RightGridXRight] " + + "AND NEW.[RightGridNrOfHorizontalPoints] = OLD.[RightGridNrOfHorizontalPoints] " + + "AND NEW.[RightGridZTop] IS OLD.[RightGridZTop] " + + "AND NEW.[RightGridZBottom] IS OLD.[RightGridZBottom] " + + "AND NEW.[RightGridNrOfVerticalPoints] = OLD.[RightGridNrOfVerticalPoints] " + + "AND NEW.[DikeSoilScenario] = OLD.[DikeSoilScenario] " + + "AND NEW.[WaterLevelRiverAverage] IS OLD.[WaterLevelRiverAverage] " + + "AND NEW.[DrainageConstructionPresent] = OLD.[DrainageConstructionPresent] " + + "AND NEW.[DrainageConstructionCoordinateX] IS OLD.[DrainageConstructionCoordinateX] " + + "AND NEW.[DrainageConstructionCoordinateZ] IS OLD.[DrainageConstructionCoordinateZ] " + + "AND NEW.[MinimumLevelPhreaticLineAtDikeTopRiver] IS OLD.[MinimumLevelPhreaticLineAtDikeTopRiver] " + + "AND NEW.[MinimumLevelPhreaticLineAtDikeTopPolder] IS OLD.[MinimumLevelPhreaticLineAtDikeTopPolder] " + + "AND NEW.[AdjustPhreaticLine3And4ForUplift] = OLD.[AdjustPhreaticLine3And4ForUplift] " + + "AND NEW.[LeakageLengthOutwardsPhreaticLine3] IS OLD.[LeakageLengthOutwardsPhreaticLine3] " + + "AND NEW.[LeakageLengthInwardsPhreaticLine3] IS OLD.[LeakageLengthInwardsPhreaticLine3] " + + "AND NEW.[LeakageLengthOutwardsPhreaticLine4] IS OLD.[LeakageLengthOutwardsPhreaticLine4] " + + "AND NEW.[LeakageLengthInwardsPhreaticLine4] IS OLD.[LeakageLengthInwardsPhreaticLine4] " + + "AND NEW.[PiezometricHeadPhreaticLine2Outwards] IS OLD.[PiezometricHeadPhreaticLine2Outwards] " + + "AND NEW.[PiezometricHeadPhreaticLine2Inwards] IS OLD.[PiezometricHeadPhreaticLine2Inwards] " + + "AND NEW.[LocationInputExtremeWaterLevelPolder] IS OLD.[LocationInputExtremeWaterLevelPolder] " + + "AND NEW.[LocationInputExtremeUseDefaultOffsets] = OLD.[LocationInputExtremeUseDefaultOffsets] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetDikeToeAtPolder] IS OLD.[LocationInputExtremePhreaticLineOffsetDikeToeAtPolder] " + + "AND NEW.[LocationInputExtremePenetrationLength] IS OLD.[LocationInputExtremePenetrationLength] " + + "AND NEW.[LocationInputDailyWaterLevelPolder] IS OLD.[LocationInputDailyWaterLevelPolder] " + + "AND NEW.[LocationInputDailyUseDefaultOffsets] = OLD.[LocationInputDailyUseDefaultOffsets] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetDikeToeAtPolder] IS OLD.[LocationInputDailyPhreaticLineOffsetDikeToeAtPolder] " + + "AND NEW.[CreateZones] = OLD.[CreateZones] " + + "AND NEW.[ZoningBoundariesDeterminationType] = OLD.[ZoningBoundariesDeterminationType] " + + "AND NEW.[ZoneBoundaryLeft] IS OLD.[ZoneBoundaryLeft] " + + "AND NEW.[ZoneBoundaryRight] IS OLD.[ZoneBoundaryRight]; " + + "DETACH SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateCalculationWithScenarioContributionNullOrBelowZero); + + string validateCalculationWithScenarioContributionAboveOne = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = " + + "(" + + "SELECT COUNT() " + + "FROM [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity " + + "WHERE ScenarioContribution >= 1 " + + ")" + + "FROM MacroStabilityInwardsCalculationEntity NEW " + + "JOIN [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity OLD USING(MacroStabilityInwardsCalculationEntityId) " + + "WHERE NEW.[MacroStabilityInwardsCalculationEntityId] = OLD.[MacroStabilityInwardsCalculationEntityId] " + + "AND NEW.[CalculationGroupEntityId] = OLD.[CalculationGroupEntityId] " + + "AND NEW.[SurfaceLineEntityId] IS OLD.[SurfaceLineEntityId] " + + "AND NEW.[MacroStabilityInwardsStochasticSoilProfileEntityId] IS OLD.[MacroStabilityInwardsStochasticSoilProfileEntityId] " + + "AND NEW.[HydraulicLocationEntityId] IS OLD.[HydraulicLocationEntityId] " + + "AND NEW.[Order] = OLD.[Order] " + + "AND NEW.[Name] IS OLD.[Name] " + + "AND NEW.[Comment] IS OLD.[Comment] " + + "AND NEW.[RelevantForScenario] = OLD.[RelevantForScenario] " + + "AND NEW.[ScenarioContribution] = 1 " + + "AND NEW.[AssessmentLevel] IS OLD.[AssessmentLevel] " + + "AND NEW.[UseAssessmentLevelManualInput] = OLD.[UseAssessmentLevelManualInput] " + + "AND NEW.[SlipPlaneMinimumDepth] IS OLD.[SlipPlaneMinimumDepth] " + + "AND NEW.[SlipPlaneMinimumLength] IS OLD.[SlipPlaneMinimumLength] " + + "AND NEW.[MaximumSliceWidth] IS OLD.[MaximumSliceWidth] " + + "AND NEW.[MoveGrid] = OLD.[MoveGrid] " + + "AND NEW.[GridDeterminationType] = OLD.[GridDeterminationType] " + + "AND NEW.[TangentLineDeterminationType] = OLD.[TangentLineDeterminationType] " + + "AND NEW.[TangentLineZTop] IS OLD.[TangentLineZTop] " + + "AND NEW.[TangentLineZBottom] IS OLD.[TangentLineZBottom] " + + "AND NEW.[TangentLineNumber] = OLD.[TangentLineNumber] " + + "AND NEW.[LeftGridXLeft] IS OLD.[LeftGridXLeft] " + + "AND NEW.[LeftGridXRight] IS OLD.[LeftGridXRight] " + + "AND NEW.[LeftGridNrOfHorizontalPoints] = OLD.[LeftGridNrOfHorizontalPoints] " + + "AND NEW.[LeftGridZTop] IS OLD.[LeftGridZTop] " + + "AND NEW.[LeftGridZBottom] IS OLD.[LeftGridZBottom] " + + "AND NEW.[LeftGridNrOfVerticalPoints] = OLD.[LeftGridNrOfVerticalPoints] " + + "AND NEW.[RightGridXLeft] IS OLD.[RightGridXLeft] " + + "AND NEW.[RightGridXRight] IS OLD.[RightGridXRight] " + + "AND NEW.[RightGridNrOfHorizontalPoints] = OLD.[RightGridNrOfHorizontalPoints] " + + "AND NEW.[RightGridZTop] IS OLD.[RightGridZTop] " + + "AND NEW.[RightGridZBottom] IS OLD.[RightGridZBottom] " + + "AND NEW.[RightGridNrOfVerticalPoints] = OLD.[RightGridNrOfVerticalPoints] " + + "AND NEW.[DikeSoilScenario] = OLD.[DikeSoilScenario] " + + "AND NEW.[WaterLevelRiverAverage] IS OLD.[WaterLevelRiverAverage] " + + "AND NEW.[DrainageConstructionPresent] = OLD.[DrainageConstructionPresent] " + + "AND NEW.[DrainageConstructionCoordinateX] IS OLD.[DrainageConstructionCoordinateX] " + + "AND NEW.[DrainageConstructionCoordinateZ] IS OLD.[DrainageConstructionCoordinateZ] " + + "AND NEW.[MinimumLevelPhreaticLineAtDikeTopRiver] IS OLD.[MinimumLevelPhreaticLineAtDikeTopRiver] " + + "AND NEW.[MinimumLevelPhreaticLineAtDikeTopPolder] IS OLD.[MinimumLevelPhreaticLineAtDikeTopPolder] " + + "AND NEW.[AdjustPhreaticLine3And4ForUplift] = OLD.[AdjustPhreaticLine3And4ForUplift] " + + "AND NEW.[LeakageLengthOutwardsPhreaticLine3] IS OLD.[LeakageLengthOutwardsPhreaticLine3] " + + "AND NEW.[LeakageLengthInwardsPhreaticLine3] IS OLD.[LeakageLengthInwardsPhreaticLine3] " + + "AND NEW.[LeakageLengthOutwardsPhreaticLine4] IS OLD.[LeakageLengthOutwardsPhreaticLine4] " + + "AND NEW.[LeakageLengthInwardsPhreaticLine4] IS OLD.[LeakageLengthInwardsPhreaticLine4] " + + "AND NEW.[PiezometricHeadPhreaticLine2Outwards] IS OLD.[PiezometricHeadPhreaticLine2Outwards] " + + "AND NEW.[PiezometricHeadPhreaticLine2Inwards] IS OLD.[PiezometricHeadPhreaticLine2Inwards] " + + "AND NEW.[LocationInputExtremeWaterLevelPolder] IS OLD.[LocationInputExtremeWaterLevelPolder] " + + "AND NEW.[LocationInputExtremeUseDefaultOffsets] = OLD.[LocationInputExtremeUseDefaultOffsets] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetDikeToeAtPolder] IS OLD.[LocationInputExtremePhreaticLineOffsetDikeToeAtPolder] " + + "AND NEW.[LocationInputExtremePenetrationLength] IS OLD.[LocationInputExtremePenetrationLength] " + + "AND NEW.[LocationInputDailyWaterLevelPolder] IS OLD.[LocationInputDailyWaterLevelPolder] " + + "AND NEW.[LocationInputDailyUseDefaultOffsets] = OLD.[LocationInputDailyUseDefaultOffsets] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetDikeToeAtPolder] IS OLD.[LocationInputDailyPhreaticLineOffsetDikeToeAtPolder] " + + "AND NEW.[CreateZones] = OLD.[CreateZones] " + + "AND NEW.[ZoningBoundariesDeterminationType] = OLD.[ZoningBoundariesDeterminationType] " + + "AND NEW.[ZoneBoundaryLeft] IS OLD.[ZoneBoundaryLeft] " + + "AND NEW.[ZoneBoundaryRight] IS OLD.[ZoneBoundaryRight]; " + + "DETACH SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateCalculationWithScenarioContributionAboveOne); + + string validateCalculationWithValidScenarioContribution = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = " + + "(" + + "SELECT COUNT() " + + "FROM [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity " + + "WHERE ScenarioContribution >= 0 " + + "AND ScenarioContribution <= 1 " + + ")" + + "FROM MacroStabilityInwardsCalculationEntity NEW " + + "JOIN [SOURCEPROJECT].MacroStabilityInwardsCalculationEntity OLD USING(MacroStabilityInwardsCalculationEntityId) " + + "WHERE NEW.[MacroStabilityInwardsCalculationEntityId] = OLD.[MacroStabilityInwardsCalculationEntityId] " + + "AND NEW.[CalculationGroupEntityId] = OLD.[CalculationGroupEntityId] " + + "AND NEW.[SurfaceLineEntityId] IS OLD.[SurfaceLineEntityId] " + + "AND NEW.[MacroStabilityInwardsStochasticSoilProfileEntityId] IS OLD.[MacroStabilityInwardsStochasticSoilProfileEntityId] " + + "AND NEW.[HydraulicLocationEntityId] IS OLD.[HydraulicLocationEntityId] " + + "AND NEW.[Order] = OLD.[Order] " + + "AND NEW.[Name] IS OLD.[Name] " + + "AND NEW.[Comment] IS OLD.[Comment] " + + "AND NEW.[RelevantForScenario] = OLD.[RelevantForScenario] " + + "AND NEW.[ScenarioContribution] = OLD.[ScenarioContribution] " + + "AND NEW.[AssessmentLevel] IS OLD.[AssessmentLevel] " + + "AND NEW.[UseAssessmentLevelManualInput] = OLD.[UseAssessmentLevelManualInput] " + + "AND NEW.[SlipPlaneMinimumDepth] IS OLD.[SlipPlaneMinimumDepth] " + + "AND NEW.[SlipPlaneMinimumLength] IS OLD.[SlipPlaneMinimumLength] " + + "AND NEW.[MaximumSliceWidth] IS OLD.[MaximumSliceWidth] " + + "AND NEW.[MoveGrid] = OLD.[MoveGrid] " + + "AND NEW.[GridDeterminationType] = OLD.[GridDeterminationType] " + + "AND NEW.[TangentLineDeterminationType] = OLD.[TangentLineDeterminationType] " + + "AND NEW.[TangentLineZTop] IS OLD.[TangentLineZTop] " + + "AND NEW.[TangentLineZBottom] IS OLD.[TangentLineZBottom] " + + "AND NEW.[TangentLineNumber] = OLD.[TangentLineNumber] " + + "AND NEW.[LeftGridXLeft] IS OLD.[LeftGridXLeft] " + + "AND NEW.[LeftGridXRight] IS OLD.[LeftGridXRight] " + + "AND NEW.[LeftGridNrOfHorizontalPoints] = OLD.[LeftGridNrOfHorizontalPoints] " + + "AND NEW.[LeftGridZTop] IS OLD.[LeftGridZTop] " + + "AND NEW.[LeftGridZBottom] IS OLD.[LeftGridZBottom] " + + "AND NEW.[LeftGridNrOfVerticalPoints] = OLD.[LeftGridNrOfVerticalPoints] " + + "AND NEW.[RightGridXLeft] IS OLD.[RightGridXLeft] " + + "AND NEW.[RightGridXRight] IS OLD.[RightGridXRight] " + + "AND NEW.[RightGridNrOfHorizontalPoints] = OLD.[RightGridNrOfHorizontalPoints] " + + "AND NEW.[RightGridZTop] IS OLD.[RightGridZTop] " + + "AND NEW.[RightGridZBottom] IS OLD.[RightGridZBottom] " + + "AND NEW.[RightGridNrOfVerticalPoints] = OLD.[RightGridNrOfVerticalPoints] " + + "AND NEW.[DikeSoilScenario] = OLD.[DikeSoilScenario] " + + "AND NEW.[WaterLevelRiverAverage] IS OLD.[WaterLevelRiverAverage] " + + "AND NEW.[DrainageConstructionPresent] = OLD.[DrainageConstructionPresent] " + + "AND NEW.[DrainageConstructionCoordinateX] IS OLD.[DrainageConstructionCoordinateX] " + + "AND NEW.[DrainageConstructionCoordinateZ] IS OLD.[DrainageConstructionCoordinateZ] " + + "AND NEW.[MinimumLevelPhreaticLineAtDikeTopRiver] IS OLD.[MinimumLevelPhreaticLineAtDikeTopRiver] " + + "AND NEW.[MinimumLevelPhreaticLineAtDikeTopPolder] IS OLD.[MinimumLevelPhreaticLineAtDikeTopPolder] " + + "AND NEW.[AdjustPhreaticLine3And4ForUplift] = OLD.[AdjustPhreaticLine3And4ForUplift] " + + "AND NEW.[LeakageLengthOutwardsPhreaticLine3] IS OLD.[LeakageLengthOutwardsPhreaticLine3] " + + "AND NEW.[LeakageLengthInwardsPhreaticLine3] IS OLD.[LeakageLengthInwardsPhreaticLine3] " + + "AND NEW.[LeakageLengthOutwardsPhreaticLine4] IS OLD.[LeakageLengthOutwardsPhreaticLine4] " + + "AND NEW.[LeakageLengthInwardsPhreaticLine4] IS OLD.[LeakageLengthInwardsPhreaticLine4] " + + "AND NEW.[PiezometricHeadPhreaticLine2Outwards] IS OLD.[PiezometricHeadPhreaticLine2Outwards] " + + "AND NEW.[PiezometricHeadPhreaticLine2Inwards] IS OLD.[PiezometricHeadPhreaticLine2Inwards] " + + "AND NEW.[LocationInputExtremeWaterLevelPolder] IS OLD.[LocationInputExtremeWaterLevelPolder] " + + "AND NEW.[LocationInputExtremeUseDefaultOffsets] = OLD.[LocationInputExtremeUseDefaultOffsets] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtRiver] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowDikeTopAtPolder] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside] IS OLD.[LocationInputExtremePhreaticLineOffsetBelowShoulderBaseInside] " + + "AND NEW.[LocationInputExtremePhreaticLineOffsetDikeToeAtPolder] IS OLD.[LocationInputExtremePhreaticLineOffsetDikeToeAtPolder] " + + "AND NEW.[LocationInputExtremePenetrationLength] IS OLD.[LocationInputExtremePenetrationLength] " + + "AND NEW.[LocationInputDailyWaterLevelPolder] IS OLD.[LocationInputDailyWaterLevelPolder] " + + "AND NEW.[LocationInputDailyUseDefaultOffsets] = OLD.[LocationInputDailyUseDefaultOffsets] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtRiver] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowDikeTopAtPolder] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside] IS OLD.[LocationInputDailyPhreaticLineOffsetBelowShoulderBaseInside] " + + "AND NEW.[LocationInputDailyPhreaticLineOffsetDikeToeAtPolder] IS OLD.[LocationInputDailyPhreaticLineOffsetDikeToeAtPolder] " + + "AND NEW.[CreateZones] = OLD.[CreateZones] " + + "AND NEW.[ZoningBoundariesDeterminationType] = OLD.[ZoningBoundariesDeterminationType] " + + "AND NEW.[ZoneBoundaryLeft] IS OLD.[ZoneBoundaryLeft] " + + "AND NEW.[ZoneBoundaryRight] IS OLD.[ZoneBoundaryRight]; " + + "DETACH SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateCalculationWithValidScenarioContribution); + } + private static void AssertMacroStabilityInwardsOutput(MigratedDatabaseReader reader) { const string macroStabilityInwardsCalculationOutputEntityTable = @@ -723,12 +980,14 @@ private static void AssertPipingCalculation(MigratedDatabaseReader reader, string sourceFilePath) { - string validateCalculation = + string validateCalculationWithScenarioContributionNullOrBelowZero = $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + "SELECT COUNT() = " + "(" + "SELECT COUNT() " + - "FROM SOURCEPROJECT.PipingCalculationEntity" + + "FROM SOURCEPROJECT.PipingCalculationEntity " + + "WHERE ScenarioContribution IS NULL " + + "OR ScenarioContribution <= 0 " + ") " + "FROM SemiProbabilisticPipingCalculationEntity NEW " + "JOIN SOURCEPROJECT.PipingCalculationEntity OLD " + @@ -747,11 +1006,74 @@ "AND NEW.[DampingFactorExitMean] IS OLD.[DampingFactorExitMean] " + "AND NEW.[DampingFactorExitStandardDeviation] IS OLD.[DampingFactorExitStandardDeviation] " + "AND NEW.[RelevantForScenario] = OLD.[RelevantForScenario] " + - "AND NEW.[ScenarioContribution] IS OLD.[ScenarioContribution] " + + "AND NEW.[ScenarioContribution] = 0 " + "AND NEW.[AssessmentLevel] IS OLD.[AssessmentLevel] " + "AND NEW.[UseAssessmentLevelManualInput] = OLD.[UseAssessmentLevelManualInput]; " + "DETACH SOURCEPROJECT;"; - reader.AssertReturnedDataIsValid(validateCalculation); + reader.AssertReturnedDataIsValid(validateCalculationWithScenarioContributionNullOrBelowZero); + + string validateCalculationWithScenarioContributionAboveOne = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = " + + "(" + + "SELECT COUNT() " + + "FROM SOURCEPROJECT.PipingCalculationEntity " + + "WHERE ScenarioContribution >= 1 " + + ") " + + "FROM SemiProbabilisticPipingCalculationEntity NEW " + + "JOIN SOURCEPROJECT.PipingCalculationEntity OLD " + + "ON NEW.[SemiProbabilisticPipingCalculationEntityId] = OLD.[PipingCalculationEntityId]" + + "WHERE NEW.[CalculationGroupEntityId] = OLD.[CalculationGroupEntityId] " + + "AND NEW.[SurfaceLineEntityId] IS OLD.[SurfaceLineEntityId] " + + "AND NEW.[PipingStochasticSoilProfileEntityId] IS OLD.[PipingStochasticSoilProfileEntityId] " + + "AND NEW.[HydraulicLocationEntityId] IS OLD.[HydraulicLocationEntityId] " + + "AND NEW.\"Order\" = OLD.\"Order\" " + + "AND NEW.[Name] IS OLD.[Name] " + + "AND NEW.[Comments] IS OLD.[Comments] " + + "AND NEW.[EntryPointL] IS OLD.[EntryPointL] " + + "AND NEW.[ExitPointL] IS OLD.[ExitPointL] " + + "AND NEW.[PhreaticLevelExitMean] IS OLD.[PhreaticLevelExitMean] " + + "AND NEW.[PhreaticLevelExitStandardDeviation] IS OLD.[PhreaticLevelExitStandardDeviation] " + + "AND NEW.[DampingFactorExitMean] IS OLD.[DampingFactorExitMean] " + + "AND NEW.[DampingFactorExitStandardDeviation] IS OLD.[DampingFactorExitStandardDeviation] " + + "AND NEW.[RelevantForScenario] = OLD.[RelevantForScenario] " + + "AND NEW.[ScenarioContribution] = 1 " + + "AND NEW.[AssessmentLevel] IS OLD.[AssessmentLevel] " + + "AND NEW.[UseAssessmentLevelManualInput] = OLD.[UseAssessmentLevelManualInput]; " + + "DETACH SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateCalculationWithScenarioContributionAboveOne); + + string validateCalculationWithValidScenarioContribution = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = " + + "(" + + "SELECT COUNT() " + + "FROM SOURCEPROJECT.PipingCalculationEntity " + + "WHERE ScenarioContribution >= 0 " + + "AND ScenarioContribution <= 1 " + + ") " + + "FROM SemiProbabilisticPipingCalculationEntity NEW " + + "JOIN SOURCEPROJECT.PipingCalculationEntity OLD " + + "ON NEW.[SemiProbabilisticPipingCalculationEntityId] = OLD.[PipingCalculationEntityId]" + + "WHERE NEW.[CalculationGroupEntityId] = OLD.[CalculationGroupEntityId] " + + "AND NEW.[SurfaceLineEntityId] IS OLD.[SurfaceLineEntityId] " + + "AND NEW.[PipingStochasticSoilProfileEntityId] IS OLD.[PipingStochasticSoilProfileEntityId] " + + "AND NEW.[HydraulicLocationEntityId] IS OLD.[HydraulicLocationEntityId] " + + "AND NEW.\"Order\" = OLD.\"Order\" " + + "AND NEW.[Name] IS OLD.[Name] " + + "AND NEW.[Comments] IS OLD.[Comments] " + + "AND NEW.[EntryPointL] IS OLD.[EntryPointL] " + + "AND NEW.[ExitPointL] IS OLD.[ExitPointL] " + + "AND NEW.[PhreaticLevelExitMean] IS OLD.[PhreaticLevelExitMean] " + + "AND NEW.[PhreaticLevelExitStandardDeviation] IS OLD.[PhreaticLevelExitStandardDeviation] " + + "AND NEW.[DampingFactorExitMean] IS OLD.[DampingFactorExitMean] " + + "AND NEW.[DampingFactorExitStandardDeviation] IS OLD.[DampingFactorExitStandardDeviation] " + + "AND NEW.[RelevantForScenario] = OLD.[RelevantForScenario] " + + "AND NEW.[ScenarioContribution] = OLD.[ScenarioContribution] " + + "AND NEW.[AssessmentLevel] IS OLD.[AssessmentLevel] " + + "AND NEW.[UseAssessmentLevelManualInput] = OLD.[UseAssessmentLevelManualInput]; " + + "DETACH SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateCalculationWithValidScenarioContribution); } private static void AssertPipingOutput(MigratedDatabaseReader reader, string sourceFilePath) @@ -951,20 +1273,24 @@ reader.AssertReturnedDataIsValid(validateForeignKeys); } - private static void AssertLogDatabase(string logFilePath, string expectedMessage) + private static void AssertLogDatabase(string logFilePath, IEnumerable expectedMessages) { using (var reader = new MigrationLogDatabaseReader(logFilePath)) { ReadOnlyCollection messages = reader.GetMigrationLogMessages(); - Assert.AreEqual(2, messages.Count); + Assert.AreEqual(expectedMessages.Count() + 1, messages.Count); var i = 0; MigrationLogTestHelper.AssertMigrationLogMessageEqual( new MigrationLogMessage("19.1", newVersion, "Gevolgen van de migratie van versie 19.1 naar versie 20.1:"), messages[i++]); - MigrationLogTestHelper.AssertMigrationLogMessageEqual( - new MigrationLogMessage("19.1", newVersion, $"* {expectedMessage}"), - messages[i]); + + foreach (string expectedMessage in expectedMessages) + { + MigrationLogTestHelper.AssertMigrationLogMessageEqual( + new MigrationLogMessage("19.1", newVersion, $"* {expectedMessage}"), + messages[i++]); + } } } }