// 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 System.Collections.Generic; using Deltares.Dam.Data; using Deltares.Geometry; using Deltares.Geometry.TestUtils; using NUnit.Framework; namespace Deltares.Dam.Tests { [TestFixture] public class LocationTest { [Test] public void CheckNameValuePairGetSet() { const double cTolerance = 0.00001; using ( var expectedLocation = new Location { Name = "Sand", SheetPileLength = 10.1, RwBankProtectionBottomLevel = 11.11 }) using (var actualLocation = new Location()) { var nameValuePairs = expectedLocation.GetParametersAsNameValuePairs(); foreach (var soilDetail in nameValuePairs) { actualLocation.SetParameterFromNameValuePair(soilDetail.Key, soilDetail.Value); } Assert.AreEqual(expectedLocation.SheetPileLength, actualLocation.SheetPileLength, cTolerance); Assert.AreEqual(expectedLocation.RwBankProtectionBottomLevel, actualLocation.RwBankProtectionBottomLevel, cTolerance); } } [Test] public void Location_ConstructNewInstance_HasDefaultValuesSet() { // setup var geometryPointComparer = new GeometryPointComparer(); var sheetPilePoint = new GeometryPoint(); const bool areLocalXzObjectsCreated = false; const double penetrationLength = 0.0; const double trafficLoad = 0.0; const PLLineCreationMethod plLineCreationMethod = PLLineCreationMethod.ExpertKnowledgeRRD; const double plLineOffsetBelowDikeTopAtRiver = 0.5; const double plLineOffsetBelowDikeTopAtPolder = 1.5; const double plLineOffsetBelowShoulderBaseInside = 0.1; const double plLineOffsetBelowDikeToeAtPolder = 0.1; const double plLineOffsetDryBelowDikeTopAtRiver = 0.5; const double plLineOffsetDryBelowDikeTopAtPolder = 1.5; const double plLineOffsetDryBelowShoulderBaseInside = 0.1; const double plLineOffsetDryBelowDikeToeAtPolder = 0.1; const double stabilityShoulderGrowSlope = 0.3333333333333; const double stabilityShoulderGrowDeltaX = 2.0; const double stabilitySlopeAdaptionDeltaX = 2.0; // call var actualLocation = new Location(); // assert Assert.AreEqual(0, geometryPointComparer.Compare(sheetPilePoint, actualLocation.SheetPilePoint)); Assert.AreEqual(areLocalXzObjectsCreated, actualLocation.AreLocalXZObjectsCreated); Assert.AreEqual(penetrationLength, actualLocation.PenetrationLength); Assert.AreEqual(trafficLoad, actualLocation.TrafficLoad); Assert.AreEqual(plLineCreationMethod, actualLocation.PLLineCreationMethod); Assert.AreEqual(plLineOffsetBelowDikeTopAtRiver, actualLocation.PlLineOffsetBelowDikeTopAtRiver); Assert.AreEqual(plLineOffsetBelowDikeTopAtPolder, actualLocation.PlLineOffsetBelowDikeTopAtPolder); Assert.AreEqual(plLineOffsetBelowShoulderBaseInside, actualLocation.PlLineOffsetBelowShoulderBaseInside); Assert.AreEqual(plLineOffsetBelowDikeToeAtPolder, actualLocation.PlLineOffsetBelowDikeToeAtPolder); Assert.AreEqual(plLineOffsetDryBelowDikeTopAtRiver, actualLocation.PLLineOffsetDryBelowDikeTopAtRiver); Assert.AreEqual(plLineOffsetDryBelowDikeTopAtPolder, actualLocation.PLLineOffsetDryBelowDikeTopAtPolder); Assert.AreEqual(plLineOffsetDryBelowShoulderBaseInside, actualLocation.PLLineOffsetDryBelowShoulderBaseInside); Assert.AreEqual(plLineOffsetDryBelowDikeToeAtPolder, actualLocation.PLLineOffsetDryBelowDikeToeAtPolder); Assert.AreEqual(null, actualLocation.PlLineOffsetBelowDikeCrestMiddle); Assert.AreEqual(null, actualLocation.PlLineOffsetFactorBelowShoulderCrest); Assert.AreEqual(null, actualLocation.PlLineOffsetDryBelowDikeCrestMiddle); Assert.AreEqual(null, actualLocation.PlLineOffsetDryFactorBelowShoulderCrest); Assert.AreEqual(null, actualLocation.UsePlLineOffsetBelowDikeCrestMiddle); Assert.AreEqual(null, actualLocation.UsePlLineOffsetFactorBelowShoulderCrest); Assert.AreEqual(null, actualLocation.UsePlLineOffsetDryBelowDikeCrestMiddle); Assert.AreEqual(null, actualLocation.UsePlLineOffsetDryFactorBelowShoulderCrest); Assert.AreEqual(IntrusionVerticalWaterPressureType.Standard, actualLocation.IntrusionVerticalWaterPressure); Assert.AreEqual(stabilityShoulderGrowSlope, actualLocation.StabilityShoulderGrowSlope, 1e-12); Assert.AreEqual(stabilityShoulderGrowDeltaX, actualLocation.StabilityShoulderGrowDeltaX); Assert.AreEqual(stabilitySlopeAdaptionDeltaX, actualLocation.StabilitySlopeAdaptionDeltaX); } [Test] public void PolderLevel_ReadWrite_ShouldGiveExpectedResult() { // setup const double expected = 2.2; using (var location = new Location("test") {PolderLevel = expected}) { // checks Assert.AreEqual(expected, location.PolderLevel); } } [Test] public void RiverLevel_ReadWrite_ShouldGiveExpectedResult() { // setup const double expected = 1.1; using (var location = new Location("test") {RiverLevel = expected}) { // checks Assert.AreEqual(expected, location.RiverLevel); } } } }