// Copyright (C) Stichting Deltares 2021. All rights reserved.
//
// This file is part of the Dam Engine.
//
// The Dam Engine is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using Deltares.DamEngine.Calculators.DikesDesign;
using Deltares.DamEngine.Data.General;
using Deltares.DamEngine.Data.Geometry;
using Deltares.DamEngine.Data.Geotechnics;
using NUnit.Framework;
namespace Deltares.DamEngine.Calculators.Tests.DikesDesign
{
[TestFixture]
public class SurfaceLineAdapterTest
{
private readonly Location location = new Location();
[TearDown]
public void TestFixtureTearDown()
{
}
[Test]
public void ThrowsAnExceptionWhenSurfaceLineIsNull()
{
Assert.That(() => new StubSurfaceLineAdapter(null, location, 0), Throws.InstanceOf());
}
[Test]
public void ThrowsAnExceptionWhenSurfaceLineHasNoDike()
{
var surfaceLine = new SurfaceLine2
{
CharacteristicPoints =
{
GeometryMustContainPoint = true
},
Geometry = new GeometryPointString()
};
surfaceLine.EnsurePoint(0, 0);
surfaceLine.EnsurePoint(1, 0);
surfaceLine.EnsurePoint(2, 0);
surfaceLine.EnsurePoint(3, 0);
Assert.That(() => new StubSurfaceLineAdapter(surfaceLine, location, 0), Throws.InstanceOf());
}
[Test]
public void ThrowsAnExceptionWhenSurfaceLineDoesNotComplyToSpecificationUsingZeroCoordValues()
{
var surfaceLine1 = new SurfaceLine2
{
CharacteristicPoints =
{
GeometryMustContainPoint = true
},
Geometry = new GeometryPointString()
};
surfaceLine1.EnsurePointOfType(0, 0, CharacteristicPointType.DikeToeAtRiver);
surfaceLine1.EnsurePointOfType(0, 0, CharacteristicPointType.DikeTopAtRiver);
surfaceLine1.EnsurePointOfType(0, 0, CharacteristicPointType.DikeTopAtPolder);
surfaceLine1.EnsurePointOfType(0, 0, CharacteristicPointType.DikeToeAtPolder);
Assert.That(() => new StubSurfaceLineAdapter(surfaceLine1, location, 0), Throws.InstanceOf());
}
[Test]
public void ThrowsAnExceptionWhenSurfaceLineDoesNotComplyToSpecificationUsingAskewDikeTop()
{
var surfaceLine1 = new SurfaceLine2
{
CharacteristicPoints =
{
GeometryMustContainPoint = true
},
Geometry = new GeometryPointString()
};
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);
Assert.That(() => new StubSurfaceLineAdapter(surfaceLine1, location, 0), Throws.InstanceOf());
}
[Test]
public void ThrowsAnExceptionWhenSurfaceLineDoesNotComplyToSpecificationUsingAskewTopShoulderInside()
{
var surfaceLine1 = new SurfaceLine2
{
CharacteristicPoints =
{
GeometryMustContainPoint = true
},
Geometry = new GeometryPointString()
};
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);
Assert.That(() => new StubSurfaceLineAdapter(surfaceLine1, location, 0), Throws.InstanceOf());
}
class StubSurfaceLineAdapter : SurfaceLineAdapter
{
public StubSurfaceLineAdapter(SurfaceLine2 surfaceLine, Location location, double scenarioPolderLevel)
: base(surfaceLine, location, scenarioPolderLevel)
{
}
}
}
}