//----------------------------------------------------------------------- // // Copyright (c) 2009 Deltares. All rights reserved. // // B.S.T.I.M. The // tom.the@deltares.nl // 03-12-2009 // Tests for SurfaceLineAdapter //----------------------------------------------------------------------- using Deltares.Geometry; using Deltares.Geotechnics; using Deltares.Geotechnics.GeotechnicalGeometry; using System; using Deltares.Dam.Data; using Deltares.Geotechnics.SurfaceLines; using NUnit.Framework; namespace Deltares.Dam.Tests { [TestFixture] public class SurfaceLineAdapterTest { private readonly Location location = new Location(); [TestFixtureTearDown] public void TestFixtureTearDown() { location.Dispose(); } [Test] [ExpectedException(typeof(ArgumentNullException))] public void ThrowsAnExceptionWhenSurfaceLineIsNull() { new StubSurfaceLineAdapter(null, location); } [Test] [ExpectedException(typeof(SurfaceLineAdapterException))] public void ThrowsAnExceptionWhenSurfaceLineHasNoDike() { using (var surfaceLine = new SurfaceLine2 { CharacteristicPoints = { GeometryMustContainPoint = true }, Geometry = new LocalizedGeometryPointString() }) { surfaceLine.EnsurePoint(0, 0); surfaceLine.EnsurePoint(1, 0); surfaceLine.EnsurePoint(2, 0); surfaceLine.EnsurePoint(3, 0); new StubSurfaceLineAdapter(surfaceLine, location); } } [Test] [ExpectedException(typeof(SurfaceLineAdapterException))] public void ThrowsAnExceptionWhenSurfaceLineDoesNotComplyToSpecificationUsingZeroCoordValues() { using (var surfaceLine1 = new SurfaceLine2 { CharacteristicPoints = { GeometryMustContainPoint = true }, Geometry = new LocalizedGeometryPointString() }) { surfaceLine1.EnsurePointOfType(0, 0, CharacteristicPointType.DikeToeAtRiver); surfaceLine1.EnsurePointOfType(0, 0, CharacteristicPointType.DikeTopAtRiver); surfaceLine1.EnsurePointOfType(0, 0, CharacteristicPointType.DikeTopAtPolder); surfaceLine1.EnsurePointOfType(0, 0, CharacteristicPointType.DikeToeAtPolder); new StubSurfaceLineAdapter(surfaceLine1, location); } } [Test] [ExpectedException(typeof(SurfaceLineAdapterException))] public void ThrowsAnExceptionWhenSurfaceLineDoesNotComplyToSpecificationUsingAskewDikeTop() { using (var surfaceLine1 = new SurfaceLine2 { CharacteristicPoints = { GeometryMustContainPoint = true }, Geometry = new LocalizedGeometryPointString() }) { var p1 = new GeometryPoint(); var p2 = new GeometryPoint() { X = 10, Z = 10 }; var p3 = new GeometryPoint() { X = 15, Z = 15 }; surfaceLine1.EnsurePointOfType(p1.X, p1.Z, CharacteristicPointType.DikeToeAtRiver); surfaceLine1.EnsurePointOfType(p2.X, p2.Z, CharacteristicPointType.DikeTopAtRiver); surfaceLine1.EnsurePointOfType(p3.X, p3.Z, CharacteristicPointType.DikeTopAtPolder); surfaceLine1.EnsurePointOfType(p1.X, p1.Z, CharacteristicPointType.DikeToeAtPolder); new StubSurfaceLineAdapter(surfaceLine1, location); } } [Test] [ExpectedException(typeof(SurfaceLineAdapterException))] public void ThrowsAnExceptionWhenSurfaceLineDoesNotComplyToSpecificationUsingAskewTopShoulderInside() { using (var surfaceLine1 = new SurfaceLine2 { CharacteristicPoints = { GeometryMustContainPoint = true }, Geometry = new LocalizedGeometryPointString() }) { var p1 = new GeometryPoint(); var p2 = new GeometryPoint() { X = 10, Z = 10 }; var p3 = new GeometryPoint() { X = 15, Z = 10 }; var p4 = new GeometryPoint() { X = 17, Z = 8 }; var p5 = new GeometryPoint() { X = 18, Z = 9 }; surfaceLine1.EnsurePointOfType(p1.X, p1.Z, CharacteristicPointType.DikeToeAtRiver); surfaceLine1.EnsurePointOfType(p2.X, p2.Z, CharacteristicPointType.DikeTopAtRiver); surfaceLine1.EnsurePointOfType(p3.X, p3.Z, CharacteristicPointType.DikeTopAtPolder); surfaceLine1.EnsurePointOfType(p4.X, p4.Z, CharacteristicPointType.ShoulderBaseInside); surfaceLine1.EnsurePointOfType(p5.X, p5.Z, CharacteristicPointType.ShoulderTopInside); surfaceLine1.EnsurePointOfType(p1.X, p1.Z, CharacteristicPointType.DikeToeAtPolder); new StubSurfaceLineAdapter(surfaceLine1, location); } } class StubSurfaceLineAdapter : SurfaceLineAdapter { public StubSurfaceLineAdapter(SurfaceLine2 surfaceLine, Location location) : base(surfaceLine, location) { } } } }