Fisheye: Tag 6555 refers to a dead (removed) revision in file `DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/LocationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data.Tests/LocationTests.cs =================================================================== diff -u -r6554 -r6555 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data.Tests/LocationTests.cs (.../LocationTests.cs) (revision 6554) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data.Tests/LocationTests.cs (.../LocationTests.cs) (revision 6555) @@ -19,9 +19,11 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using Deltares.Geometry; using Deltares.Geotechnics.GeotechnicalGeometry; using Deltares.Geotechnics.SurfaceLines; +using Deltares.Standard.Language; using Deltares.Standard.Validation; using NUnit.Framework; @@ -60,7 +62,90 @@ }); } } + + [Test] + public void CheckNameValuePairGetSet() + { + const double cTolerance = 0.00001; + var expectedLocation = new Location(); + expectedLocation.Name = "Sand"; + expectedLocation.DampingFactorPL3 = 11.11; + var actualLocation = new Location(); + Dictionary nameValuePairs = expectedLocation.GetParametersAsNameValuePairs(); + foreach (KeyValuePair soilDetail in nameValuePairs) + { + actualLocation.SetParameterFromNameValuePair(soilDetail.Key, soilDetail.Value); + } + Assert.That(actualLocation.DampingFactorPL3, + Is.EqualTo(expectedLocation.DampingFactorPL3).Within(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.That(actualLocation.AreLocalXZObjectsCreated, Is.EqualTo(areLocalXzObjectsCreated)); + Assert.That(actualLocation.PenetrationLength, Is.EqualTo(penetrationLength)); + Assert.That(actualLocation.TrafficLoad, Is.EqualTo(trafficLoad)); + Assert.That(actualLocation.TL_DegreeOfConsolidation, Is.EqualTo(null)); + Assert.That(actualLocation.PLLineCreationMethod, Is.EqualTo(plLineCreationMethod)); + Assert.That(actualLocation.IntrusionVerticalWaterPressure, Is.EqualTo(IntrusionVerticalWaterPressureType.Standard)); + Assert.That(actualLocation.StabilityShoulderGrowSlope, Is.EqualTo(stabilityShoulderGrowSlope).Within(1e-12)); + Assert.That(actualLocation.StabilityShoulderGrowDeltaX, Is.EqualTo(stabilityShoulderGrowDeltaX)); + Assert.That(actualLocation.StabilitySlopeAdaptionDeltaX, Is.EqualTo(stabilitySlopeAdaptionDeltaX)); + } + + [Test] + [TestCase(0, IntrusionVerticalWaterPressureType.Standard, "")] + [TestCase(0, IntrusionVerticalWaterPressureType.HydroStatic, "")] + [TestCase(0, IntrusionVerticalWaterPressureType.FullHydroStatic, "")] + [TestCase(0, IntrusionVerticalWaterPressureType.Linear, "")] + [TestCase(0, IntrusionVerticalWaterPressureType.SemiTimeDependent, "UseOfSemiTimeDependentModelWithoutPenetrationLength")] + [TestCase(1, IntrusionVerticalWaterPressureType.Standard, "UseOfPenetrationLengthWithoutSemiTimeDependentModel")] + [TestCase(1, IntrusionVerticalWaterPressureType.HydroStatic, "UseOfPenetrationLengthWithoutSemiTimeDependentModel")] + [TestCase(1, IntrusionVerticalWaterPressureType.FullHydroStatic, "UseOfPenetrationLengthWithoutSemiTimeDependentModel")] + [TestCase(1, IntrusionVerticalWaterPressureType.Linear, "UseOfPenetrationLengthWithoutSemiTimeDependentModel")] + [TestCase(1, IntrusionVerticalWaterPressureType.SemiTimeDependent, "")] + public void GivenPenetrationLengthWithIntrusionVerticalWaterPressureType_WhenValidating_ReturnsExpectedWarning(double penetrationLength, IntrusionVerticalWaterPressureType model, string expectedWarning) + { + var location = new Location(); + location.IntrusionVerticalWaterPressure = model; + location.PenetrationLength = penetrationLength; + + ValidationResult[] validationResults = location.ValidateLocationUseOfPenetrationLength(); + + if (expectedWarning == "") + { + Assert.That(validationResults, Has.Length.EqualTo(0)); + } + else + { + Assert.Multiple(() => + { + Assert.That(validationResults, Has.Length.EqualTo(1)); + Assert.That(validationResults[0].MessageType, Is.EqualTo(ValidationResultType.Warning)); + + string header = LocalizationManager.GetTranslatedText(typeof(Location), "IntrusionVerticalWaterPressure"); + string selectedModel = LocalizationManager.GetTranslatedText(typeof(Location), model.ToString()); + string message = string.Format(LocalizationManager.GetTranslatedText(typeof(Location), expectedWarning), header, selectedModel); + Assert.That(validationResults[0].Text, Is.EqualTo(message)); + }); + } + } + private static SurfaceLine2 CreateSurfaceLine(CharacteristicPointType typeNotPresent) { var gp0 = new GeometryPoint(0.0, 0.0, 0.0);