Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSoilProfileEntityReadExtensionsTest.cs =================================================================== diff -u -r8c6f5442c5e135d2ef3a67161b7d4d5c24fb21a2 -r2d2bea96014455b3ba10a7ba20b8aa1a2d633fca --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSoilProfileEntityReadExtensionsTest.cs (.../PipingSoilProfileEntityReadExtensionsTest.cs) (revision 8c6f5442c5e135d2ef3a67161b7d4d5c24fb21a2) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingSoilProfileEntityReadExtensionsTest.cs (.../PipingSoilProfileEntityReadExtensionsTest.cs) (revision 2d2bea96014455b3ba10a7ba20b8aa1a2d633fca) @@ -65,13 +65,12 @@ public void Read_WithCollector_ReturnsNewPipingSoilProfileWithPropertiesSet() { // Setup - const string testName = "testName"; var random = new Random(21); double bottom = random.NextDouble(); var sourceType = random.NextEnumValue(); var entity = new PipingSoilProfileEntity { - Name = testName, + Name = "testName", Bottom = bottom, SourceType = (byte) sourceType, PipingSoilLayerEntities = @@ -97,7 +96,7 @@ // Assert Assert.IsNotNull(profile); - Assert.AreEqual(testName, profile.Name); + Assert.AreEqual(entity.Name, profile.Name); Assert.AreEqual(bottom, profile.Bottom, 1e-6); Assert.AreEqual(sourceType, profile.SoilProfileSourceType); CollectionAssert.AreEqual(new[] @@ -131,65 +130,42 @@ Assert.IsNotNull(profile); Assert.AreEqual(entity.Name, profile.Name); Assert.IsNaN(profile.Bottom); - Assert.AreEqual(1, profile.Layers.Count()); + Assert.AreEqual(entity.PipingSoilLayerEntities.Count, profile.Layers.Count()); PipingSoilLayer layer = profile.Layers.ElementAt(0); - Assert.IsNaN(layer.Top); Assert.AreEqual(entity.PipingSoilLayerEntities.First().MaterialName, layer.MaterialName); } [Test] - public void Read_WithCollectorWithoutLayers_ThrowsArgumentException() + public void GivenReadObject_WhenReadCalledOnSameEntity_ThenSameObjectInstanceReturned() { - // Setup + // Given var random = new Random(21); var entity = new PipingSoilProfileEntity { - Name = "Name", + Name = "testName", Bottom = random.NextDouble(), - SourceType = (byte) random.NextEnumValue() - }; - var collector = new ReadConversionCollector(); - - // Call - TestDelegate test = () => entity.Read(collector); - - // Assert - Assert.Throws(test); - } - - [Test] - public void Read_WithCollectorReadTwice_ReturnsSamePipingSoilProfile() - { - // Setup - const string testName = "testName"; - var random = new Random(21); - double bottom = random.NextDouble(); - var entity = new PipingSoilProfileEntity - { - Name = testName, - Bottom = bottom, SourceType = (byte) random.NextEnumValue(), PipingSoilLayerEntities = { new PipingSoilLayerEntity { - Top = bottom + 0.5 + Top = random.NextDouble() + 0.5 }, new PipingSoilLayerEntity { - Top = bottom + 1.2 + Top = random.NextDouble() + 1.2 } } }; var collector = new ReadConversionCollector(); PipingSoilProfile profile = entity.Read(collector); - // Call + // When PipingSoilProfile secondProfile = entity.Read(collector); - // Assert + // Then Assert.AreSame(profile, secondProfile); } }