// 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.Dam.Data; 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", DampingFactorPL3 = 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.DampingFactorPL3, actualLocation.DampingFactorPL3, cTolerance); } } [Test] public void Location_ConstructNewInstance_HasDefaultValuesSet() { // setup const bool areLocalXzObjectsCreated = false; const double penetrationLength = 0.0; const double trafficLoad = 0.0; const PLLineCreationMethod plLineCreationMethod = PLLineCreationMethod.ExpertKnowledgeRRD; const double stabilityShoulderGrowSlope = 0.3333333333333; const double stabilityShoulderGrowDeltaX = 2.0; const double stabilitySlopeAdaptionDeltaX = 2.0; // call var actualLocation = new Location(); // assert Assert.AreEqual(areLocalXzObjectsCreated, actualLocation.AreLocalXZObjectsCreated); Assert.AreEqual(penetrationLength, actualLocation.PenetrationLength); Assert.AreEqual(trafficLoad, actualLocation.TrafficLoad); Assert.AreEqual(null, actualLocation.TL_DegreeOfConsolidation); Assert.AreEqual(plLineCreationMethod, actualLocation.PLLineCreationMethod); 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); } } } }