// Copyright (C) Stichting Deltares 2025. 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 Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.Geotechnics; using NUnit.Framework; namespace Deltares.DamEngine.Data.Tests.General; [TestFixture] public class SegmentTests { [Test] public void CanGetMostProbableSoilGeometryProbability1DForStability() { Segment segment = CreateSegment(SegmentFailureMechanismType.Stability, SoilProfileType.ProfileType1D); Assert.Multiple(() => { Assert.That(segment.GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType.Stability).SoilProfile1D.Name, Is.EqualTo("profile 1D 2")); Assert.That(segment.GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType.Piping), Is.EqualTo(null)); }); } [Test] public void CanGetMostProbableSoilGeometryProbability1DForPiping() { Segment segment = CreateSegment(SegmentFailureMechanismType.Piping, SoilProfileType.ProfileType1D); Assert.Multiple(() => { Assert.That(segment.GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType.Piping).SoilProfile1D.Name, Is.EqualTo("profile 1D 2")); Assert.That(segment.GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType.Stability), Is.EqualTo(null)); }); } [Test] public void CanGetMostProbableSoilGeometryProbability2DForStability() { Segment segment = CreateSegment(SegmentFailureMechanismType.Stability, SoilProfileType.ProfileType2D); Assert.Multiple(() => { Assert.That(segment.GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType.Stability).SoilProfile2D.Name, Is.EqualTo("profile 2D 2")); Assert.That(segment.GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType.Piping), Is.EqualTo(null)); }); } [Test] public void CanGetMostProbableSoilGeometryProbability2DForPiping() { Segment segment = CreateSegment(SegmentFailureMechanismType.Piping, SoilProfileType.ProfileType2D); Assert.Multiple(() => { Assert.That(segment.GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType.Piping).SoilProfile2D.Name, Is.EqualTo("profile 2D 2")); Assert.That(segment.GetMostProbableSoilGeometryProbability(SegmentFailureMechanismType.Stability), Is.EqualTo(null)); }); } private static Segment CreateSegment(SegmentFailureMechanismType segmentFailureMechanismType, SoilProfileType soilProfileType) { var segment = new Segment(); segment.SoilProfileProbabilities.Add(new SoilGeometryProbability { Probability = 0.1, SegmentFailureMechanismType = segmentFailureMechanismType, SoilProfileType = soilProfileType, SoilProfile2D = new SoilProfile2D { Name = "profile 2D 1" }, SoilProfile1D = new SoilProfile1D { Name = "profile 1D 1" } }); segment.SoilProfileProbabilities.Add(new SoilGeometryProbability { Probability = 0.4, SegmentFailureMechanismType = segmentFailureMechanismType, SoilProfileType = soilProfileType, SoilProfile2D = new SoilProfile2D { Name = "profile 2D 2" }, SoilProfile1D = new SoilProfile1D { Name = "profile 1D 2" } }); segment.SoilProfileProbabilities.Add(new SoilGeometryProbability { Probability = 0.3, SegmentFailureMechanismType = segmentFailureMechanismType, SoilProfileType = soilProfileType, SoilProfile2D = new SoilProfile2D { Name = "profile 2D 3" }, SoilProfile1D = new SoilProfile1D { Name = "profile 1D 3" } }); segment.SoilProfileProbabilities.Add(new SoilGeometryProbability { Probability = 0.2, SegmentFailureMechanismType = segmentFailureMechanismType, SoilProfileType = soilProfileType, SoilProfile2D = new SoilProfile2D { Name = "profile 2D 4" }, SoilProfile1D = new SoilProfile1D { Name = "profile 1D 4" } }); return segment; } }