Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SurfaceLineEntityReadExtensions.cs =================================================================== diff -u -rac96d7c315129af851634ed5a4a6800b59ede718 -r7f82fd637dc8796f3d270cb0fa6d9ab18548c6f4 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SurfaceLineEntityReadExtensions.cs (.../SurfaceLineEntityReadExtensions.cs) (revision ac96d7c315129af851634ed5a4a6800b59ede718) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SurfaceLineEntityReadExtensions.cs (.../SurfaceLineEntityReadExtensions.cs) (revision 7f82fd637dc8796f3d270cb0fa6d9ab18548c6f4) @@ -48,6 +48,10 @@ /// Thrown when any input parameter is null. /// Thrown when /// of is empty. + /// Thrown when the + /// contains an invalid type of characteristic point. + /// Thrown when the contains a + /// characteristic point that is not supported. public static PipingSurfaceLine ReadAsPipingSurfaceLine(this SurfaceLineEntity entity, ReadConversionCollector collector) { @@ -89,6 +93,10 @@ /// Thrown when any input parameter is null. /// Thrown when /// of is empty. + /// Thrown when the + /// contains an invalid type of characteristic point. + /// Thrown when the contains a + /// characteristic point that is not supported. public static MacroStabilityInwardsSurfaceLine ReadAsMacroStabilityInwardsSurfaceLine( this SurfaceLineEntity entity, ReadConversionCollector collector) @@ -126,6 +134,16 @@ entity.ReferenceLineIntersectionY.ToNullAsNaN()); } + /// + /// Reads the characteristic points from the and sets these + /// to the . + /// + /// The entity to read. + /// The surface line to set the characteristic point on. + /// Thrown when the + /// contains an invalid type of characteristic point. + /// Thrown when the contains a + /// characteristic point that is not supported. private static void ReadCharacteristicPoints(this SurfaceLineEntity entity, PipingSurfaceLine surfaceLine) { var characteristicPoints = new Dictionary(); @@ -139,6 +157,16 @@ characteristicPoints.ForEachElementDo(cp => SetCharacteristicPoint(surfaceLine, cp.Key, cp.Value)); } + /// + /// Reads the characteristic points from the and sets these + /// to the . + /// + /// The entity to read. + /// The surface line to set the characteristic point on. + /// Thrown when the + /// contains an invalid type of characteristic point. + /// Thrown when the contains a + /// characteristic point that is not supported. private static void ReadCharacteristicPoints(this SurfaceLineEntity entity, MacroStabilityInwardsSurfaceLine surfaceLine) { var characteristicPoints = new Dictionary(); @@ -152,10 +180,27 @@ characteristicPoints.ForEachElementDo(cp => SetCharacteristicPoint(surfaceLine, cp.Key, cp.Value)); } + + /// + /// Sets the characteristic point and its coordinate to the . + /// + /// The surface line to set the characteristic point on. + /// The type of characteristic point. + /// The point associated with the characteristic point. + /// Thrown when is not + /// a valid . + /// Thrown when is not supported. private static void SetCharacteristicPoint(PipingSurfaceLine surfaceLine, PipingCharacteristicPointType type, Point3D geometryPoint) { + if (!Enum.IsDefined(typeof(PipingCharacteristicPointType), type)) + { + throw new InvalidEnumArgumentException(nameof(type), + (int) type, + typeof(PipingCharacteristicPointType)); + } + switch (type) { case PipingCharacteristicPointType.DikeToeAtRiver: @@ -177,16 +222,30 @@ surfaceLine.SetDitchPolderSideAt(geometryPoint); break; default: - throw new InvalidEnumArgumentException(nameof(type), - (int) type, - typeof(PipingCharacteristicPointType)); + throw new NotSupportedException($"The enum value {nameof(PipingCharacteristicPointType)}.{type} is not supported."); } } + /// + /// Sets the characteristic point and its coordinate to the . + /// + /// The surface line to set the characteristic point on. + /// The type of characteristic point. + /// The point associated with the characteristic point. + /// Thrown when is not + /// a valid . + /// Thrown when is not supported. private static void SetCharacteristicPoint(MacroStabilityInwardsSurfaceLine surfaceLine, MacroStabilityInwardsCharacteristicPointType type, Point3D geometryPoint) { + if (!Enum.IsDefined(typeof(MacroStabilityInwardsCharacteristicPointType), type)) + { + throw new InvalidEnumArgumentException(nameof(type), + (int) type, + typeof(MacroStabilityInwardsCharacteristicPointType)); + } + switch (type) { case MacroStabilityInwardsCharacteristicPointType.SurfaceLevelOutside: @@ -226,9 +285,7 @@ surfaceLine.SetDitchPolderSideAt(geometryPoint); break; default: - throw new InvalidEnumArgumentException(nameof(type), - (int) type, - typeof(MacroStabilityInwardsCharacteristicPointType)); + throw new NotSupportedException($"The enum value {nameof(MacroStabilityInwardsCharacteristicPointType)}.{type} is not supported."); } }