Index: DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/OperationalStabilityProfile1DTests.cs =================================================================== diff -u -r5998 -r6031 --- DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/OperationalStabilityProfile1DTests.cs (.../OperationalStabilityProfile1DTests.cs) (revision 5998) +++ DamEngine/trunk/src/Deltares.DamEngine.IntegrationTests/IntegrationTests/OperationalStabilityProfile1DTests.cs (.../OperationalStabilityProfile1DTests.cs) (revision 6031) @@ -126,7 +126,7 @@ }, new Point2DType { - // sensor 'PB01786' + // 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 }, @@ -136,7 +136,6 @@ 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"); @@ -243,14 +242,14 @@ // 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 pl1Points, - PlLinePoints pl3Points, - PlLinePoints pl4Points) + public void GivenStabilityInsideProfile1DProject_WhenCalculatingWithVariationsOnSpecifiedSensorLocationData_ThenExpectedResultIsGenerated(SensorConfiguration sensorConfiguration, + PlLinePoints pl1Points, + PlLinePoints pl3Points, + PlLinePoints pl4Points) { var projectPath = "SensorProfile1DTests"; string testCaseName = TestContext.CurrentContext.Test.Name; - string calcDir = $"DAMLive.Calc.{testCaseName}"; + var calcDir = $"DAMLive.Calc.{testCaseName}"; const string testFilesLocation = @".\TestFiles\Operational\SensorProfile1DTests\"; string inputFilename = testFilesLocation + "CalculateStabilityInsideBishopGrid1InputFile.xml"; string outputFilename = testFilesLocation + "CalculateStabilityInsideBishopGrid1OutputFile.xml"; @@ -279,41 +278,15 @@ 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; + 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?.Length > 1) ? waternet.HeadLines[1]?.WaternetLine.Points.ToList(): null; + List pl4 = waternet.HeadLines?.Length > 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); + Assert.That(arePointsInLine, Is.True, assertMessage); } - private static bool ArePointsInLine(PlLinePoints pointsToFind, List line, string lineName, List messages) - { - const double tolerance = 0.0005; - if (pointsToFind == null) - { - 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)] // Following testcase based on the DamLive test Deltares.DamLive.Tests.StabilityInsideBishopGridTest // "Deltares.DamLive.Tests\TestData\IntegrationTests\StabilityInsideBishopGrid\DAMLive.damx" @@ -404,6 +377,35 @@ CompareOutput(expectedOutput, actualOutput); } + private static bool ArePointsInLine(PlLinePoints pointsToFind, List line, string lineName, List messages) + { + const double tolerance = 0.0005; + if (pointsToFind == null) + { + return true; + } + + var 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; + } + public class SensorConfiguration { public uint SourceTypePl1OuterWaterLevel { get; set; } = sourceTypeSensor;