Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityOutwards/MacroStabilityOutwardsSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r36d4b4090a4169cc8d25ede0029a3244df8fe74d -rb8df616ca911988b921b933bead5f1ef6862d076 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityOutwards/MacroStabilityOutwardsSectionResultEntityReadExtensionsTest.cs (.../MacroStabilityOutwardsSectionResultEntityReadExtensionsTest.cs) (revision 36d4b4090a4169cc8d25ede0029a3244df8fe74d) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityOutwards/MacroStabilityOutwardsSectionResultEntityReadExtensionsTest.cs (.../MacroStabilityOutwardsSectionResultEntityReadExtensionsTest.cs) (revision b8df616ca911988b921b933bead5f1ef6862d076) @@ -21,9 +21,10 @@ using System; using Application.Ringtoets.Storage.DbContext; -using Application.Ringtoets.Storage.Read.MacroStabilityOutwards; using Application.Ringtoets.Storage.Read; +using Application.Ringtoets.Storage.Read.MacroStabilityOutwards; using Application.Ringtoets.Storage.TestUtil; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Integration.Data.StandAlone.SectionResults; @@ -48,15 +49,14 @@ } [Test] - [Combinatorial] - public void Read_ParameterValues_SectionResultWithParameterValues( - [Values(AssessmentLayerOneState.NotAssessed, AssessmentLayerOneState.NoVerdict, - AssessmentLayerOneState.Sufficient)] - AssessmentLayerOneState layerOne, - [Values(0.1, 0.2, null)] double? layerTwoA, - [Values(0.11, 0.22, null)] double? layerThree) + public void Read_ParameterValues_SectionResultWithParameterValues() { // Setup + var random = new Random(21); + var layerOne = random.NextEnumValue(); + double layerTwoA = random.NextDouble(); + double layerThree = random.NextDouble(); + var collector = new ReadConversionCollector(); var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); @@ -74,10 +74,38 @@ entity.Read(sectionResult); // Assert - Assert.IsNotNull(sectionResult); Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); - Assert.AreEqual(layerTwoA ?? double.NaN, sectionResult.AssessmentLayerTwoA, 1e-6); - Assert.AreEqual(layerThree ?? double.NaN, sectionResult.AssessmentLayerThree, 1e-6); + Assert.AreEqual(layerTwoA, sectionResult.AssessmentLayerTwoA, 1e-6); + Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); } + + [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 MacroStabilityOutwardsSectionResultEntity + { + LayerThree = null, + LayerTwoA = null, + LayerOne = Convert.ToByte(layerOne), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new MacroStabilityOutwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult); + + // Assert + Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); + Assert.IsNaN(sectionResult.AssessmentLayerTwoA); + Assert.IsNaN(sectionResult.AssessmentLayerThree); + } } } \ No newline at end of file