Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSurfaceLineTest.cs =================================================================== diff -u -red125eab861825fb053bf64259d38f33599087a9 -r9b791eb0a5c7d9bf4842ac9c79d4acb31bf69612 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSurfaceLineTest.cs (.../MacroStabilityInwardsSurfaceLineTest.cs) (revision ed125eab861825fb053bf64259d38f33599087a9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSurfaceLineTest.cs (.../MacroStabilityInwardsSurfaceLineTest.cs) (revision 9b791eb0a5c7d9bf4842ac9c79d4acb31bf69612) @@ -22,13 +22,11 @@ using System; using System.Collections.Generic; using System.Linq; -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using Core.Common.Utils; using NUnit.Framework; using Ringtoets.Common.Data; -using Ringtoets.Common.Data.Exceptions; namespace Ringtoets.MacroStabilityInwards.Primitives.Test { @@ -46,207 +44,6 @@ } [Test] - public void GetZAtL_GeometryIsEmpty_ThrowsInvalidOperationException() - { - // Setup - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - var l = (RoundedDouble) new Random(21).NextDouble(); - - // Call - TestDelegate test = () => surfaceLine.GetZAtL(l); - - // Assert - string exceptionMessage = Assert.Throws(test).Message; - Assert.AreEqual("De profielschematisatie heeft geen geometrie.", exceptionMessage); - } - - [Test] - public void GetZAtL_SurfaceLineContainsPointAtL_ReturnsZOfPoint() - { - // Setup - double testZ = new Random(22).NextDouble(); - - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - var l = (RoundedDouble) 2.0; - surfaceLine.SetGeometry(new[] - { - new Point3D(0.0, 0.0, 2.2), - new Point3D(l, 0.0, testZ), - new Point3D(3.0, 0.0, 7.7) - }); - - // Call - double result = surfaceLine.GetZAtL(l); - - // Assert - Assert.AreEqual(testZ, result, 1e-2); - } - - [Test] - [SetCulture("nl-NL")] - [TestCase(-1)] - [TestCase(-5e-3)] - [TestCase(3.1 + 5e-3)] - [TestCase(4.0)] - public void GetZAtL_SurfaceLineDoesNotContainsPointAtL_ThrowsArgumentOutOfRangeException(double l) - { - // Setup - double testZ = new Random(22).NextDouble(); - - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - surfaceLine.SetGeometry(new[] - { - new Point3D(1.0, 0.0, 2.2), - new Point3D(2.0, 0.0, testZ), - new Point3D(4.1, 0.0, 7.7) - }); - - // Call - TestDelegate test = () => surfaceLine.GetZAtL((RoundedDouble) l); - - // Assert - const string expectedMessage = "Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [0,0, 3,1] liggen."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); - } - - [Test] - public void GetZAtL_SurfaceLineVerticalAtL_ThrowsMechanismSurfaceLineException() - { - // Setup - double testZ = new Random(22).NextDouble(); - - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - var l = (RoundedDouble) 2.0; - surfaceLine.SetGeometry(new[] - { - new Point3D(0.0, 0.0, 2.2), - new Point3D(l, 0.0, testZ), - new Point3D(l, 0.0, testZ + 1), - new Point3D(3.0, 0.0, 7.7) - }); - - // Call - TestDelegate test = () => surfaceLine.GetZAtL(l); - - // Assert - var exception = Assert.Throws(test); - string message = $"Kan geen hoogte bepalen op het punt met de lokale coördinaat {l}, omdat de profielschematisatie verticaal loopt op dat punt."; - Assert.AreEqual(message, exception.Message); - } - - [Test] - public void ToString_ReturnName() - { - // Setup - const string niceName = "Nice name"; - var surfaceLine = new MacroStabilityInwardsSurfaceLine - { - Name = niceName - }; - - // Call - string text = surfaceLine.ToString(); - - // Assert - Assert.AreEqual(niceName, text); - } - - [Test] - [TestCase(5.0)] - [TestCase(1.375)] - [TestCase(-0.005)] - [TestCase(-5)] - public void ValidateInRange_PointNotInRange_ReturnsFalse(double invalidValue) - { - // Setup - const double testX = 1.0; - const double testY = 2.2; - const double testZ = 4.4; - var testPoint = new Point3D(testX, testY, testZ); - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - CreateTestGeometry(testPoint, surfaceLine); - - // Call - bool valid = surfaceLine.ValidateInRange(invalidValue); - - // Assert - Assert.IsFalse(valid); - } - - [Test] - [TestCase(-0e-3)] - [TestCase(1.37)] - [TestCase(1.0)] - public void ValidateInRange_PointInRange_ReturnsTrue(double validValue) - { - // Setup - const double testX = 1.0; - const double testY = 2.2; - const double testZ = 4.4; - var testPoint = new Point3D(testX, testY, testZ); - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - CreateTestGeometry(testPoint, surfaceLine); - - // Call - bool valid = surfaceLine.ValidateInRange(validValue); - - // Assert - Assert.IsTrue(valid); - } - - [Test] - public void GetLocalPointFromGeometry_ValidSurfaceLine_ReturnsLocalPoint() - { - // Setup - const double testX = 1.0; - const double testY = 2.2; - const double testZ = 4.4; - var testPoint = new Point3D(testX, testY, testZ); - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - CreateTestGeometry(testPoint, surfaceLine); - - // Call - Point2D localPoint = surfaceLine.GetLocalPointFromGeometry(testPoint); - - // Assert - Assert.AreEqual(new Point2D(0.04, 4.4), localPoint); - } - - [Test] - public void GetLocalPointFromGeometry_NoPointsOnSurfaceLine_ReturnsPointWithNanValues() - { - // Setup - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - - // Call - Point2D localPoint = surfaceLine.GetLocalPointFromGeometry(new Point3D(1.0, 2.2, 4.4)); - - // Assert - Assert.AreEqual(new Point2D(double.NaN, double.NaN), localPoint); - } - - [Test] - public void GetLocalPointFromGeometry_OnePointOnSurfaceLine_ReturnsPointWithNanValues() - { - // Setup - const double testX = 1.0; - const double testY = 2.2; - const double testZ = 4.4; - var testPoint = new Point3D(testX, testY, testZ); - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); - surfaceLine.SetGeometry(new[] - { - testPoint - }); - - // Call - Point2D localPoint = surfaceLine.GetLocalPointFromGeometry(testPoint); - - // Assert - Assert.AreEqual(new Point2D(double.NaN, double.NaN), localPoint); - } - - [Test] public void CopyProperties_WithSurfaceLineNull_ThrowsArgumentNullException() { // Setup