Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs
===================================================================
diff -u -r6955 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs (.../DataPluginImporter.cs) (revision 6955)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DataPlugins/DataPluginImporter.cs (.../DataPluginImporter.cs) (revision 6968)
@@ -361,6 +361,7 @@
///
public IEnumerable GetSurfaceLineCharacteristicPoints(string surfaceLineId)
{
+ const double pointTolerance = 1E-6;
SurfaceLine2 surfaceLine = GetSurfaceLine(surfaceLineId);
foreach (CharacteristicPointType type in Enum.GetValues(typeof(CharacteristicPointType)))
@@ -372,7 +373,8 @@
continue;
}
- if ((point.X == -1.0) && (point.Y == -1.0) && (point.Z == -1.0))
+ if ((Math.Abs(point.X - (-1.0)) < pointTolerance) && (Math.Abs(point.Y - (-1.0)) < pointTolerance) &&
+ (Math.Abs(point.Z - (-1.0)) < pointTolerance))
{
continue;
}
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/LocationJob.cs
===================================================================
diff -u -r6964 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/LocationJob.cs (.../LocationJob.cs) (revision 6964)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/LocationJob.cs (.../LocationJob.cs) (revision 6968)
@@ -351,8 +351,8 @@
}
}
}
-
- if (res == double.MaxValue)
+ const double tolerance = 0.1;
+ if (Math.Abs(res - double.MaxValue) < tolerance)
{
res = DamGlobalConstants.NoRunValue;
}
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DtoAssembler/DtoAssembler.cs
===================================================================
diff -u -r6436 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DtoAssembler/DtoAssembler.cs (.../DtoAssembler.cs) (revision 6436)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DtoAssembler/DtoAssembler.cs (.../DtoAssembler.cs) (revision 6968)
@@ -236,7 +236,7 @@
/// An XElement instance
public override XElement CreateDataTransferObject(TDomainObject domainObj)
{
- if (domainObj == null)
+ if (EqualityComparer.Default.Equals(domainObj, default(TDomainObject)))
{
return null;
}
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/IO/CombineImportedData.cs
===================================================================
diff -u -r6940 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/IO/CombineImportedData.cs (.../CombineImportedData.cs) (revision 6940)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/IO/CombineImportedData.cs (.../CombineImportedData.cs) (revision 6968)
@@ -452,7 +452,10 @@
// if this is a dummy layer to set the bottom level for the entire profile, then do so
if (soilProfileRecord.SoilName == SoilProfile1D.SoilProfileBottomLevelId)
{
- soilProfile.BottomLevel = soilProfileRecord.TopLevel;
+ if (soilProfile != null)
+ {
+ soilProfile.BottomLevel = soilProfileRecord.TopLevel;
+ }
}
else
{
@@ -476,7 +479,10 @@
layer.Soil = dike.SoilList.Soils[soilIndex];
layer.Name = "Layer" + layerIndex;
layerIndex++;
- soilProfile.Layers.Add(layer);
+ if (soilProfile != null)
+ {
+ soilProfile.Layers.Add(layer);
+ }
}
}
}
@@ -530,7 +536,7 @@
{
return;
}
-
+ const double pointTolerance = 1E-6;
foreach (CsvImporterSurfaceLines.SurfaceLineRecord surfaceLineRecord in SurfaceLineRecords)
{
if (String.IsNullOrEmpty(surfaceLineRecord.SurfaceLineId))
@@ -563,7 +569,9 @@
for (var i = 0; i < surfaceLineRecord.Xcoors.Count; i++)
{
// empty points will not be added
- if (surfaceLineRecord.Xcoors[i] != -1 || surfaceLineRecord.Ycoors[i] != -1 || surfaceLineRecord.Zcoors[i] != -1)
+ if (Math.Abs(surfaceLineRecord.Xcoors[i] - (-1)) > pointTolerance ||
+ Math.Abs(surfaceLineRecord.Ycoors[i] - (-1)) > pointTolerance ||
+ Math.Abs(surfaceLineRecord.Zcoors[i] - (-1)) > pointTolerance)
{
surfaceLine.EnsurePointOfType(surfaceLineRecord.Xcoors[i], surfaceLineRecord.Ycoors[i], surfaceLineRecord.Zcoors[i], null);
}
@@ -584,7 +592,9 @@
foreach (CsvImporterCharacteristicPoints.CharPoint point in characteristicPointsRecord.Points)
{
// ignore unset points
- if (!((point.X == -1) && (point.Y == -1) && (point.Z == -1)))
+ if (!((Math.Abs(point.X - (-1)) < pointTolerance) &&
+ (Math.Abs(point.Y - (-1)) < pointTolerance) &&
+ (Math.Abs(point.Z - (-1)) < pointTolerance)))
{
GeometryPoint tppoint = surfaceLine.Geometry.GetPointAt(point.X, point.Y, point.Z);
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/CompositeJob.cs
===================================================================
diff -u -r6436 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/CompositeJob.cs (.../CompositeJob.cs) (revision 6436)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/CompositeJob.cs (.../CompositeJob.cs) (revision 6968)
@@ -21,6 +21,7 @@
using System.Collections.Generic;
using System.ComponentModel;
+using System.Linq;
using Deltares.Standard.Attributes;
namespace Deltares.Dam.Data;
@@ -37,37 +38,15 @@
{
get
{
- var containsRun = false;
- var containsNoRun = false;
-
- foreach (DamJob job in jobs)
- {
- if (!job.Run.HasValue)
- {
- containsRun = true;
- containsNoRun = true;
- }
- else if (job.Run.Value)
- {
- containsRun = true;
- }
- else
- {
- containsNoRun = true;
- }
- }
-
+ bool containsRun = jobs.Any(job => job.Run != false);
+ bool containsNoRun = jobs.Any(job => job.Run != true);
+
if (containsRun && containsNoRun)
{
return null;
}
- if (containsRun)
- {
- return true;
- }
-
- return false;
+ return containsRun;
}
set
{
Fisheye: Tag 6968 refers to a dead (removed) revision in file `DamClients/DamUI/trunk/src/Dam/Deltares.Dam.Tests/DamStabilityParametersTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProjectCalculationSpecification.cs
===================================================================
diff -u -r6964 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProjectCalculationSpecification.cs (.../DamProjectCalculationSpecification.cs) (revision 6964)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamProjectCalculationSpecification.cs (.../DamProjectCalculationSpecification.cs) (revision 6968)
@@ -23,6 +23,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Linq;
using System.Xml.Serialization;
using Deltares.Dam.Data.UISupport;
using Deltares.Standard;
@@ -121,11 +122,7 @@
// To solve MWDAM-592, remember the current pipingmodeltype as this gets reset by setting the
// calculationmodel. Only switch it back when needed.
PipingModelType oldPipingModelType = pipingModelType;
- foreach (Enum possibleModel in GetDomain("CalculationModel"))
- {
- CalculationModel = possibleModel;
- break;
- }
+ CalculationModel = GetDomain("CalculationModel").Cast().FirstOrDefault();
if (failureMechanismSystemType == FailureMechanismSystemType.Piping)
{
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs
===================================================================
diff -u -r6436 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs (.../Scenario.cs) (revision 6436)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs (.../Scenario.cs) (revision 6968)
@@ -640,9 +640,14 @@
throw new ScenarioException(String.Format(LocalizationManager.GetTranslatedText(this, "NoUpliftCriterionForStability"), Location.Name, ToString()));
}
- return (ModelFactors.UpliftCriterionStability.IsNearEqual(0)
- ? defaultUpliftCriterionStability.Value
- : ModelFactors.UpliftCriterionStability);
+ if (defaultUpliftCriterionStability != null)
+ {
+ return (ModelFactors.UpliftCriterionStability.IsNearEqual(0)
+ ? defaultUpliftCriterionStability.Value
+ : ModelFactors.UpliftCriterionStability);
+ }
+
+ return 0.0;
}
///
@@ -657,7 +662,11 @@
throw new ScenarioException(String.Format(LocalizationManager.GetTranslatedText(this, "NoUpliftCriterionForPiping"), Location.Name, ToString()));
}
- return (ModelFactors.UpliftCriterionPiping.IsNearEqual(0) ? defaultUpliftCriterionPiping.Value : ModelFactors.UpliftCriterionPiping);
+ if (defaultUpliftCriterionPiping != null)
+ {
+ return (ModelFactors.UpliftCriterionPiping.IsNearEqual(0) ? defaultUpliftCriterionPiping.Value : ModelFactors.UpliftCriterionPiping);
+ }
+ return 0.0;
}
///
@@ -672,7 +681,11 @@
throw new ScenarioException(String.Format(LocalizationManager.GetTranslatedText(this, "NoRequiredSafetyFactorPiping"), Location.Name, ToString()));
}
- return (ModelFactors.RequiredSafetyFactorPiping.IsNearEqual(0) ? defaultRequiredSafetyFactorPiping.Value : ModelFactors.RequiredSafetyFactorPiping);
+ if (defaultRequiredSafetyFactorPiping != null)
+ {
+ return (ModelFactors.RequiredSafetyFactorPiping.IsNearEqual(0) ? defaultRequiredSafetyFactorPiping.Value : ModelFactors.RequiredSafetyFactorPiping);
+ }
+ return 0.0;
}
///
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamJob.cs
===================================================================
diff -u -r6839 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamJob.cs (.../DamJob.cs) (revision 6839)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/DamJob.cs (.../DamJob.cs) (revision 6968)
@@ -43,14 +43,8 @@
[PropertyOrder(0, 0)]
public virtual string Name
{
- get
- {
- return subject != null ? subject.ToString() : "";
- }
- set
- {
- name = value;
- }
+ get => subject?.ToString() ?? "";
+ set => name = value;
}
[Label("Run")]
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/SlipCircleDefinition.cs
===================================================================
diff -u -r6964 -r6968
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/SlipCircleDefinition.cs (.../SlipCircleDefinition.cs) (revision 6964)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/SlipCircleDefinition.cs (.../SlipCircleDefinition.cs) (revision 6968)
@@ -474,13 +474,4 @@
Specification.FailureMechanismSystemType == FailureMechanismSystemType.StabilityOutside) &&
(StabilityModelType) Specification.CalculationModel == StabilityModelType.BishopUpliftVan);
}
-}
-
-public class MStabDesignEmbankment : ICloneable
-{
- public MStabDesignEmbankment Clone()
- {
- var mstabDesignEmbankment = new MStabDesignEmbankment();
- return mstabDesignEmbankment;
- }
-}
+}
\ No newline at end of file
Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data.Tests/DamStabilityParametersTest.cs
===================================================================
diff -u
--- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data.Tests/DamStabilityParametersTest.cs (revision 0)
+++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data.Tests/DamStabilityParametersTest.cs (revision 6968)
@@ -0,0 +1,167 @@
+// Copyright (C) Stichting Deltares 2025. 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.Standard;
+using Deltares.Dam.Data;
+using NUnit.Framework;
+
+namespace Deltares.Dam.Tests
+{
+ [TestFixture]
+ public class DamStabilityParametersTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var parameters = new DamStabilityParameters();
+
+ // Assert
+ Assert.That(parameters, Is.InstanceOf>());
+ Assert.That(parameters, Is.InstanceOf());
+
+ Assert.Multiple(() =>
+ {
+ Assert.That(parameters.IsUpliftVanRunOnlyWhenUpliftOccurs, Is.True);
+ Assert.That(parameters.SearchMethod, Is.EqualTo(StabilitySearchMethod.BeeSwarm));
+ Assert.That(parameters.SlipCircleDefinition, Is.Not.Null);
+ });
+ }
+
+ [Test]
+ [TestCase(FailureMechanismSystemType.StabilityInside, true)]
+ [TestCase(FailureMechanismSystemType.StabilityOutside, false)]
+ public void GivenSpecificationWithStabilityModel_WhenIsEnabledCalledWithCalculationModel_ThenReturnsExpectedResult(
+ FailureMechanismSystemType failureMechanism, bool expectedIsEnabled)
+ {
+ // Given
+ var specification = new DamProjectCalculationSpecification()
+ {
+ FailureMechanismSystemType = failureMechanism
+ };
+
+ // When
+ bool isEnabled = specification.IsEnabled(nameof(specification.CalculationModel));
+
+ // Then
+ Assert.That(isEnabled, Is.EqualTo(expectedIsEnabled));
+ }
+
+ [Test]
+ [TestCase(null)]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase("Property")]
+ public void GivenSpecificationWithStabilityInside_WhenIsEnabledCalledWithOtherProperty_ThenReturnsTrue(
+ string property)
+ {
+ // Given
+ var specification = new DamProjectCalculationSpecification()
+ {
+ FailureMechanismSystemType = FailureMechanismSystemType.StabilityInside
+ };
+
+ // When
+ bool isEnabled = specification.IsEnabled(property);
+
+ // Then
+ Assert.That(isEnabled, Is.True);
+ }
+
+ [Test]
+ [TestCase(null)]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase("Property")]
+ public void GivenSpecificationWithStabilityOutside_WhenIsEnabledCalledWithOtherProperty_ThenReturnsTrue(
+ string property)
+ {
+ // Given
+ var specification = new DamProjectCalculationSpecification
+ {
+ FailureMechanismSystemType = FailureMechanismSystemType.StabilityOutside
+ };
+
+ // When
+ bool isEnabled = specification.IsEnabled(property);
+
+ // Then
+ Assert.That(isEnabled, Is.True);
+ }
+
+ [Test]
+ [TestCase(FailureMechanismSystemType.Piping)]
+ public void GivenSpecificationWithNotStabilityModel_WhenIsEnabledCalledWithCalculationModel_ThenReturnsTrue(
+ FailureMechanismSystemType failureMechanism)
+ {
+ // Given
+ var specification = new DamProjectCalculationSpecification
+ {
+ FailureMechanismSystemType = failureMechanism
+ };
+
+ // When
+ bool isEnabled = specification.IsEnabled(nameof(specification.CalculationModel));
+
+ // Then
+ Assert.That(isEnabled, Is.True);
+ }
+
+ [Test]
+ [TestCase(FailureMechanismSystemType.StabilityInside, true)]
+ [TestCase(FailureMechanismSystemType.StabilityOutside, false)]
+ [TestCase(FailureMechanismSystemType.Piping, false)]
+ public void IsVisible_WithFailureMechanismTypeAndCalledWithStabilityParametersProperty_ReturnsExpectedResult(
+ FailureMechanismSystemType failureMechanismSystemType, bool expectedVisibility)
+ {
+ // Setup
+ var specification = new DamProjectCalculationSpecification
+ {
+ FailureMechanismSystemType = failureMechanismSystemType
+ };
+
+ // Call
+ bool isVisible = specification.IsVisible(nameof(StabilityModelType));
+
+ // Assert
+ Assert.That(isVisible, Is.EqualTo(expectedVisibility));
+ }
+
+ [Test]
+ [TestCase(null)]
+ [TestCase("")]
+ [TestCase(" ")]
+ [TestCase("Property")]
+ public void IsVisible_CalledWithProperty_ReturnsTrue(string property)
+ {
+ // Setup
+ var specification = new DamProjectCalculationSpecification
+ {
+ FailureMechanismSystemType = FailureMechanismSystemType.StabilityInside
+ };
+
+ // Call
+ bool isVisible = specification.IsVisible(property);
+
+ // Assert
+ Assert.That(isVisible, Is.True);
+ }
+ }
+}
\ No newline at end of file