Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj =================================================================== diff -u -r268d5940d8ed4a65319179de7515eaf89586ad0a -r85cf65b38e2e96810139a8490fec8eb5b95837a6 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 268d5940d8ed4a65319179de7515eaf89586ad0a) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 85cf65b38e2e96810139a8490fec8eb5b95837a6) @@ -495,17 +495,17 @@ - + - + - + Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs =================================================================== diff -u -rf05b4b6bbe032a1c358f2a4ffe4f5ff6726d8000 -r85cf65b38e2e96810139a8490fec8eb5b95837a6 --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision f05b4b6bbe032a1c358f2a4ffe4f5ff6726d8000) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision 85cf65b38e2e96810139a8490fec8eb5b95837a6) @@ -28,6 +28,7 @@ using Application.Ringtoets.Storage.Read.GrassCoverErosionInwards; using Application.Ringtoets.Storage.Read.GrassCoverErosionOutwards; using Application.Ringtoets.Storage.Read.HeightStructures; +using Application.Ringtoets.Storage.Read.MacroStabilityInwards; using Application.Ringtoets.Storage.Read.Piping; using Application.Ringtoets.Storage.Read.PipingStructures; using Application.Ringtoets.Storage.Read.StabilityPointStructures; Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensions.cs =================================================================== diff -u --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensions.cs (revision 0) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensions.cs (revision 85cf65b38e2e96810139a8490fec8eb5b95837a6) @@ -0,0 +1,55 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.DbContext; +using Core.Common.Base.Data; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.MacroStabilityInwards.Data; + +namespace Application.Ringtoets.Storage.Read.MacroStabilityInwards +{ + /// + /// This class defines extension methods for read operations for a based on the + /// . + /// + internal static class MacroStabilityInwardsSectionResultEntityReadExtensions + { + /// + /// Reads the and use the information to update a + /// . + /// + /// The to create for. + /// The target of the read operation. + /// A new . + /// Thrown when is null. + internal static void Read(this MacroStabilityInwardsSectionResultEntity entity, MacroStabilityInwardsFailureMechanismSectionResult sectionResult) + { + if (sectionResult == null) + { + throw new ArgumentNullException(nameof(sectionResult)); + } + + sectionResult.AssessmentLayerOne = (AssessmentLayerOneState) entity.LayerOne; + sectionResult.AssessmentLayerThree = (RoundedDouble) entity.LayerThree.ToNullAsNaN(); + } + } +} \ No newline at end of file Fisheye: Tag 85cf65b38e2e96810139a8490fec8eb5b95837a6 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwardsSectionResultEntityReadExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 85cf65b38e2e96810139a8490fec8eb5b95837a6 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/PipingSurfaceLineEntityReadExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 85cf65b38e2e96810139a8490fec8eb5b95837a6 refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/StochasticSoilModelEntityReadExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a5714fc0488030773fff50dfc82041c6cb9edc2f refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Read/StochasticSoilModelEntityReadExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a5714fc0488030773fff50dfc82041c6cb9edc2f refers to a dead (removed) revision in file `Application/Ringtoets/src/Application.Ringtoets.Storage/Read/SurfaceLineEntityReadExtensions.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r268d5940d8ed4a65319179de7515eaf89586ad0a -r85cf65b38e2e96810139a8490fec8eb5b95837a6 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 268d5940d8ed4a65319179de7515eaf89586ad0a) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 85cf65b38e2e96810139a8490fec8eb5b95837a6) @@ -238,17 +238,17 @@ - + - + - + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs =================================================================== diff -u -rcf2b4ca40987c1f035b244cc80a382a2bf2cc12b -r85cf65b38e2e96810139a8490fec8eb5b95837a6 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision cf2b4ca40987c1f035b244cc80a382a2bf2cc12b) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/PersistenceRegistryTest.cs (.../PersistenceRegistryTest.cs) (revision 85cf65b38e2e96810139a8490fec8eb5b95837a6) @@ -73,10 +73,10 @@ } [TestFixture] - private class PipingStochasticSoilModelTest : RegistryTest { - public PipingStochasticSoilModelTest() : base( + public PipingStochasticSoilModelRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -88,10 +88,10 @@ } [TestFixture] - private class PipingStochasticSoilProfileTest : RegistryTest { - public PipingStochasticSoilProfileTest() : base( + public PipingStochasticSoilProfileRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -103,10 +103,10 @@ } [TestFixture] - private class PipingSoilProfileTest : RegistryTest { - public PipingSoilProfileTest() : base( + public PipingSoilProfileRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -118,10 +118,10 @@ } [TestFixture] - private class PipingSurfaceLineTest : RegistryTest { - public PipingSurfaceLineTest() : base( + public PipingSurfaceLineRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -133,10 +133,10 @@ } [TestFixture] - private class MacroStabilityInwardsStochasticSoilModelTest : RegistryTest { - public MacroStabilityInwardsStochasticSoilModelTest() : base( + public MacroStabilityInwardsStochasticSoilModelRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -148,7 +148,7 @@ } [TestFixture] - private class MacroStabilityInwardsStochasticSoilProfileTest : RegistryTest { private MockRepository mockRepository; @@ -165,7 +165,7 @@ mockRepository.VerifyAll(); } - public MacroStabilityInwardsStochasticSoilProfileTest() : base( + public MacroStabilityInwardsStochasticSoilProfileRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -180,10 +180,10 @@ } [TestFixture] - private class MacroStabilityInwardsSoilProfile1DTest : RegistryTest { - public MacroStabilityInwardsSoilProfile1DTest() : base( + public MacroStabilityInwardsSoilProfile1DRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -195,10 +195,10 @@ } [TestFixture] - private class MacroStabilityInwardsSoilProfile2DTest : RegistryTest { - public MacroStabilityInwardsSoilProfile2DTest() : base( + public MacroStabilityInwardsSoilProfile2DRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -217,10 +217,10 @@ } [TestFixture] - private class MacroStabilityInwardsSurfaceLineTest : RegistryTest { - public MacroStabilityInwardsSurfaceLineTest() : base( + public MacroStabilityInwardsSurfaceLineRegistryTest() : base( (r, e, m) => r.Register(e, m), (r, m) => r.Contains(m), (r, m) => r.Get(m)) {} @@ -231,14 +231,55 @@ } } - [TestFixture] + /// + /// Test class to test the for the combination of + /// and . + /// + /// The data model. + /// The database entity. private abstract class RegistryTest where TDataModel : class where TEntity : class, new() { private readonly Action registerToRegistry; private readonly Func containsInRegistry; private readonly Func getFromRegistry; + /// + /// Creates a new instance of . + /// + /// The action to perform to register the data model + /// to the registry. + /// The action to perform to check whether the data + /// model is registered in the registry. + /// The action to perform to get the data model from + /// the registry. + /// Thrown when any input parameter is null. + /// public DerivedRegistryTest() : base( + /// (r, e, m) => r.Register(e, m), + /// (r, m) => r.Contains(m), + /// (r, m) => r.Get(m)) {} + protected RegistryTest(Action registerToRegistry, + Func containsInRegistry, + Func getFromRegistry) + { + if (registerToRegistry == null) + { + throw new ArgumentNullException(nameof(registerToRegistry)); + } + if (containsInRegistry == null) + { + throw new ArgumentNullException(nameof(containsInRegistry)); + } + if (getFromRegistry == null) + { + throw new ArgumentNullException(nameof(getFromRegistry)); + } + + this.registerToRegistry = registerToRegistry; + this.containsInRegistry = containsInRegistry; + this.getFromRegistry = getFromRegistry; + } + [Test] public void Register_WithNullEntity_ThrowsArgumentNullException() { @@ -370,45 +411,9 @@ } /// - /// Creates a new instance of . - /// - /// The action to perform to register the data model - /// to the registry. - /// The action to perform to check whether the data - /// model is registered in the registry. - /// The action to perform to get the data model from - /// the registry. - /// Thrown when any input parameter is null. - /// public DerivedRegistryTest() : base( - /// (r, e, m) => r.Register(e, m), - /// (r, m) => r.Contains(m), - /// (r, m) => r.Get(m)) {} - protected RegistryTest(Action registerToRegistry, - Func containsInRegistry, - Func getFromRegistry) - { - if (registerToRegistry == null) - { - throw new ArgumentNullException(nameof(registerToRegistry)); - } - if (containsInRegistry == null) - { - throw new ArgumentNullException(nameof(containsInRegistry)); - } - if (getFromRegistry == null) - { - throw new ArgumentNullException(nameof(getFromRegistry)); - } - - this.registerToRegistry = registerToRegistry; - this.containsInRegistry = containsInRegistry; - this.getFromRegistry = getFromRegistry; - } - - /// /// Creates a new instance of . /// - /// + /// An instance of . protected abstract TDataModel CreateDataModel(); } Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs (revision 85cf65b38e2e96810139a8490fec8eb5b95837a6) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Read; +using Application.Ringtoets.Storage.Read.MacroStabilityInwards; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.MacroStabilityInwards.Data; + +namespace Application.Ringtoets.Storage.Test.Read.MacroStabilityInwards +{ + [TestFixture] + public class MacroStabilityInwardsSectionResultEntityReadExtensionsTest + { + [Test] + public void Read_SectionResultIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new MacroStabilityInwardsSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResult", paramName); + } + + [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) + { + // Setup + var collector = new ReadConversionCollector(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new MacroStabilityInwardsSectionResultEntity + { + LayerThree = layerThree, + LayerTwoA = layerTwoA, + 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.AreEqual(layerThree ?? double.NaN, sectionResult.AssessmentLayerThree, 1e-6); + } + } +} \ No newline at end of file Fisheye: Tag 85cf65b38e2e96810139a8490fec8eb5b95837a6 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwardsSectionResultEntityReadExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 85cf65b38e2e96810139a8490fec8eb5b95837a6 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/StochasticSoilModelEntityReadExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 85cf65b38e2e96810139a8490fec8eb5b95837a6 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/SurfaceLineEntityReadExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs =================================================================== diff -u -rb0b8bffcbb871a42e6c8b282fe20858d6a738dbc -r85cf65b38e2e96810139a8490fec8eb5b95837a6 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision b0b8bffcbb871a42e6c8b282fe20858d6a738dbc) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/ReadConversionCollectorTest.cs (.../ReadConversionCollectorTest.cs) (revision 85cf65b38e2e96810139a8490fec8eb5b95837a6) @@ -47,307 +47,235 @@ [TestFixture] public class ReadConversionCollectorTest { - #region StochasticSoilProfileEntity: Read, Contains, Get - - [Test] - public void Contains_WithoutPipingStochasticSoilProfileEntity_ThrowsArgumentNullException() + /// + /// Test class to test the for the combination of + /// and . + /// + /// The data model. + /// The database entity. + private abstract class CollectorTest where TDataModel : class + where TEntity : class, new() { - // Setup - var collector = new ReadConversionCollector(); + private readonly Action registerToCollector; + private readonly Func containsInCollector; + private readonly Func getFromCollector; - // Call - TestDelegate test = () => collector.Contains((PipingStochasticSoilProfileEntity) null); + /// + /// Creates a new instance of . + /// + /// The action to perform to register the entity + /// to the collector. + /// The action to perform to check whether the entity + /// is registered in the collector. + /// The action to perform to get the entity from + /// the collector. + /// Thrown when any input parameter is null. + /// public CollectorTest() : base( + /// (c, e, m) => c.Read(e, m), + /// (c, e) => c.Contains(e), + /// (c, e) => c.Get(e)) {} + protected CollectorTest(Action registerToCollector, + Func containsInCollector, + Func getFromCollector) + { + if (registerToCollector == null) + { + throw new ArgumentNullException(nameof(registerToCollector)); + } + if (containsInCollector == null) + { + throw new ArgumentNullException(nameof(containsInCollector)); + } + if (getFromCollector == null) + { + throw new ArgumentNullException(nameof(getFromCollector)); + } - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } + this.registerToCollector = registerToCollector; + this.containsInCollector = containsInCollector; + this.getFromCollector = getFromCollector; + } - [Test] - public void Contains_PipingStochasticSoilProfileEntityAdded_ReturnsTrue() - { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingStochasticSoilProfileEntity(); - collector.Read(entity, new PipingStochasticSoilProfile(1, PipingSoilProfileTestFactory.CreatePipingSoilProfile())); + [Test] + public void Contains_EntityNull_ThrowsArgumentNullException() + { + // Setup + var collector = new ReadConversionCollector(); - // Call - bool result = collector.Contains(entity); + // Call + TestDelegate test = () => containsInCollector(collector, null); - // Assert - Assert.IsTrue(result); - } + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } - [Test] - public void Contains_NoPipingStochasticSoilProfileEntityAdded_ReturnsFalse() - { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingStochasticSoilProfileEntity(); + [Test] + public void Contains_DataModelAdded_ReturnsTrue() + { + // Setup + var collector = new ReadConversionCollector(); + var entity = new TEntity(); + registerToCollector(collector, entity, CreateDataModel()); - // Call - bool result = collector.Contains(entity); + // Call + bool result = containsInCollector(collector, entity); - // Assert - Assert.IsFalse(result); - } + // Assert + Assert.IsTrue(result); + } - [Test] - public void Contains_OtherPipingStochasticSoilProfileEntityAdded_ReturnsFalse() - { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingStochasticSoilProfileEntity(); - collector.Read(new PipingStochasticSoilProfileEntity(), new PipingStochasticSoilProfile( - 0.4, PipingSoilProfileTestFactory.CreatePipingSoilProfile())); + [Test] + public void Contains_NoDataModelAdded_ReturnsFalse() + { + // Setup + var collector = new ReadConversionCollector(); + var entity = new TEntity(); - // Call - bool result = collector.Contains(entity); + // Call + bool result = containsInCollector(collector, entity); - // Assert - Assert.IsFalse(result); - } + // Assert + Assert.IsFalse(result); + } - [Test] - public void Get_WithoutPipingStochasticSoilProfileEntity_ThrowsArgumentNullException() - { - // Setup - var collector = new ReadConversionCollector(); + [Test] + public void Contains_OtherEntityAdded_ReturnsFalse() + { + // Setup + var collector = new ReadConversionCollector(); + registerToCollector(collector, new TEntity(), CreateDataModel()); - // Call - TestDelegate test = () => collector.Get((PipingStochasticSoilProfileEntity) null); + // Call + bool result = containsInCollector(collector, new TEntity()); - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } + // Assert + Assert.IsFalse(result); + } - [Test] - public void Get_PipingStochasticSoilProfileEntityAdded_ReturnsReadStochasticSoilProfile() - { - // Setup - var collector = new ReadConversionCollector(); - var profile = new PipingStochasticSoilProfile(0.5, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); - var entity = new PipingStochasticSoilProfileEntity(); - collector.Read(entity, profile); + [Test] + public void Get_EntityNull_ThrowsArgumentNullException() + { + // Setup + var collector = new ReadConversionCollector(); - // Call - PipingStochasticSoilProfile result = collector.Get(entity); + // Call + TestDelegate test = () => getFromCollector(collector, null); - // Assert - Assert.AreSame(profile, result); - } + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } - [Test] - public void Get_NoPipingStochasticSoilProfileEntityAdded_ThrowsInvalidOperationException() - { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingStochasticSoilProfileEntity(); + [Test] + public void Get_DataModelAdded_ReturnsEntity() + { + // Setup + var collector = new ReadConversionCollector(); + TDataModel dataModel = CreateDataModel(); + var entity = new TEntity(); + registerToCollector(collector, entity, dataModel); - // Call - TestDelegate test = () => collector.Get(entity); + // Call + TDataModel result = getFromCollector(collector, entity); - // Assert - Assert.Throws(test); - } + // Assert + Assert.AreSame(dataModel, result); + } - [Test] - public void Get_OtherPipingStochasticSoilProfileEntityAdded_ThrowsInvalidOperationException() - { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingStochasticSoilProfileEntity(); - collector.Read(new PipingStochasticSoilProfileEntity(), new PipingStochasticSoilProfile( - 0.7, PipingSoilProfileTestFactory.CreatePipingSoilProfile())); + [Test] + public void Get_NoDataModelAdded_ThrowsInvalidOperationException() + { + // Setup + var collector = new ReadConversionCollector(); + var entity = new TEntity(); - // Call - TestDelegate test = () => collector.Get(entity); + // Call + TestDelegate test = () => getFromCollector(collector, entity); - // Assert - Assert.Throws(test); - } + // Assert + Assert.Throws(test); + } - [Test] - public void Read_WithNullStochasticSoilProfileEntity_ThrowsArgumentNullException() - { - // Setup - var collector = new ReadConversionCollector(); + [Test] + public void Get_OtherDataModelAdded_ThrowsInvalidOperationException() + { + // Setup + var collector = new ReadConversionCollector(); + registerToCollector(collector, new TEntity(), CreateDataModel()); - // Call - TestDelegate test = () => collector.Read(null, new PipingStochasticSoilProfile( - 0.7, PipingSoilProfileTestFactory.CreatePipingSoilProfile())); + // Call + TestDelegate test = () => getFromCollector(collector, new TEntity()); - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } + // Assert + Assert.Throws(test); + } - [Test] - public void Read_WithNullPipingStochasticSoilProfile_ThrowsArgumentNullException() - { - // Setup - var collector = new ReadConversionCollector(); + [Test] + public void Read_EntityNull_ThrowsArgumentNullException() + { + // Setup + var collector = new ReadConversionCollector(); - // Call - TestDelegate test = () => collector.Read(new PipingStochasticSoilProfileEntity(), null); + // Call + TestDelegate test = () => registerToCollector(collector, null, CreateDataModel()); - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("entity", paramName); + } - #endregion + [Test] + public void Read_DataModelNull_ThrowsArgumentNullException() + { + // Setup + var collector = new ReadConversionCollector(); - #region SoilProfileEntity: Read, Contains, Get + // Call + TestDelegate test = () => registerToCollector(collector, new TEntity(), null); - [Test] - public void Contains_WithoutPipingSoilProfileEntity_ThrowsArgumentNullException() - { - // Setup - var collector = new ReadConversionCollector(); + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("model", paramName); + } - // Call - TestDelegate test = () => collector.Contains((PipingSoilProfileEntity) null); - - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); + /// + /// Creates a new instance of . + /// + /// An instance of . + protected abstract TDataModel CreateDataModel(); } - [Test] - public void Contains_PipingSoilProfileAdded_ReturnsTrue() + [TestFixture] + private class PipingSoilProfileCollectorTest : CollectorTest { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingSoilProfileEntity(); - collector.Read(entity, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + public PipingSoilProfileCollectorTest() : base( + (c, e, m) => c.Read(e, m), + (c, e) => c.Contains(e), + (c, e) => c.Get(e)) {} - // Call - bool result = collector.Contains(entity); - - // Assert - Assert.IsTrue(result); + protected override PipingSoilProfile CreateDataModel() + { + return PipingSoilProfileTestFactory.CreatePipingSoilProfile(); + } } - [Test] - public void Contains_NoPipingSoilProfileAdded_ReturnsFalse() + [TestFixture] + private class PipingStochasticSoilProfileCollectorTest : CollectorTest { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingSoilProfileEntity(); + public PipingStochasticSoilProfileCollectorTest() : base( + (c, e, m) => c.Read(e, m), + (c, e) => c.Contains(e), + (c, e) => c.Get(e)) {} - // Call - bool result = collector.Contains(entity); - - // Assert - Assert.IsFalse(result); + protected override PipingStochasticSoilProfile CreateDataModel() + { + return new PipingStochasticSoilProfile(1, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); + } } - [Test] - public void Contains_OtherPipingSoilProfileEntityAdded_ReturnsFalse() - { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingSoilProfileEntity(); - collector.Read(new PipingSoilProfileEntity(), PipingSoilProfileTestFactory.CreatePipingSoilProfile()); - - // Call - bool result = collector.Contains(entity); - - // Assert - Assert.IsFalse(result); - } - - [Test] - public void Get_WithoutPipingSoilProfileEntity_ThrowsArgumentNullException() - { - // Setup - var collector = new ReadConversionCollector(); - - // Call - TestDelegate test = () => collector.Get((PipingSoilProfileEntity) null); - - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Get_PipingSoilProfileAdded_ReturnsEntity() - { - // Setup - var collector = new ReadConversionCollector(); - PipingSoilProfile profile = PipingSoilProfileTestFactory.CreatePipingSoilProfile(); - var entity = new PipingSoilProfileEntity(); - collector.Read(entity, profile); - - // Call - PipingSoilProfile result = collector.Get(entity); - - // Assert - Assert.AreSame(profile, result); - } - - [Test] - public void Get_NoPipingSoilProfileAdded_ThrowsInvalidOperationException() - { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingSoilProfileEntity(); - - // Call - TestDelegate test = () => collector.Get(entity); - - // Assert - Assert.Throws(test); - } - - [Test] - public void Get_OtherPipingSoilProfileAdded_ThrowsInvalidOperationException() - { - // Setup - var collector = new ReadConversionCollector(); - var entity = new PipingSoilProfileEntity(); - collector.Read(new PipingSoilProfileEntity(), PipingSoilProfileTestFactory.CreatePipingSoilProfile()); - - // Call - TestDelegate test = () => collector.Get(entity); - - // Assert - Assert.Throws(test); - } - - [Test] - public void Read_WithNullPipingSoilProfileEntity_ThrowsArgumentNullException() - { - // Setup - var collector = new ReadConversionCollector(); - - // Call - TestDelegate test = () => collector.Read(null, PipingSoilProfileTestFactory.CreatePipingSoilProfile()); - - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("entity", paramName); - } - - [Test] - public void Read_WithNullPipingSoilProfile_ThrowsArgumentNullException() - { - // Setup - var collector = new ReadConversionCollector(); - - // Call - TestDelegate test = () => collector.Read(new PipingSoilProfileEntity(), null); - - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("model", paramName); - } - - #endregion - #region SurfaceLineEntity: Read, Contains, Get [Test] Fisheye: Tag a5714fc0488030773fff50dfc82041c6cb9edc2f refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StochasticSoilModelEntityReadExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a5714fc0488030773fff50dfc82041c6cb9edc2f refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/SurfaceLineEntityReadExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff?