// Copyright (C) Stichting Deltares 2026. 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 System.Collections.Generic; using System.Drawing; using Deltares.Geotechnics.Soils; using NUnit.Framework; namespace Deltares.Dam.Data.Tests { // this was moved here from DSL-GeoIo, to make DSL-GeoIo superfluous [TestFixture] public class SoilUtilsTests { [Test] public void CheckNameValuePairGetSet() { var expectedSoil = new Soil { Name = "Sand", DiameterD70 = 1.1, Color = Color.Aqua, Cohesion = 1.3, AbovePhreaticLevel = 1.4, BelowPhreaticLevel = 1.5, FrictionAngle = 1.6, PermeabKx = 1.7, POP = 1.8, RatioCuPc = 1.9, SoilType = SoilType.Sand, ShearStrengthModel = ShearStrengthModel.CuMeasured, StrengthIncreaseExponent = 2.0, UseDefaultShearStrengthModel = false }; Dictionary nameValuePairs = SoilUtils.GetParametersAsNameValuePairs(expectedSoil); var actualSoil = new Soil(); actualSoil.UseDefaultShearStrengthModel = false; foreach (KeyValuePair soilDetail in nameValuePairs) { SoilUtils.SetParameterFromNameValuePair(actualSoil, soilDetail.Key, soilDetail.Value); } Assert.Multiple(() => { Assert.That(actualSoil.DiameterD70, Is.EqualTo(expectedSoil.DiameterD70)); Assert.That(actualSoil.Color.ToArgb(), Is.EqualTo(expectedSoil.Color.ToArgb())); Assert.That(actualSoil.Cohesion, Is.EqualTo(expectedSoil.Cohesion)); Assert.That(actualSoil.AbovePhreaticLevel, Is.EqualTo(expectedSoil.AbovePhreaticLevel)); Assert.That(actualSoil.BelowPhreaticLevel, Is.EqualTo(expectedSoil.BelowPhreaticLevel)); Assert.That(actualSoil.FrictionAngle, Is.EqualTo(expectedSoil.FrictionAngle)); Assert.That(actualSoil.PermeabKx, Is.EqualTo(expectedSoil.PermeabKx)); Assert.That(actualSoil.POP, Is.EqualTo(expectedSoil.POP)); Assert.That(actualSoil.RatioCuPc, Is.EqualTo(expectedSoil.RatioCuPc)); Assert.That(actualSoil.SoilType, Is.EqualTo(expectedSoil.SoilType)); Assert.That(actualSoil.ShearStrengthModel, Is.EqualTo(expectedSoil.ShearStrengthModel)); Assert.That(actualSoil.StrengthIncreaseExponent, Is.EqualTo(expectedSoil.StrengthIncreaseExponent)); }); expectedSoil.DiameterD70 = 20; nameValuePairs = SoilUtils.GetParametersAsNameValuePairs(expectedSoil); actualSoil = new Soil(); foreach (KeyValuePair soilDetail in nameValuePairs) { SoilUtils.SetParameterFromNameValuePair(actualSoil, soilDetail.Key, soilDetail.Value); } Assert.That(actualSoil.DiameterD70, Is.EqualTo(expectedSoil.DiameterD70)); } } }