Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SurfaceLineEntityReadExtensionsTest.cs =================================================================== diff -u -r39e941a3f116d264000cd6f46a61f64674063933 -r7f82fd637dc8796f3d270cb0fa6d9ab18548c6f4 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SurfaceLineEntityReadExtensionsTest.cs (.../SurfaceLineEntityReadExtensionsTest.cs) (revision 39e941a3f116d264000cd6f46a61f64674063933) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SurfaceLineEntityReadExtensionsTest.cs (.../SurfaceLineEntityReadExtensionsTest.cs) (revision 7f82fd637dc8796f3d270cb0fa6d9ab18548c6f4) @@ -20,11 +20,13 @@ // All rights reserved. using System; +using System.ComponentModel; using System.Linq; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Read; using Application.Ringtoets.Storage.Serializers; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Primitives; using Ringtoets.Piping.Primitives; @@ -297,6 +299,39 @@ } [Test] + public void ReadAsPipingSurfaceLine_WithInvalidPipingCharacteristicPointType_ThrowsInvalidEnumArgumentException() + { + // Setup + var random = new Random(31); + + var points = new[] + { + CreatePoint3D(random) + }; + + const byte invalidCharacteristicPointType = 37; + var entity = new SurfaceLineEntity + { + Name = "Better name.", + ReferenceLineIntersectionX = random.NextDouble(), + ReferenceLineIntersectionY = random.NextDouble(), + PointsXml = new Point3DXmlSerializer().ToXml(points), + PipingCharacteristicPointEntities = + { + CreatePipingCharacteristicPointEntity(points[0], (PipingCharacteristicPointType) invalidCharacteristicPointType) + } + }; + + // Call + TestDelegate call = () => entity.ReadAsPipingSurfaceLine(new ReadConversionCollector()); + + // Assert + string exoectedMessage = $"The value of argument 'type' ({invalidCharacteristicPointType}) is invalid for Enum type '{nameof(PipingCharacteristicPointType)}'."; + string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, exoectedMessage).ParamName; + Assert.AreEqual("type", parameterName); + } + + [Test] public void ReadAsPipingSurfaceLine_SurfaceLineEntityReadMultipleTimes_ReturnSameSurfaceLine() { // Setup @@ -618,6 +653,39 @@ } [Test] + public void ReadAsMacroStabilityInwardsSurfaceLine_WithInvalidMacroStabilityCharacteristicPointType_ThrowsInvalidEnumArgumentException() + { + // Setup + var random = new Random(31); + + var points = new[] + { + CreatePoint3D(random) + }; + + const byte invalidCharacteristicPointType = 37; + var entity = new SurfaceLineEntity + { + Name = "Better name.", + ReferenceLineIntersectionX = random.NextDouble(), + ReferenceLineIntersectionY = random.NextDouble(), + PointsXml = new Point3DXmlSerializer().ToXml(points), + MacroStabilityInwardsCharacteristicPointEntities = + { + CreateMacroStabilityInwardsCharacteristicPointEntity(points[0], (MacroStabilityInwardsCharacteristicPointType) invalidCharacteristicPointType) + } + }; + + // Call + TestDelegate call = () => entity.ReadAsMacroStabilityInwardsSurfaceLine(new ReadConversionCollector()); + + // Assert + string exoectedMessage = $"The value of argument 'type' ({invalidCharacteristicPointType}) is invalid for Enum type '{nameof(MacroStabilityInwardsCharacteristicPointType)}'."; + string parameterName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, exoectedMessage).ParamName; + Assert.AreEqual("type", parameterName); + } + + [Test] public void ReadAsMacroStabilityInwardsSurfaceLine_SurfaceLineEntityReadMultipleTimes_ReturnSameSurfaceLine() { // Setup