Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r070c0400906eb4cfbd4fdcfbf1e49d4dfeec7856 -r20355a15fa557bb6a66ee12a64456cefc3156b90 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 070c0400906eb4cfbd4fdcfbf1e49d4dfeec7856) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 20355a15fa557bb6a66ee12a64456cefc3156b90) @@ -564,6 +564,11 @@ Ringtoets.ClosingStructures.Data False + + {78aa56f5-431d-465c-ac50-3173d7e90ac1} + Ringtoets.Common.Primitives + False + {6A074D65-A81C-4C1C-8E24-F36C916E4ED7} Ringtoets.Common.Util Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensions.cs =================================================================== diff -u -r8d37f4040238a84405d8f08363ec706232a35326 -r20355a15fa557bb6a66ee12a64456cefc3156b90 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensions.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensions.cs) (revision 8d37f4040238a84405d8f08363ec706232a35326) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensions.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensions.cs) (revision 20355a15fa557bb6a66ee12a64456cefc3156b90) @@ -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 HeightStructuresSectionResultEntity Create(this HeightStructuresFailureMechanismSectionResult result, PersistenceRegistry registry) { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + if (registry == null) { throw new ArgumentNullException(nameof(registry)); } var sectionResultEntity = new HeightStructuresSectionResultEntity { - 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/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r070c0400906eb4cfbd4fdcfbf1e49d4dfeec7856 -r20355a15fa557bb6a66ee12a64456cefc3156b90 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 070c0400906eb4cfbd4fdcfbf1e49d4dfeec7856) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 20355a15fa557bb6a66ee12a64456cefc3156b90) @@ -287,6 +287,10 @@ {f5b43c29-6169-4e9a-859e-09090330b94e} Ringtoets.ClosingStructures.Data.TestUtil + + {78AA56F5-431D-465C-AC50-3173D7E90AC1} + Ringtoets.Common.Primitives + {6A074D65-A81C-4C1C-8E24-F36C916E4ED7} Ringtoets.Common.Util Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs =================================================================== diff -u -r4cdd6c4ecd15eba7d16363e42b7a6dcae4169bd0 -r20355a15fa557bb6a66ee12a64456cefc3156b90 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 4cdd6c4ecd15eba7d16363e42b7a6dcae4169bd0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HeightStructures/HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs (.../HeightStructuresFailureMechanismSectionResultCreateExtensionsTest.cs) (revision 20355a15fa557bb6a66ee12a64456cefc3156b90) @@ -24,11 +24,10 @@ using Application.Ringtoets.Storage.Create.HeightStructures; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.TestUtil; -using Core.Common.Base.Data; using Core.Common.TestUtil; using NUnit.Framework; -using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Primitives; using Ringtoets.HeightStructures.Data; namespace Application.Ringtoets.Storage.Test.Create.HeightStructures @@ -37,8 +36,19 @@ public class HeightStructuresFailureMechanismSectionResultCreateExtensionsTest { [Test] - public void Create_WithoutPersistenceRegistry_ThrowsArgumentNullException() + public void Create_FailureMechanismSectionResultNull_ThrowsArgumentNullException() { + // Call + TestDelegate call = () => HeightStructuresFailureMechanismSectionResultCreateExtensions.Create(null, new PersistenceRegistry()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("result", exception.ParamName); + } + + [Test] + public void Create_PersistenceRegistryNull_ThrowsArgumentNullException() + { // Setup var sectionResult = new HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()); @@ -55,38 +65,52 @@ { // 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 HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) { - AssessmentLayerOne = assessmentLayerOneResult, - TailorMadeAssessmentProbability = tailorMadeAssessmentProbability + SimpleAssessmentResult = simpleAssessmentResult, + DetailedAssessmentResult = detailedAssessmentResult, + TailorMadeAssessmentResult = tailorMadeAssessmentResult, + TailorMadeAssessmentProbability = tailorMadeAssessmentProbability, + UseManualAssemblyProbability = useManualAssemblyProbability, + ManualAssemblyProbability = manualAssemblyProbability }; // Call - HeightStructuresSectionResultEntity result = sectionResult.Create(new PersistenceRegistry()); + HeightStructuresSectionResultEntity entity = sectionResult.Create(new PersistenceRegistry()); // Assert - Assert.AreEqual(Convert.ToByte(assessmentLayerOneResult), result.LayerOne); - Assert.AreEqual(tailorMadeAssessmentProbability, result.LayerThree); - Assert.IsNull(result.HeightStructuresCalculationEntityId); + 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.HeightStructuresCalculationEntityId); } [Test] - public void Create_WithNaNTailorMadeAssessmentProbability_ReturnsEntityWithExpectedResults() + public void Create_SectionResultWithNaNValues_ReturnsEntityWithExpectedResults() { // Setup var sectionResult = new HeightStructuresFailureMechanismSectionResult(new TestFailureMechanismSection()) { - TailorMadeAssessmentProbability = double.NaN + TailorMadeAssessmentProbability = double.NaN, + ManualAssemblyProbability = double.NaN }; // Call - HeightStructuresSectionResultEntity result = sectionResult.Create(new PersistenceRegistry()); + HeightStructuresSectionResultEntity entity = sectionResult.Create(new PersistenceRegistry()); // Assert - Assert.IsNull(result.LayerThree); + Assert.IsNull(entity.TailorMadeAssessmentProbability); + Assert.IsNull(entity.ManualAssemblyProbability); } [Test] @@ -100,14 +124,14 @@ }; var registry = new PersistenceRegistry(); - var entity = new HeightStructuresCalculationEntity(); - registry.Register(entity, calculation); + var calculationEntity = new HeightStructuresCalculationEntity(); + registry.Register(calculationEntity, calculation); // Call - HeightStructuresSectionResultEntity result = sectionResult.Create(registry); + HeightStructuresSectionResultEntity entity = sectionResult.Create(registry); // Assert - Assert.AreSame(entity, result.HeightStructuresCalculationEntity); + Assert.AreSame(calculationEntity, entity.HeightStructuresCalculationEntity); } } } \ No newline at end of file