Index: Riskeer/Piping/src/Riskeer.Piping.Data/PipingScenarioConfigurationPerFailureMechanismSection.cs
===================================================================
diff -u -rd9334d0a89e1271b4288b132c3148b539f3b0d22 -r44f322faddd87303f4648269a224b894d3a54e14
--- Riskeer/Piping/src/Riskeer.Piping.Data/PipingScenarioConfigurationPerFailureMechanismSection.cs (.../PipingScenarioConfigurationPerFailureMechanismSection.cs) (revision d9334d0a89e1271b4288b132c3148b539f3b0d22)
+++ Riskeer/Piping/src/Riskeer.Piping.Data/PipingScenarioConfigurationPerFailureMechanismSection.cs (.../PipingScenarioConfigurationPerFailureMechanismSection.cs) (revision 44f322faddd87303f4648269a224b894d3a54e14)
@@ -52,7 +52,7 @@
public FailureMechanismSection Section { get; }
///
- /// Gets the scenario configuration.
+ /// Gets or sets the scenario configuration.
///
public PipingScenarioConfigurationPerFailureMechanismSectionType ScenarioConfigurationType { get; set; }
}
Index: Riskeer/Storage/src/Riskeer.Storage.Core/Read/Piping/PipingFailureMechanismMetaEntityReadExtensions.cs
===================================================================
diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -r44f322faddd87303f4648269a224b894d3a54e14
--- Riskeer/Storage/src/Riskeer.Storage.Core/Read/Piping/PipingFailureMechanismMetaEntityReadExtensions.cs (.../PipingFailureMechanismMetaEntityReadExtensions.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd)
+++ Riskeer/Storage/src/Riskeer.Storage.Core/Read/Piping/PipingFailureMechanismMetaEntityReadExtensions.cs (.../PipingFailureMechanismMetaEntityReadExtensions.cs) (revision 44f322faddd87303f4648269a224b894d3a54e14)
@@ -27,8 +27,9 @@
namespace Riskeer.Storage.Core.Read.Piping
{
///
- /// This class defines extension methods for read operations for a
- /// and a based on the .
+ /// This class defines extension methods for read operations for a ,
+ /// a or a based on the
+ /// .
///
internal static class PipingFailureMechanismMetaEntityReadExtensions
{
@@ -80,5 +81,29 @@
generalPipingInput.WaterVolumetricWeight = (RoundedDouble) entity.WaterVolumetricWeight;
}
+
+ ///
+ /// Read the and use the information to update the
+ /// .
+ ///
+ /// The to use to update the
+ /// .
+ /// The to be updated.
+ /// Thrown when any input parameter is null.
+ internal static void ReadFailureMechanismValues(this PipingFailureMechanismMetaEntity entity,
+ PipingFailureMechanism failureMechanism)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException(nameof(entity));
+ }
+
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ failureMechanism.ScenarioConfigurationType = (PipingScenarioConfigurationType) entity.PipingScenarioConfigurationType;
+ }
}
}
\ No newline at end of file
Index: Riskeer/Storage/src/Riskeer.Storage.Core/Read/Piping/PipingScenarioConfigurationPerFailureMechanismSectionEntityReadExtensions.cs
===================================================================
diff -u
--- Riskeer/Storage/src/Riskeer.Storage.Core/Read/Piping/PipingScenarioConfigurationPerFailureMechanismSectionEntityReadExtensions.cs (revision 0)
+++ Riskeer/Storage/src/Riskeer.Storage.Core/Read/Piping/PipingScenarioConfigurationPerFailureMechanismSectionEntityReadExtensions.cs (revision 44f322faddd87303f4648269a224b894d3a54e14)
@@ -0,0 +1,59 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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;
+using Riskeer.Piping.Data;
+using Riskeer.Storage.Core.DbContext;
+
+namespace Riskeer.Storage.Core.Read.Piping
+{
+ ///
+ /// This class defines extension methods for read operations for a based on the
+ /// .
+ ///
+ internal static class PipingScenarioConfigurationPerFailureMechanismSectionEntityReadExtensions
+ {
+ ///
+ /// Reads the and use the information to construct a
+ /// .
+ ///
+ /// The used to update
+ /// the .
+ /// The target of the read operation.
+ /// Thrown when any parameter is null.
+ internal static void Read(this PipingScenarioConfigurationPerFailureMechanismSectionEntity entity,
+ PipingScenarioConfigurationPerFailureMechanismSection scenarioConfigurationsPerFailureMechanismSection)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException(nameof(entity));
+ }
+
+ if (scenarioConfigurationsPerFailureMechanismSection == null)
+ {
+ throw new ArgumentNullException(nameof(scenarioConfigurationsPerFailureMechanismSection));
+ }
+
+ scenarioConfigurationsPerFailureMechanismSection.ScenarioConfigurationType =
+ (PipingScenarioConfigurationPerFailureMechanismSectionType) entity.PipingScenarioConfigurationPerFailureMechanismSectionType;
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/Piping/PipingFailureMechanismMetaEntityReadExtensionsTest.cs
===================================================================
diff -u -rda1df87d94dcc61aa26d5f033c6bf579c2249cdd -r44f322faddd87303f4648269a224b894d3a54e14
--- Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/Piping/PipingFailureMechanismMetaEntityReadExtensionsTest.cs (.../PipingFailureMechanismMetaEntityReadExtensionsTest.cs) (revision da1df87d94dcc61aa26d5f033c6bf579c2249cdd)
+++ Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/Piping/PipingFailureMechanismMetaEntityReadExtensionsTest.cs (.../PipingFailureMechanismMetaEntityReadExtensionsTest.cs) (revision 44f322faddd87303f4648269a224b894d3a54e14)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Riskeer.Common.Data.TestUtil;
using Riskeer.Piping.Data;
@@ -38,10 +39,10 @@
var input = new PipingProbabilityAssessmentInput();
// Call
- TestDelegate test = () => ((PipingFailureMechanismMetaEntity) null).ReadProbabilityAssessmentInput(input);
+ void Call() => ((PipingFailureMechanismMetaEntity) null).ReadProbabilityAssessmentInput(input);
// Assert
- var exception = Assert.Throws(test);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("entity", exception.ParamName);
}
@@ -52,10 +53,10 @@
var entity = new PipingFailureMechanismMetaEntity();
// Call
- TestDelegate test = () => entity.ReadProbabilityAssessmentInput(null);
+ void Call() => entity.ReadProbabilityAssessmentInput(null);
// Assert
- var exception = Assert.Throws(test);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("probabilityAssessmentInput", exception.ParamName);
}
@@ -83,10 +84,10 @@
var input = new GeneralPipingInput();
// Call
- TestDelegate test = () => ((PipingFailureMechanismMetaEntity) null).ReadGeneralPipingInput(input);
+ void Call() => ((PipingFailureMechanismMetaEntity) null).ReadGeneralPipingInput(input);
// Assert
- var exception = Assert.Throws(test);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("entity", exception.ParamName);
}
@@ -97,10 +98,10 @@
var entity = new PipingFailureMechanismMetaEntity();
// Call
- TestDelegate test = () => entity.ReadGeneralPipingInput(null);
+ void Call() => entity.ReadGeneralPipingInput(null);
// Assert
- var exception = Assert.Throws(test);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("generalPipingInput", exception.ParamName);
}
@@ -120,5 +121,50 @@
// Assert
Assert.AreEqual(entity.WaterVolumetricWeight, inputToUpdate.WaterVolumetricWeight, inputToUpdate.WaterVolumetricWeight.GetAccuracy());
}
+
+ [Test]
+ public void ReadFailureMechanismValues_EntityNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => ((PipingFailureMechanismMetaEntity) null).ReadFailureMechanismValues(new PipingFailureMechanism());
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void ReadFailureMechanismValues_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new PipingFailureMechanismMetaEntity();
+
+ // Call
+ void Call() => entity.ReadFailureMechanismValues(null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ }
+
+ [Test]
+ public void ReadFailureMechanismValues_ValidParameters_SetPipingProbabilityAssessmentInputProperties()
+ {
+ // Setup
+ var random = new Random(31);
+ var configurationType = random.NextEnumValue();
+
+ var failureMechanismToUpdate = new PipingFailureMechanism();
+ var entity = new PipingFailureMechanismMetaEntity
+ {
+ PipingScenarioConfigurationType = Convert.ToByte(configurationType)
+ };
+
+ // Call
+ entity.ReadFailureMechanismValues(failureMechanismToUpdate);
+
+ // Assert
+ Assert.AreEqual(configurationType, failureMechanismToUpdate.ScenarioConfigurationType);
+ }
}
}
\ No newline at end of file
Index: Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/Piping/PipingScenarioConfigurationPerFailureMechanismSectionEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/Piping/PipingScenarioConfigurationPerFailureMechanismSectionEntityReadExtensionsTest.cs (revision 0)
+++ Riskeer/Storage/test/Riskeer.Storage.Core.Test/Read/Piping/PipingScenarioConfigurationPerFailureMechanismSectionEntityReadExtensionsTest.cs (revision 44f322faddd87303f4648269a224b894d3a54e14)
@@ -0,0 +1,83 @@
+// Copyright (C) Stichting Deltares 2021. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Piping.Data;
+using Riskeer.Storage.Core.DbContext;
+using Riskeer.Storage.Core.Read.Piping;
+
+namespace Riskeer.Storage.Core.Test.Read.Piping
+{
+ [TestFixture]
+ public class PipingScenarioConfigurationPerFailureMechanismSectionEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_EntityNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((PipingScenarioConfigurationPerFailureMechanismSectionEntity) null).Read(
+ new PipingScenarioConfigurationPerFailureMechanismSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection()));
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void Read_ScenarioConfigurationsPerFailureMechanismSectionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var entity = new PipingScenarioConfigurationPerFailureMechanismSectionEntity();
+
+ // Call
+ TestDelegate call = () => entity.Read(null);
+
+ // Assert
+ string paramName = Assert.Throws(call).ParamName;
+ Assert.AreEqual("scenarioConfigurationsPerFailureMechanismSection", paramName);
+ }
+
+ [Test]
+ public void Read_ParameterValues_SectionResultWithParameterValues()
+ {
+ // Setup
+ var random = new Random(21);
+ var configurationType = random.NextEnumValue();
+
+ var entity = new PipingScenarioConfigurationPerFailureMechanismSectionEntity
+ {
+ PipingScenarioConfigurationPerFailureMechanismSectionType = Convert.ToByte(configurationType)
+ };
+
+ var configurationPerSection =
+ new PipingScenarioConfigurationPerFailureMechanismSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ // Call
+ entity.Read(configurationPerSection);
+
+ // Assert
+ Assert.AreEqual(configurationType, configurationPerSection.ScenarioConfigurationType);
+ }
+ }
+}
\ No newline at end of file