Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensions.cs
===================================================================
diff -u -rbfd84af2152b697561a499f15caa6d1f9f5fd4ed -r4823d81e68837eec1ebb52616ae21982462fe6ab
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensions.cs (.../ClosingStructuresFailureMechanismSectionResultCreateExtensions.cs) (revision bfd84af2152b697561a499f15caa6d1f9f5fd4ed)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensions.cs (.../ClosingStructuresFailureMechanismSectionResultCreateExtensions.cs) (revision 4823d81e68837eec1ebb52616ae21982462fe6ab)
@@ -38,19 +38,28 @@
/// The result to create a database entity for.
/// The object keeping track of create operations.
/// A new .
- /// Thrown when is null.
+ /// Thrown when any parameter is null.
internal static ClosingStructuresSectionResultEntity Create(this ClosingStructuresFailureMechanismSectionResult result,
PersistenceRegistry registry)
{
+ if (result == null)
+ {
+ throw new ArgumentNullException(nameof(result));
+ }
+
if (registry == null)
{
throw new ArgumentNullException(nameof(registry));
}
var sectionResultEntity = new ClosingStructuresSectionResultEntity
{
- LayerOne = Convert.ToByte(result.AssessmentLayerOne),
- LayerThree = result.TailorMadeAssessmentProbability.ToNaNAsNull()
+ SimpleAssessmentResult = Convert.ToByte(result.SimpleAssessmentResult),
+ DetailedAssessmentResult = Convert.ToByte(result.DetailedAssessmentResult),
+ TailorMadeAssessmentResult = Convert.ToByte(result.TailorMadeAssessmentResult),
+ TailorMadeAssessmentProbability = result.TailorMadeAssessmentProbability.ToNaNAsNull(),
+ UseManualAssemblyProbability = Convert.ToByte(result.UseManualAssemblyProbability),
+ ManualAssemblyProbability = result.ManualAssemblyProbability.ToNaNAsNull()
};
if (result.Calculation != null)
{
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs
===================================================================
diff -u -rbfd84af2152b697561a499f15caa6d1f9f5fd4ed -r4823d81e68837eec1ebb52616ae21982462fe6ab
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs (.../ClosingStructuresSectionResultEntityReadExtensions.cs) (revision bfd84af2152b697561a499f15caa6d1f9f5fd4ed)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensions.cs (.../ClosingStructuresSectionResultEntityReadExtensions.cs) (revision 4823d81e68837eec1ebb52616ae21982462fe6ab)
@@ -21,9 +21,8 @@
using System;
using Application.Ringtoets.Storage.DbContext;
-using Core.Common.Base.Data;
using Ringtoets.ClosingStructures.Data;
-using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Primitives;
namespace Application.Ringtoets.Storage.Read.ClosingStructures
{
@@ -47,6 +46,11 @@
ClosingStructuresFailureMechanismSectionResult sectionResult,
ReadConversionCollector collector)
{
+ if (entity == null)
+ {
+ throw new ArgumentNullException(nameof(entity));
+ }
+
if (sectionResult == null)
{
throw new ArgumentNullException(nameof(sectionResult));
@@ -57,8 +61,12 @@
throw new ArgumentNullException(nameof(collector));
}
- sectionResult.AssessmentLayerOne = (AssessmentLayerOneState) entity.LayerOne;
- sectionResult.TailorMadeAssessmentProbability = entity.LayerThree.ToNullAsNaN();
+ sectionResult.SimpleAssessmentResult = (SimpleAssessmentResultType) entity.SimpleAssessmentResult;
+ sectionResult.DetailedAssessmentResult = (DetailedAssessmentProbabilityOnlyResultType) entity.DetailedAssessmentResult;
+ sectionResult.TailorMadeAssessmentResult = (TailorMadeAssessmentProbabilityCalculationResultType) entity.TailorMadeAssessmentResult;
+ sectionResult.TailorMadeAssessmentProbability = entity.TailorMadeAssessmentProbability.ToNullAsNaN();
+ sectionResult.UseManualAssemblyProbability = Convert.ToBoolean(entity.UseManualAssemblyProbability);
+ sectionResult.ManualAssemblyProbability = entity.ManualAssemblyProbability.ToNullAsNaN();
if (entity.ClosingStructuresCalculationEntity != null)
{
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs
===================================================================
diff -u -rbfd84af2152b697561a499f15caa6d1f9f5fd4ed -r4823d81e68837eec1ebb52616ae21982462fe6ab
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision bfd84af2152b697561a499f15caa6d1f9f5fd4ed)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 4823d81e68837eec1ebb52616ae21982462fe6ab)
@@ -24,19 +24,29 @@
using Application.Ringtoets.Storage.Create.ClosingStructures;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.TestUtil;
-using Core.Common.Base.Data;
using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.ClosingStructures.Data;
-using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Structures;
+using Ringtoets.Common.Primitives;
namespace Application.Ringtoets.Storage.Test.Create.ClosingStructures
{
[TestFixture]
public class ClosingStructuresFailureMechanismSectionResultCreateExtensionsTest
{
[Test]
+ public void Create_FailureMechanismSectionResultNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((ClosingStructuresFailureMechanismSectionResult) null).Create(new PersistenceRegistry());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("result", exception.ParamName);
+ }
+
+ [Test]
public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException()
{
// Setup
@@ -54,22 +64,34 @@
{
// Setup
var random = new Random(21);
- var assessmentLayerOneResult = random.NextEnumValue();
+ var simpleAssessmentResult = random.NextEnumValue();
+ var detailedAssessmentResult = random.NextEnumValue();
+ var tailorMadeAssessmentResult = random.NextEnumValue();
double tailorMadeAssessmentProbability = random.NextDouble();
+ bool useManualAssemblyProbability = random.NextBoolean();
+ double manualAssemblyProbability = random.NextDouble();
var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection())
{
- AssessmentLayerOne = assessmentLayerOneResult,
- TailorMadeAssessmentProbability = tailorMadeAssessmentProbability
+ SimpleAssessmentResult = simpleAssessmentResult,
+ DetailedAssessmentResult = detailedAssessmentResult,
+ TailorMadeAssessmentResult = tailorMadeAssessmentResult,
+ TailorMadeAssessmentProbability = tailorMadeAssessmentProbability,
+ UseManualAssemblyProbability = useManualAssemblyProbability,
+ ManualAssemblyProbability = manualAssemblyProbability
};
// Call
- ClosingStructuresSectionResultEntity result = sectionResult.Create(new PersistenceRegistry());
+ ClosingStructuresSectionResultEntity entity = sectionResult.Create(new PersistenceRegistry());
// Assert
- Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne);
- Assert.AreEqual(tailorMadeAssessmentProbability, result.LayerThree);
- Assert.IsNull(result.ClosingStructuresCalculationEntityId);
+ Assert.AreEqual(Convert.ToByte(simpleAssessmentResult), entity.SimpleAssessmentResult);
+ Assert.AreEqual(Convert.ToByte(detailedAssessmentResult), entity.DetailedAssessmentResult);
+ Assert.AreEqual(Convert.ToByte(tailorMadeAssessmentResult), entity.TailorMadeAssessmentResult);
+ Assert.AreEqual(tailorMadeAssessmentProbability, entity.TailorMadeAssessmentProbability);
+ Assert.AreEqual(Convert.ToByte(useManualAssemblyProbability), entity.UseManualAssemblyProbability);
+ Assert.AreEqual(manualAssemblyProbability, entity.ManualAssemblyProbability);
+ Assert.IsNull(entity.ClosingStructuresCalculationEntityId);
}
[Test]
@@ -78,14 +100,16 @@
// Setup
var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection())
{
- TailorMadeAssessmentProbability = double.NaN
+ TailorMadeAssessmentProbability = double.NaN,
+ ManualAssemblyProbability = double.NaN
};
// Call
- ClosingStructuresSectionResultEntity result = sectionResult.Create(new PersistenceRegistry());
+ ClosingStructuresSectionResultEntity entity = sectionResult.Create(new PersistenceRegistry());
// Assert
- Assert.IsNull(result.LayerThree);
+ Assert.IsNull(entity.TailorMadeAssessmentProbability);
+ Assert.IsNull(entity.ManualAssemblyProbability);
}
[Test]
@@ -99,14 +123,14 @@
};
var registry = new PersistenceRegistry();
- var entity = new ClosingStructuresCalculationEntity();
- registry.Register(entity, calculation);
+ var calculationEntity = new ClosingStructuresCalculationEntity();
+ registry.Register(calculationEntity, calculation);
// Call
- ClosingStructuresSectionResultEntity result = sectionResult.Create(registry);
+ ClosingStructuresSectionResultEntity entity = sectionResult.Create(registry);
// Assert
- Assert.AreSame(entity, result.ClosingStructuresCalculationEntity);
+ Assert.AreSame(calculationEntity, entity.ClosingStructuresCalculationEntity);
}
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs
===================================================================
diff -u -rbfd84af2152b697561a499f15caa6d1f9f5fd4ed -r4823d81e68837eec1ebb52616ae21982462fe6ab
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs (.../ClosingStructuresSectionResultEntityReadExtensionsTest.cs) (revision bfd84af2152b697561a499f15caa6d1f9f5fd4ed)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ClosingStructures/ClosingStructuresSectionResultEntityReadExtensionsTest.cs (.../ClosingStructuresSectionResultEntityReadExtensionsTest.cs) (revision 4823d81e68837eec1ebb52616ae21982462fe6ab)
@@ -27,15 +27,28 @@
using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.ClosingStructures.Data;
-using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.Common.Data.Structures;
+using Ringtoets.Common.Primitives;
namespace Application.Ringtoets.Storage.Test.Read.ClosingStructures
{
[TestFixture]
public class ClosingStructuresSectionResultEntityReadExtensionsTest
{
[Test]
+ public void Read_EntityNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((ClosingStructuresSectionResultEntity) null).Read(
+ new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()),
+ new ReadConversionCollector());
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
public void Read_SectionResultIsNull_ThrowArgumentNullException()
{
// Setup
@@ -69,45 +82,52 @@
{
// Setup
var random = new Random(21);
- var layerOne = random.NextEnumValue();
- double layerThree = random.NextDouble();
+ var simpleAssessmentResult = random.NextEnumValue();
+ var detailedAssessmentResult = random.NextEnumValue();
+ var tailorMadeAssessmentResult = random.NextEnumValue();
+ double tailorMadeAssessmentProbability = random.NextDouble();
+ bool useManualAssemblyProbability = random.NextBoolean();
+ double manualAssemblyProbability = random.NextDouble();
var collector = new ReadConversionCollector();
var failureMechanismSectionEntity = new FailureMechanismSectionEntity();
collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection());
var entity = new ClosingStructuresSectionResultEntity
{
- LayerThree = layerThree,
- LayerOne = Convert.ToByte(layerOne),
- FailureMechanismSectionEntity = failureMechanismSectionEntity
+ FailureMechanismSectionEntity = failureMechanismSectionEntity,
+ SimpleAssessmentResult = Convert.ToByte(simpleAssessmentResult),
+ DetailedAssessmentResult = Convert.ToByte(detailedAssessmentResult),
+ TailorMadeAssessmentResult = Convert.ToByte(tailorMadeAssessmentResult),
+ TailorMadeAssessmentProbability = tailorMadeAssessmentProbability,
+ UseManualAssemblyProbability = Convert.ToByte(useManualAssemblyProbability),
+ ManualAssemblyProbability = manualAssemblyProbability
};
var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection());
// Call
entity.Read(sectionResult, collector);
// Assert
- Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne);
- Assert.AreEqual(layerThree, sectionResult.TailorMadeAssessmentProbability, 1e-6);
+ Assert.AreEqual(simpleAssessmentResult, sectionResult.SimpleAssessmentResult);
+ Assert.AreEqual(detailedAssessmentResult, sectionResult.DetailedAssessmentResult);
+ Assert.AreEqual(tailorMadeAssessmentResult, sectionResult.TailorMadeAssessmentResult);
+ Assert.AreEqual(tailorMadeAssessmentProbability, sectionResult.TailorMadeAssessmentProbability, 1e-6);
+ Assert.AreEqual(useManualAssemblyProbability, sectionResult.UseManualAssemblyProbability);
+ Assert.AreEqual(manualAssemblyProbability, sectionResult.ManualAssemblyProbability, 1e-6);
Assert.IsNull(sectionResult.Calculation);
}
[Test]
public void Read_EntityWithNullValues_SectionResultWithNaNValues()
{
// Setup
- var random = new Random(21);
- var layerOne = random.NextEnumValue();
-
var collector = new ReadConversionCollector();
var failureMechanismSectionEntity = new FailureMechanismSectionEntity();
collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection());
var entity = new ClosingStructuresSectionResultEntity
{
- LayerThree = null,
- LayerOne = Convert.ToByte(random.NextEnumValue()),
FailureMechanismSectionEntity = failureMechanismSectionEntity
};
var sectionResult = new ClosingStructuresFailureMechanismSectionResult(new TestFailureMechanismSection());
@@ -116,8 +136,8 @@
entity.Read(sectionResult, collector);
// Assert
- Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne);
Assert.IsNaN(sectionResult.TailorMadeAssessmentProbability);
+ Assert.IsNaN(sectionResult.ManualAssemblyProbability);
Assert.IsNull(sectionResult.Calculation);
}