Index: Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/DatabaseStructure17.2.sql =================================================================== diff -u -r1ba21a629ef9ee35b003e5f5e66f26f5b8bc7766 -r3aae00632d922ad6a995a79de25ff4da07e6b57a --- Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/DatabaseStructure17.2.sql (.../DatabaseStructure17.2.sql) (revision 1ba21a629ef9ee35b003e5f5e66f26f5b8bc7766) +++ Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/DatabaseStructure17.2.sql (.../DatabaseStructure17.2.sql) (revision 3aae00632d922ad6a995a79de25ff4da07e6b57a) @@ -1,6 +1,6 @@ /* ---------------------------------------------------- */ /* Generated by Enterprise Architect Version 12.0 */ -/* Created On : 21-Sep-2017 9:03:22 AM */ +/* Created On : 28-Sep-2017 2:48:18 PM */ /* DBMS : SQLite */ /* ---------------------------------------------------- */ @@ -847,7 +847,6 @@ 'MacroStabilityInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'FailureMechanismSectionEntityId' INTEGER NOT NULL, 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict - 'LayerTwoA' REAL, 'LayerThree' REAL, CONSTRAINT 'FK_MacroStabilityInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade ) Index: Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql =================================================================== diff -u -r0641053e020a1478f793ee17e753df60af26171f -r3aae00632d922ad6a995a79de25ff4da07e6b57a --- Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql (.../Migration_17.1_17.2.sql) (revision 0641053e020a1478f793ee17e753df60af26171f) +++ Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql (.../Migration_17.1_17.2.sql) (revision 3aae00632d922ad6a995a79de25ff4da07e6b57a) @@ -1057,13 +1057,11 @@ [MacroStabilityInwardsSectionResultEntityId], [FailureMechanismSectionEntityId], [LayerOne], - [LayerTwoA], [LayerThree]) SELECT [MacrostabilityInwardsSectionResultEntityId], [FailureMechanismSectionEntityId], [LayerOne], - [LayerTwoA], CASE WHEN [LayerThree] > 1 OR [LayerThree] < 0 THEN NULL Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/MacroStabilityInwardsSectionResultEntity.cs =================================================================== diff -u -r334d67567ece149b04b876ce3576a8d246b5c97c -r3aae00632d922ad6a995a79de25ff4da07e6b57a --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/MacroStabilityInwardsSectionResultEntity.cs (.../MacroStabilityInwardsSectionResultEntity.cs) (revision 334d67567ece149b04b876ce3576a8d246b5c97c) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/MacroStabilityInwardsSectionResultEntity.cs (.../MacroStabilityInwardsSectionResultEntity.cs) (revision 3aae00632d922ad6a995a79de25ff4da07e6b57a) @@ -35,7 +35,6 @@ public long MacroStabilityInwardsSectionResultEntityId { get; set; } public long FailureMechanismSectionEntityId { get; set; } public byte LayerOne { get; set; } - public double? LayerTwoA { get; set; } public double? LayerThree { get; set; } public virtual FailureMechanismSectionEntity FailureMechanismSectionEntity { get; set; } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx =================================================================== diff -u -re08b5ce64ea11d4f631c96acf8c7bf7f33865f78 -r3aae00632d922ad6a995a79de25ff4da07e6b57a --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision e08b5ce64ea11d4f631c96acf8c7bf7f33865f78) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx (.../RingtoetsEntities.edmx) (revision 3aae00632d922ad6a995a79de25ff4da07e6b57a) @@ -705,7 +705,6 @@ - @@ -4854,7 +4853,6 @@ - @@ -7719,7 +7717,6 @@ - Index: Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram =================================================================== diff -u -re08b5ce64ea11d4f631c96acf8c7bf7f33865f78 -r3aae00632d922ad6a995a79de25ff4da07e6b57a --- Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision e08b5ce64ea11d4f631c96acf8c7bf7f33865f78) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/DbContext/RingtoetsEntities.edmx.diagram (.../RingtoetsEntities.edmx.diagram) (revision 3aae00632d922ad6a995a79de25ff4da07e6b57a) @@ -5,94 +5,94 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + - - - - - + + + + + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensions.cs =================================================================== diff -u -r36d13a2d6fade97d565f186f5eaec5d382cba27a -r3aae00632d922ad6a995a79de25ff4da07e6b57a --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensions.cs (.../MacroStabilityInwardsSectionResultEntityReadExtensions.cs) (revision 36d13a2d6fade97d565f186f5eaec5d382cba27a) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensions.cs (.../MacroStabilityInwardsSectionResultEntityReadExtensions.cs) (revision 3aae00632d922ad6a995a79de25ff4da07e6b57a) @@ -21,7 +21,6 @@ using System; using Application.Ringtoets.Storage.DbContext; -using Core.Common.Base.Data; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.MacroStabilityInwards.Data; @@ -37,19 +36,23 @@ /// Reads the and use the information to update a /// . /// - /// The to create for. + /// The to + /// update the for. /// The target of the read operation. - /// A new . - /// Thrown when is null. - internal static void Read(this MacroStabilityInwardsSectionResultEntity entity, MacroStabilityInwardsFailureMechanismSectionResult sectionResult) + /// Thrown when any parameter is null. + public static void Read(this MacroStabilityInwardsSectionResultEntity entity, MacroStabilityInwardsFailureMechanismSectionResult sectionResult) { + if (entity == null) + { + throw new ArgumentNullException(nameof(entity)); + } if (sectionResult == null) { throw new ArgumentNullException(nameof(sectionResult)); } sectionResult.AssessmentLayerOne = (AssessmentLayerOneState) entity.LayerOne; - sectionResult.AssessmentLayerThree = (RoundedDouble) entity.LayerThree.ToNullAsNaN(); + sectionResult.AssessmentLayerThree = entity.LayerThree.ToNullAsNaN(); } } } \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u -r85cf65b38e2e96810139a8490fec8eb5b95837a6 -r3aae00632d922ad6a995a79de25ff4da07e6b57a --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs (.../MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs) (revision 85cf65b38e2e96810139a8490fec8eb5b95837a6) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs (.../MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs) (revision 3aae00632d922ad6a995a79de25ff4da07e6b57a) @@ -24,6 +24,7 @@ using Application.Ringtoets.Storage.Read; using Application.Ringtoets.Storage.Read.MacroStabilityInwards; using Application.Ringtoets.Storage.TestUtil; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.MacroStabilityInwards.Data; @@ -34,6 +35,20 @@ public class MacroStabilityInwardsSectionResultEntityReadExtensionsTest { [Test] + public void Read_EntityNull_ThrowsArgumentNullException() + { + // Setup + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + TestDelegate test = () => ((MacroStabilityInwardsSectionResultEntity) null).Read(sectionResult); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("entity", exception.ParamName); + } + + [Test] public void Read_SectionResultIsNull_ThrowArgumentNullException() { // Setup @@ -48,22 +63,19 @@ } [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_SetsSectionResultWithParameterValues() { // Setup + var random = new Random(31); var collector = new ReadConversionCollector(); + var layerOne = random.NextEnumValue(); + double layerThree = random.NextDouble(); var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); var entity = new MacroStabilityInwardsSectionResultEntity { LayerThree = layerThree, - LayerTwoA = layerTwoA, LayerOne = Convert.ToByte(layerOne), FailureMechanismSectionEntity = failureMechanismSectionEntity }; @@ -75,7 +87,35 @@ // Assert Assert.IsNotNull(sectionResult); Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); - Assert.AreEqual(layerThree ?? double.NaN, sectionResult.AssessmentLayerThree, 1e-6); + Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); } + + [Test] + public void Read_WithNullValues_SetsSectionResultWithNaNValues() + { + // Setup + var random = new Random(31); + var collector = new ReadConversionCollector(); + var layerOne = random.NextEnumValue(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + + var entity = new MacroStabilityInwardsSectionResultEntity + { + LayerThree = null, + LayerOne = Convert.ToByte(layerOne), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult); + + // Assert + Assert.IsNotNull(sectionResult); + Assert.AreEqual(layerOne, sectionResult.AssessmentLayerOne); + Assert.IsNaN(sectionResult.AssessmentLayerThree); + } } } \ No newline at end of file Index: build/DatabaseStructure.sql =================================================================== diff -u -r1ba21a629ef9ee35b003e5f5e66f26f5b8bc7766 -r3aae00632d922ad6a995a79de25ff4da07e6b57a --- build/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision 1ba21a629ef9ee35b003e5f5e66f26f5b8bc7766) +++ build/DatabaseStructure.sql (.../DatabaseStructure.sql) (revision 3aae00632d922ad6a995a79de25ff4da07e6b57a) @@ -1,6 +1,6 @@ /* ---------------------------------------------------- */ /* Generated by Enterprise Architect Version 12.0 */ -/* Created On : 21-Sep-2017 9:03:22 AM */ +/* Created On : 28-Sep-2017 2:48:18 PM */ /* DBMS : SQLite */ /* ---------------------------------------------------- */ @@ -847,7 +847,6 @@ 'MacroStabilityInwardsSectionResultEntityId' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 'FailureMechanismSectionEntityId' INTEGER NOT NULL, 'LayerOne' TINYINT (1) NOT NULL, -- Enum: 1 = NotAssessed, 2 = Sufficient, 3 = NoVerdict - 'LayerTwoA' REAL, 'LayerThree' REAL, CONSTRAINT 'FK_MacroStabilityInwardsSectionResultEntity_FailureMechanismSectionEntity' FOREIGN KEY ('FailureMechanismSectionEntityId') REFERENCES 'FailureMechanismSectionEntity' ('FailureMechanismSectionEntityId') ON DELETE Cascade ON UPDATE Cascade ) Index: design/DatabaseDesign.eap =================================================================== diff -u -r56b38a0c5072db8091b568c324673687e33a1c23 -r3aae00632d922ad6a995a79de25ff4da07e6b57a Binary files differ