Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/OperationalStabilityProfile1DTests.cs =================================================================== diff -u -r5984 -r5990 --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/OperationalStabilityProfile1DTests.cs (.../OperationalStabilityProfile1DTests.cs) (revision 5984) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/OperationalStabilityProfile1DTests.cs (.../OperationalStabilityProfile1DTests.cs) (revision 5990) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -71,15 +72,15 @@ SourceTypePl4 = sourceTypeLocationData, HeadPl4 = 0.0 }, - new PlLinePoints + new PlLinePoints // PL-1 { Points = [ new Point2DType { // Pl1Left X = 0.0, // Expected X-value is leftmost point.X - Z = -0.1 // Expected Z-value is the value from location data WaterLevelOutside of 'Purmer_PU0042+00_K': -0.1 + Z = -0.1 // Expected Z-value is the value of location data WaterLevelOutside of 'Purmer_PU0042+00_K': -0.1 }, new Point2DType { @@ -106,7 +107,39 @@ Z = -2.0 // Expected Z-value is location data Polderlevel of 'Purmer_PU0042+00_K': -2.0 } ] - }).SetName("OnlyLocationData"); + }, + new PlLinePoints // PL-3 + { + Points = + [ + new Point2DType + { + // Pl3Left + X = 0.0, // Expected X-value is leftmost point.X + Z = -3.0 // Expected Z-value is the value of location data: -3.0 + }, + new Point2DType + { + // sensor 'PB01786_BuT' + X = 11.468, // Expected X-value is the location of the sensor X = 11.486 + Z = -2.87 // Expected Z-value is the value of the first timestep of the sensor: -2.87 + }, + new Point2DType + { + // sensor 'PB01786' + X = 36.185, // Expected X-value is the location of the sensor X = 36.185 + Z = -2.87 // Expected Z-value is the value of the first timestep of the sensor: -2.87 + }, + new Point2DType + { + // Pl3Right + X = 57.896, // Expected X-value is rightmost point.X: 57.896 + Z = -2.87 // Expected Z-value is the value of the first timestep of the last sensor: -2.87 + } + + ] + }, + null).SetName("OnlyLocationData"); yield return new TestCaseData( // This is the case that all values are taken from the sensor data new SensorConfiguration @@ -169,7 +202,38 @@ Z = -2.0 // Expected Z-value is location data Polderlevel of 'Purmer_PU0042+00_K': -2.0 } ] - }).SetName("OnlySensorData"); + }, + new PlLinePoints // PL-3 + { + Points = + [ + new Point2DType + { + // Pl3Left + X = 0.0, // Expected X-value is leftmost point.X + Z = -0.2 // Expected Z-value is the value of the Waterlevel: -0.2 + }, + new Point2DType + { + // sensor 'PB01786_BuT' + X = 11.468, // Expected X-value is the location of the sensor X = 11.486 + Z = -2.87 // Expected Z-value is the value of the first timestep of the sensor: -2.87 + }, + new Point2DType + { + // sensor 'PB01786' + X = 36.185, // Expected X-value is the location of the sensor X = 36.185 + Z = -2.87 // Expected Z-value is the value of the first timestep of the sensor: -2.87 + }, + new Point2DType + { + // Pl3Right + X = 57.896, // Expected X-value is rightmost point.X: 57.896 + Z = -2.87 // Expected Z-value is the value of the first timestep of the last sensor: -2.87 + } + ] + }, + null).SetName("OnlySensorData"); } } @@ -179,7 +243,10 @@ // This tests if the sensor location data is used in the calculation by changing the source type of Pl1 offset below diketop to [Test] [TestCaseSource(nameof(AddTestCases))] - public void GivenStabilityInsideProfile1DProject_WhenCalculatingWithVariatonsOnSpecifiedSensorLocationData_ThenExpectedResultIsGenerated(SensorConfiguration sensorConfiguration, PlLinePoints plLinePoints) + public void GivenStabilityInsideProfile1DProject_WhenCalculatingWithVariatonsOnSpecifiedSensorLocationData_ThenExpectedResultIsGenerated(SensorConfiguration sensorConfiguration, + PlLinePoints pl1Points, + PlLinePoints pl3Points, + PlLinePoints pl4Points) { var projectPath = "SensorProfile1DTests"; string testCaseName = TestContext.CurrentContext.Test.Name; @@ -204,13 +271,47 @@ // Read the kernel input data from the input file var kernelInputFilename = $"{projectPath}\\{calcDir}\\Stability\\Bishop\\Dik(dike)_Loc(Purmer_PU0042+00_K)_Stp(0)_Mdl(Bishop)_2016-03-02T03_10_00_Pro(Purmer_PU0042+00K).skx"; FullInputModelType expectedMacrostabilityInput = MacroStabilityXmlSerialization.LoadInputFromXmlFile(kernelInputFilename); + + WaternetType waternet = expectedMacrostabilityInput.StabilityModel.ConstructionStages[0].Waternet; + // Check the phreatic line + List phreaticLine = waternet.PhreaticLine.WaternetLine.Points.ToList(); + var messages = new List(); + messages.Add("Failing assertions"); + bool arePointsInLine = ArePointsInLine(pl1Points, phreaticLine, "PL-1", messages); + // PL-3 + List pl3 = waternet.HeadLines.Any() ? waternet.HeadLines[0]?.WaternetLine.Points.ToList(): null; + arePointsInLine = arePointsInLine && ArePointsInLine(pl3Points, pl3, "PL-3", messages); + // PL-4 + List pl4 = (waternet.HeadLines.Count() > 1) ? waternet.HeadLines[1]?.WaternetLine.Points.ToList(): null; + arePointsInLine = arePointsInLine && ArePointsInLine(pl4Points, pl4, "PL-4", messages); + string assertMessage = string.Join(Environment.NewLine, messages); + Assert.That(arePointsInLine, Is.True, assertMessage); + } + + private static bool ArePointsInLine(PlLinePoints pointsToFind, List line, string lineName, List messages) + { const double tolerance = 0.0005; - List phreaticLine = expectedMacrostabilityInput.StabilityModel.ConstructionStages[0].Waternet.PhreaticLine.WaternetLine.Points.ToList(); - foreach (Point2DType point in plLinePoints.Points) + if (pointsToFind == null) { - bool pointExists = phreaticLine.Any(p => p.X.IsNearEqual(point.X, tolerance) && p.Z.IsNearEqual(point.Z, tolerance)); - Assert.That(pointExists, Is.True, $"The expected point x={point.X}, z={point.X} was not found in the phreatic line."); + return true; } + bool arePointsInLine = true; + var missingPoints = new List(); + foreach (Point2DType point in pointsToFind.Points) + { + bool isPointExists = (line != null) && line.Any(p => p.X.IsNearEqual(point.X, tolerance) && p.Z.IsNearEqual(point.Z, tolerance)); + if (!isPointExists) + { + missingPoints.Add($"X: {point.X}, Z: {point.Z}"); + arePointsInLine = false; + } + } + if (!arePointsInLine) + { + messages.Add($"The following points were not found in {lineName}"); + messages.AddRange(missingPoints); + } + return arePointsInLine; } [Test, Category(Categories.Slow)]