Index: Ringtoets/Common/src/Ringtoets.Common.IO/SurfaceLines/SurfaceLineExtensions.cs =================================================================== diff -u -r8e717411be3a9f6947737321832ec2ffe06f43dd -rfc91936524e52aeab541d4e72d15c5ff7832fee5 --- Ringtoets/Common/src/Ringtoets.Common.IO/SurfaceLines/SurfaceLineExtensions.cs (.../SurfaceLineExtensions.cs) (revision 8e717411be3a9f6947737321832ec2ffe06f43dd) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SurfaceLines/SurfaceLineExtensions.cs (.../SurfaceLineExtensions.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) @@ -23,7 +23,6 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Base.Geometry; -using log4net; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.IO.Properties; @@ -34,8 +33,6 @@ /// public static class SurfaceLineExtensions { - private static readonly ILog log = LogManager.GetLogger(typeof(SurfaceLineExtensions)); - /// /// The type of the intersection possible with a reference line. /// @@ -55,7 +52,7 @@ /// A new with a type of intersection and /// possibly an intersection point, if there was only one found. /// Thrown when any parameter is null. - public static ReferenceLineIntersectionResult CheckReferenceLineInterSections(this SurfaceLine surfaceLine, ReferenceLine referenceLine) + public static Point2D GetSingleReferenceLineInterSection(this SurfaceLine surfaceLine, ReferenceLine referenceLine) { if (surfaceLine == null) { @@ -65,20 +62,23 @@ { throw new ArgumentNullException(nameof(referenceLine)); } + ReferenceLineIntersectionResult result = GetReferenceLineIntersections(referenceLine, surfaceLine); if (result.TypeOfIntersection == ReferenceLineIntersectionsResult.NoIntersections) { - log.ErrorFormat(Resources.SurfaceLineExtensions_CheckReferenceLineInterSections_Surfaceline_0_does_not_correspond_to_current_referenceline_1_, - surfaceLine.Name, - Resources.SurfaceLineExtensions_CheckReferenceLineInterSections_This_could_be_caused_coordinates_being_local_coordinate_system); + string message = string.Format(Resources.SurfaceLineExtensions_CheckReferenceLineInterSections_Surfaceline_0_does_not_correspond_to_current_referenceline_1_, + surfaceLine.Name, + Resources.SurfaceLineExtensions_CheckReferenceLineInterSections_This_could_be_caused_coordinates_being_local_coordinate_system); + throw new SurfaceLineTransformException(message); } if (result.TypeOfIntersection == ReferenceLineIntersectionsResult.MultipleIntersectionsOrOverlap) { - log.ErrorFormat(Resources.SurfaceLineExtensions_CheckReferenceLineInterSections_Surfaceline_0_does_not_correspond_to_current_referenceline, surfaceLine.Name); + string message = string.Format(Resources.SurfaceLineExtensions_CheckReferenceLineInterSections_Surfaceline_0_does_not_correspond_to_current_referenceline, surfaceLine.Name); + throw new SurfaceLineTransformException(message); } - return result; + return result.IntersectionPoint; } private static ReferenceLineIntersectionResult GetReferenceLineIntersections(ReferenceLine referenceLine, SurfaceLine surfaceLine) Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SurfaceLines/SurfaceLineExtensionsTest.cs =================================================================== diff -u -r8e717411be3a9f6947737321832ec2ffe06f43dd -rfc91936524e52aeab541d4e72d15c5ff7832fee5 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SurfaceLines/SurfaceLineExtensionsTest.cs (.../SurfaceLineExtensionsTest.cs) (revision 8e717411be3a9f6947737321832ec2ffe06f43dd) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SurfaceLines/SurfaceLineExtensionsTest.cs (.../SurfaceLineExtensionsTest.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) @@ -35,7 +35,7 @@ public void CheckReferenceLineInterSections_WithoutSurfaceLine_ThrowsArgumentNullException() { // Call - TestDelegate test = () => ((SurfaceLine)null).CheckReferenceLineInterSections(new ReferenceLine()); + TestDelegate test = () => ((SurfaceLine) null).GetSingleReferenceLineInterSection(new ReferenceLine()); // Assert var exception = Assert.Throws(test); @@ -46,7 +46,7 @@ public void CheckReferenceLineInterSections_WithoutReferenceLine_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new SurfaceLine().CheckReferenceLineInterSections(null); + TestDelegate test = () => new SurfaceLine().GetSingleReferenceLineInterSection(null); // Assert var exception = Assert.Throws(test); @@ -75,18 +75,15 @@ new Point2D(4.0, 4.5) }); - SurfaceLineExtensions.ReferenceLineIntersectionResult result = null; - // Call - result = surfaceLine.CheckReferenceLineInterSections(referenceLine); + Point2D result = surfaceLine.GetSingleReferenceLineInterSection(referenceLine); // Assert - Assert.AreEqual(SurfaceLineExtensions.ReferenceLineIntersectionsResult.OneIntersection, result.TypeOfIntersection); - Assert.AreEqual(new Point2D(3.0, 4.5), result.IntersectionPoint); + Assert.AreEqual(new Point2D(3.0, 4.5), result); } [Test] - public void CheckReferenceLineInterSections_SurfaceLineNotOnReferenceLine_LogErrorAndReturnResultWithIntersectionPointNull() + public void CheckReferenceLineInterSections_SurfaceLineNotOnReferenceLine_ThrowSurfaceLineTransformerException() { // Setup var referenceLine = new ReferenceLine(); @@ -106,20 +103,17 @@ new Point2D(2.0, 4.0) }); - SurfaceLineExtensions.ReferenceLineIntersectionResult result = null; - // Call - Action call = () => result = surfaceLine.CheckReferenceLineInterSections(referenceLine); + TestDelegate test = () => surfaceLine.GetSingleReferenceLineInterSection(referenceLine); // Assert string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd. Dit kan komen doordat de profielschematisatie een lokaal coördinaatsysteem heeft."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(message, LogLevelConstant.Error)); - Assert.AreEqual(SurfaceLineExtensions.ReferenceLineIntersectionsResult.NoIntersections, result.TypeOfIntersection); - Assert.IsNull(result.IntersectionPoint); + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); } [Test] - public void CheckReferenceLineInterSections_SurfaceLineIntersectsReferenceLineMultipleTimes_LogErrorAndReturnResultWithIntersectionPointNull() + public void CheckReferenceLineInterSections_SurfaceLineIntersectsReferenceLineMultipleTimes_ThrowSurfaceLineTransformerException() { // Setup var referenceLine = new ReferenceLine(); @@ -141,16 +135,13 @@ new Point2D(0.0, 4.0) }); - SurfaceLineExtensions.ReferenceLineIntersectionResult result = null; - // Call - Action call = () => result = surfaceLine.CheckReferenceLineInterSections(referenceLine); + TestDelegate test = () => surfaceLine.GetSingleReferenceLineInterSection(referenceLine); // Assert string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(message, LogLevelConstant.Error)); - Assert.AreEqual(SurfaceLineExtensions.ReferenceLineIntersectionsResult.MultipleIntersectionsOrOverlap, result.TypeOfIntersection); - Assert.IsNull(result.IntersectionPoint); + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Importers/MacroStabilityInwardsSurfaceLineTransformer.cs =================================================================== diff -u -r683ff9234262d9fa3bea5edc0abe35254f80e49d -rfc91936524e52aeab541d4e72d15c5ff7832fee5 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Importers/MacroStabilityInwardsSurfaceLineTransformer.cs (.../MacroStabilityInwardsSurfaceLineTransformer.cs) (revision 683ff9234262d9fa3bea5edc0abe35254f80e49d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Importers/MacroStabilityInwardsSurfaceLineTransformer.cs (.../MacroStabilityInwardsSurfaceLineTransformer.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) @@ -20,14 +20,11 @@ // All rights reserved. using System; -using log4net; +using Core.Common.Base.Geometry; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.MacroStabilityInwards.Primitives; -using ReferenceLineIntersectionsResult = Ringtoets.Common.IO.SurfaceLines.SurfaceLineExtensions.ReferenceLineIntersectionsResult; -using ReferenceLineIntersectionResult = Ringtoets.Common.IO.SurfaceLines.SurfaceLineExtensions.ReferenceLineIntersectionResult; - namespace Ringtoets.MacroStabilityInwards.IO.Importers { /// @@ -53,13 +50,8 @@ public RingtoetsMacroStabilityInwardsSurfaceLine Transform(SurfaceLine surfaceLine, CharacteristicPoints characteristicPoints) { - ReferenceLineIntersectionResult result = surfaceLine.CheckReferenceLineInterSections(referenceLine); + Point2D intersectionPoint = surfaceLine.GetSingleReferenceLineInterSection(referenceLine); - if (result.TypeOfIntersection != ReferenceLineIntersectionsResult.OneIntersection) - { - return null; - } - var macroStabilityInwardsSurfaceLine = new RingtoetsMacroStabilityInwardsSurfaceLine { Name = surfaceLine.Name @@ -68,7 +60,7 @@ macroStabilityInwardsSurfaceLine.SetCharacteristicPoints(characteristicPoints); - macroStabilityInwardsSurfaceLine.ReferenceLineIntersectionWorldPoint = result.IntersectionPoint; + macroStabilityInwardsSurfaceLine.ReferenceLineIntersectionWorldPoint = intersectionPoint; return macroStabilityInwardsSurfaceLine; } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/MacrostabilityInwardsSurfaceLineTransformerTest.cs =================================================================== diff -u -rf5856404ce0793d444cd6dc88ab0aef9922ad39e -rfc91936524e52aeab541d4e72d15c5ff7832fee5 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/MacrostabilityInwardsSurfaceLineTransformerTest.cs (.../MacrostabilityInwardsSurfaceLineTransformerTest.cs) (revision f5856404ce0793d444cd6dc88ab0aef9922ad39e) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Importers/MacrostabilityInwardsSurfaceLineTransformerTest.cs (.../MacrostabilityInwardsSurfaceLineTransformerTest.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) @@ -26,7 +26,6 @@ using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.MacroStabilityInwards.IO.Importers; @@ -148,15 +147,13 @@ new Point2D(2.0, 4.0) }); - IMechanismSurfaceLine result = null; - // Call - Action call = () => result = transformer.Transform(surfaceLine, null); + TestDelegate test = () => transformer.Transform(surfaceLine, null); // Assert string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd. Dit kan komen doordat de profielschematisatie een lokaal coördinaatsysteem heeft."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(message, LogLevelConstant.Error)); - Assert.IsNull(result); + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); } [Test] @@ -183,15 +180,13 @@ new Point2D(0.0, 4.0) }); - IMechanismSurfaceLine result = null; - // Call - Action call = () => result = transformer.Transform(surfaceLine, null); + TestDelegate test = () => transformer.Transform(surfaceLine, null); // Assert string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(message, LogLevelConstant.Error)); - Assert.IsNull(result); + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); } [Test] Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingSurfaceLineTransformer.cs =================================================================== diff -u -r683ff9234262d9fa3bea5edc0abe35254f80e49d -rfc91936524e52aeab541d4e72d15c5ff7832fee5 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingSurfaceLineTransformer.cs (.../PipingSurfaceLineTransformer.cs) (revision 683ff9234262d9fa3bea5edc0abe35254f80e49d) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingSurfaceLineTransformer.cs (.../PipingSurfaceLineTransformer.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) @@ -20,14 +20,12 @@ // All rights reserved. using System; +using Core.Common.Base.Geometry; using log4net; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.IO.SurfaceLines; using Ringtoets.Piping.Primitives; -using ReferenceLineIntersectionsResult = Ringtoets.Common.IO.SurfaceLines.SurfaceLineExtensions.ReferenceLineIntersectionsResult; -using ReferenceLineIntersectionResult = Ringtoets.Common.IO.SurfaceLines.SurfaceLineExtensions.ReferenceLineIntersectionResult; - namespace Ringtoets.Piping.IO.Importers { /// @@ -54,13 +52,8 @@ public RingtoetsPipingSurfaceLine Transform(SurfaceLine surfaceLine, CharacteristicPoints characteristicPoints) { - ReferenceLineIntersectionResult result = surfaceLine.CheckReferenceLineInterSections(referenceLine); + Point2D intersectionPoint = surfaceLine.GetSingleReferenceLineInterSection(referenceLine); - if (result.TypeOfIntersection != ReferenceLineIntersectionsResult.OneIntersection) - { - return null; - } - var pipingSurfaceLine = new RingtoetsPipingSurfaceLine { Name = surfaceLine.Name @@ -69,7 +62,7 @@ pipingSurfaceLine.SetCharacteristicPoints(characteristicPoints); - pipingSurfaceLine.ReferenceLineIntersectionWorldPoint = result.IntersectionPoint; + pipingSurfaceLine.ReferenceLineIntersectionWorldPoint = intersectionPoint; return pipingSurfaceLine; } Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSurfaceLineTransformerTest.cs =================================================================== diff -u -r683ff9234262d9fa3bea5edc0abe35254f80e49d -rfc91936524e52aeab541d4e72d15c5ff7832fee5 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSurfaceLineTransformerTest.cs (.../PipingSurfaceLineTransformerTest.cs) (revision 683ff9234262d9fa3bea5edc0abe35254f80e49d) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingSurfaceLineTransformerTest.cs (.../PipingSurfaceLineTransformerTest.cs) (revision fc91936524e52aeab541d4e72d15c5ff7832fee5) @@ -106,15 +106,13 @@ new Point2D(2.0, 4.0) }); - IMechanismSurfaceLine result = null; - // Call - Action call = () => result = transformer.Transform(surfaceLine, null); + TestDelegate test = () => transformer.Transform(surfaceLine, null); // Assert string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd. Dit kan komen doordat de profielschematisatie een lokaal coördinaatsysteem heeft."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(message, LogLevelConstant.Error)); - Assert.IsNull(result); + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); } [Test] @@ -141,15 +139,13 @@ new Point2D(0.0, 4.0) }); - IMechanismSurfaceLine result = null; - // Call - Action call = () => result = transformer.Transform(surfaceLine, null); + TestDelegate test = () => transformer.Transform(surfaceLine, null); // Assert string message = $"Profielschematisatie {surfaceLineName} doorkruist de huidige referentielijn niet of op meer dan één punt en kan niet worden geïmporteerd."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(message, LogLevelConstant.Error)); - Assert.IsNull(result); + var exception = Assert.Throws(test); + Assert.AreEqual(message, exception.Message); } [Test]