Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsStochasticSoilProfileCreateExtensionsTest.cs =================================================================== diff -u -r8e213638a22dd9f04d965d875bb58156db019be5 -rfe26eb5e452792f9c2ebd62a737a35642210d2f3 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsStochasticSoilProfileCreateExtensionsTest.cs (.../MacroStabilityInwardsStochasticSoilProfileCreateExtensionsTest.cs) (revision 8e213638a22dd9f04d965d875bb58156db019be5) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsStochasticSoilProfileCreateExtensionsTest.cs (.../MacroStabilityInwardsStochasticSoilProfileCreateExtensionsTest.cs) (revision fe26eb5e452792f9c2ebd62a737a35642210d2f3) @@ -25,7 +25,6 @@ using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.Create.MacroStabilityInwards; using Application.Ringtoets.Storage.DbContext; -using Core.Common.Base.Geometry; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; @@ -72,6 +71,22 @@ } [Test] + public void Create_WithUnsupportedSoilProfile_ThrowsNotSupportedException() + { + // Setup + var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.5, new UnsupportedMacroStabilityInwardsSoilProfile()); + var registry = new PersistenceRegistry(); + + // Call + TestDelegate test = () => stochasticSoilProfile.Create(registry, 1); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual($"{nameof(UnsupportedMacroStabilityInwardsSoilProfile)} is not supported. " + + $"Supported types are: {nameof(MacroStabilityInwardsSoilProfile1D)} and {nameof(MacroStabilityInwardsSoilProfile2D)}.", exception.Message); + } + + [Test] [TestCaseSource(nameof(GetMacroStabilityInwardsSoilProfiles))] public void Create_WithValidProperties_ReturnsStochasticSoilProfileEntityWithPropertiesSet(IMacroStabilityInwardsSoilProfile soilProfile) { @@ -151,20 +166,26 @@ [Test] [TestCaseSource(nameof(GetMacroStabilityInwardsSoilProfiles))] - public void Create_SameStochasticSoilProfileMultipleTimes_ReturnSameEntity(IMacroStabilityInwardsSoilProfile soilProfile) + public void GivenCreatedEntity_WhenCreateCalledOnSameObject_ThenSameEntityInstanceReturned(IMacroStabilityInwardsSoilProfile soilProfile) { - // Setup + // Given var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.4, soilProfile); var registry = new PersistenceRegistry(); - // Call MacroStabilityInwardsStochasticSoilProfileEntity entity1 = stochasticSoilProfile.Create(registry, 0); + + // When MacroStabilityInwardsStochasticSoilProfileEntity entity2 = stochasticSoilProfile.Create(registry, 0); - // Assert + // Then Assert.AreSame(entity1, entity2); } + private class UnsupportedMacroStabilityInwardsSoilProfile : IMacroStabilityInwardsSoilProfile + { + public string Name { get; } + } + private static IEnumerable GetSameExpectedMacroStabilityInwardsSoilProfiles() { IMacroStabilityInwardsSoilProfile[] soilProfiles = GetMacroStabilityInwardsSoilProfiles().ToArray(); @@ -181,14 +202,7 @@ private static IEnumerable GetMacroStabilityInwardsSoilProfiles() { yield return new TestMacroStabilityInwardsSoilProfile1D(nameof(MacroStabilityInwardsSoilProfile1D)); - yield return new MacroStabilityInwardsSoilProfile2D(nameof(MacroStabilityInwardsSoilProfile2D), new[] - { - new MacroStabilityInwardsSoilLayer2D(new Ring(new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - }), Enumerable.Empty()) - }, new MacroStabilityInwardsPreconsolidationStress[0]); + yield return MacroStabilityInwardsSoilProfile2DTestFactory.CreateMacroStabilityInwardsSoilProfile2D(); } } } \ No newline at end of file