// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of the application DAM - UI. // // DAM - UI is free software: you can redistribute it and/or modify // it under the terms of the GNU 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 General Public License for more details. // // You should have received a copy of the GNU 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 Deltares.Geometry; using Deltares.Geotechnics; using Deltares.Geotechnics.GeotechnicalGeometry; using Deltares.Dam.Data; using NUnit.Framework; using System.Linq; using Deltares.Geotechnics.Soils; using Deltares.Geotechnics.SurfaceLines; namespace Deltares.Dam.Tests { [TestFixture] public class DikeTest { private Dike dike; private Dam.Data.Segment segment1; private Location location1; private SurfaceLine2 surfaceLine1; private SoilProfile1D soilProfile; [TestFixtureSetUp] public void TestFixtureSetup() { } [SetUp] public void TestSetup() { // Dike this.dike = new Dike(); this.dike.Name = "Dike"; // Segments this.segment1 = new Segment(); this.segment1.Name = "Segment1"; // this.dike.Segments.Add(this.segment1); // Locations this.location1 = new Location(); this.location1.Name = "Location1"; this.location1.Segment = segment1; this.dike.Locations.Add(location1); // Surface lines surfaceLine1 = new SurfaceLine2 { Geometry = new LocalizedGeometryPointString(), CharacteristicPoints = { GeometryMustContainPoint = true }, Name = "SurfaceLine1" }; this.dike.SurfaceLines2.Add(surfaceLine1); // Soil profiles this.soilProfile = new SoilProfile1D(); this.soilProfile.Name = "SoilProfile1"; this.dike.SoilProfiles.Add(soilProfile); // Locations' Segments this.location1.Segment = segment1; // Locations' surface lines this.location1.SurfaceLine2 = this.surfaceLine1; // Segments' Soil profile probabilities this.segment1.AddSoilProfileProbability(soilProfile, 100.0, FailureMechanismSystemType.StabilityInside); surfaceLine1.AddCharacteristicPoint(new GeometryPoint(15.3, 0.0, -3.52)); surfaceLine1.AddCharacteristicPoint(new GeometryPoint(19.4, 0.0, -1.46), CharacteristicPointType.DikeToeAtRiver); surfaceLine1.AddCharacteristicPoint(new GeometryPoint(27.4, 0.0, 8.56), CharacteristicPointType.DikeTopAtRiver); surfaceLine1.AddCharacteristicPoint(new GeometryPoint(35.2, 0.0, 8.62), CharacteristicPointType.DikeTopAtPolder); surfaceLine1.AddCharacteristicPoint(new GeometryPoint(41.5, 0.0, -3.76), CharacteristicPointType.DikeToeAtPolder); surfaceLine1.AddCharacteristicPoint(new GeometryPoint(85.4, 0.0, -3.61)); } [TearDown] public void TearDown() { dike.Dispose(); } [Test] public void DefaultConstructor_ExpectedValues() { // setup // call using (var newDike = new Dike()) { // assert Assert.AreEqual(0, newDike.SurfaceLines2.Count); Assert.AreEqual(0, newDike.Locations.Count); } } [Test] public void TestDikeIntegrity() { Assert.IsNotNull(this.dike); Assert.AreEqual("Dike", this.dike.Name); //Assert.IsNotNull(this.dike.Segments); Assert.IsNotNull(this.dike.Locations); Assert.IsNotNull(this.dike.SurfaceLines2); Assert.IsNotNull(this.dike.SoilProfiles); } // [Test] // public void TestDikeSegments() // { // Assert.IsNotNull(this.segment1); // // Assert.AreEqual(1, this.dike.Segments.Count); // Assert.AreEqual(this.segment1, this.dike.Segments[0]); // Assert.AreEqual("Segment1", this.segment1.Name); // Assert.IsNotNull(this.segment1.GetMostProbableProfile(SegmentFailureMechanismType.Stability)); // } [Test] public void TestDikeLocations() { Assert.IsNotNull(this.location1); Assert.AreEqual(1, this.dike.Locations.Count); Assert.AreEqual(this.location1, this.dike.Locations[0]); Assert.AreEqual("Location1", this.location1.Name); } [Test] public void TestDikeSurfaceLines() { Assert.IsNotNull(this.surfaceLine1); Assert.IsNotNull(this.surfaceLine1.Geometry.Points); Assert.AreEqual(1, this.dike.SurfaceLines2.Count); Assert.AreEqual(this.surfaceLine1, this.dike.SurfaceLines2[0]); Assert.AreEqual("SurfaceLine1", this.surfaceLine1.Name); } [Test] public void TestDikeSoilProfiles() { Assert.IsNotNull(this.soilProfile); Assert.AreEqual(1, this.dike.SoilProfiles.Count); Assert.AreEqual(this.soilProfile, this.dike.SoilProfiles[0]); Assert.AreEqual("SoilProfile1", this.soilProfile.Name); } [Test] public void TestDikeLocationSegments() { Assert.IsNotNull(this.location1.Segment); Assert.AreEqual(this.segment1, this.location1.Segment); } [Test] public void TestDikeLocationSurfaceLines() { Assert.IsNotNull(this.location1.SurfaceLine2); Assert.AreEqual(this.surfaceLine1, this.location1.SurfaceLine2); } [Test] public void TestDikeSegmentsSoilProfileProbabilities() { Assert.AreEqual(100, this.segment1.GetSoilProfileProbability(this.soilProfile, FailureMechanismSystemType.StabilityInside)); } [Test] public void TestDikeSegmentsSurfaceLinePoints() { var points = this.surfaceLine1.Geometry.Points; Assert.AreEqual(6, points.Count); Assert.AreEqual(15.3, points[0].X); Assert.AreEqual(-3.52, points[0].Z); Assert.AreEqual(19.4, points[1].X); Assert.AreEqual(-1.46, points[1].Z); Assert.AreEqual(points[1], this.surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtRiver)); Assert.AreEqual(points[2], this.surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtRiver)); Assert.AreEqual(points[3], this.surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeTopAtPolder)); Assert.AreEqual(points[4], this.surfaceLine1.CharacteristicPoints.GetGeometryPoint(CharacteristicPointType.DikeToeAtPolder)); Assert.AreEqual(0, this.surfaceLine1.GetCharacteristicPoints(points[0]).Count(cpt => cpt != CharacteristicPointType.None)); Assert.AreEqual(CharacteristicPointType.DikeToeAtRiver, this.surfaceLine1.GetCharacteristicPoints(points[1]).First()); Assert.IsTrue(this.surfaceLine1.HasDike()); } // private Dike CreateDikeWith2DGeometrySegements() // { // dike = new Dike(); // dike.Name = "Dike"; // // Segments // Segment 1 // var segment = new Dam.Data.Segment(); // segment.Name = "Segment1"; // SoilGeometryProbability soilGeometryProbability = new SoilGeometryProbability(); // soilGeometryProbability.SoilGeometry2DName = "Geometry1"; // segment.SoilProfileProbabilities.Add(soilGeometryProbability); // dike.Segments.Add(segment); // Segment 2 // segment = new Dam.Data.Segment(); // segment.Name = "Segment2"; // soilGeometryProbability = new SoilGeometryProbability(); // soilGeometryProbability.SoilGeometry2DName = "Geometry2"; // segment.SoilProfileProbabilities.Add(soilGeometryProbability); // dike.Segments.Add(segment); // // return dike; // } // // [Test] // public void CanAddGeometry2DNamesFromSegments() // { // Dike dike = CreateDikeWith2DGeometrySegements(); // dike.FillGeometry2DNamesFromSegments(); // Assert.AreEqual(2, dike.SoilGeometry2DNames.Count); // } } }