Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u -r8e213638a22dd9f04d965d875bb58156db019be5 -r668c7fb9df618f1c1e1fc0b5ab2ae3ab58c85d8e --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsFailureMechanismCreateExtensionsTest.cs (.../MacroStabilityInwardsFailureMechanismCreateExtensionsTest.cs) (revision 8e213638a22dd9f04d965d875bb58156db019be5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsFailureMechanismCreateExtensionsTest.cs (.../MacroStabilityInwardsFailureMechanismCreateExtensionsTest.cs) (revision 668c7fb9df618f1c1e1fc0b5ab2ae3ab58c85d8e) @@ -52,7 +52,7 @@ } [Test] - public void Create_WithCollectorAndPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet() + public void Create_WithoutAllPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet() { // Setup var random = new Random(31); @@ -86,15 +86,61 @@ Assert.AreEqual(failureMechanism.NotRelevantComments.Body, entity.NotRelevantComments); CollectionAssert.IsEmpty(entity.StochasticSoilModelEntities); - MacroStabilityInwardsFailureMechanismMetaEntity failureMechanismMetaEntity = entity.MacroStabilityInwardsFailureMechanismMetaEntities.ToArray()[0]; + MacroStabilityInwardsFailureMechanismMetaEntity failureMechanismMetaEntity = entity.MacroStabilityInwardsFailureMechanismMetaEntities.First(); Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.A, failureMechanismMetaEntity.A); - Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.B, failureMechanismMetaEntity.B); Assert.IsNull(failureMechanismMetaEntity.SectionLength); Assert.IsNull(failureMechanismMetaEntity.StochasticSoilModelCollectionSourcePath); Assert.IsNull(failureMechanismMetaEntity.SurfaceLineCollectionSourcePath); } [Test] + public void Create_WithPropertiesSet_ReturnsFailureMechanismEntityWithPropertiesSet() + { + // Setup + var random = new Random(31); + var failureMechanism = new MacroStabilityInwardsFailureMechanism + { + IsRelevant = random.NextBoolean(), + InputComments = + { + Body = "Some input text" + }, + OutputComments = + { + Body = "Some output text" + }, + NotRelevantComments = + { + Body = "Really not relevant" + }, + MacroStabilityInwardsProbabilityAssessmentInput = + { + A = random.NextDouble(), + SectionLength = random.NextDouble() + } + }; + var registry = new PersistenceRegistry(); + + // Call + FailureMechanismEntity entity = failureMechanism.Create(registry); + + // Assert + Assert.IsNotNull(entity); + Assert.AreEqual((short) FailureMechanismType.MacroStabilityInwards, entity.FailureMechanismType); + Assert.AreEqual(Convert.ToByte(failureMechanism.IsRelevant), entity.IsRelevant); + Assert.AreEqual(failureMechanism.InputComments.Body, entity.InputComments); + Assert.AreEqual(failureMechanism.OutputComments.Body, entity.OutputComments); + Assert.AreEqual(failureMechanism.NotRelevantComments.Body, entity.NotRelevantComments); + + CollectionAssert.IsEmpty(entity.StochasticSoilModelEntities); + MacroStabilityInwardsFailureMechanismMetaEntity failureMechanismMetaEntity = entity.MacroStabilityInwardsFailureMechanismMetaEntities.First(); + Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.A, failureMechanismMetaEntity.A); + Assert.AreEqual(failureMechanism.MacroStabilityInwardsProbabilityAssessmentInput.SectionLength, failureMechanismMetaEntity.SectionLength); + Assert.IsNull(failureMechanismMetaEntity.StochasticSoilModelCollectionSourcePath); + Assert.IsNull(failureMechanismMetaEntity.SurfaceLineCollectionSourcePath); + } + + [Test] public void Create_StringPropertiesDoNotShareReference() { // Setup