Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilLayer2DTest.cs =================================================================== diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -ra07b01c421d15a0a1e4933e3967ac1f25d30eccc --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilLayer2DTest.cs (.../MacroStabilityInwardsSoilLayer2DTest.cs) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilLayer2DTest.cs (.../MacroStabilityInwardsSoilLayer2DTest.cs) (revision a07b01c421d15a0a1e4933e3967ac1f25d30eccc) @@ -35,7 +35,7 @@ public class MacroStabilityInwardsSoilLayer2DTest { [Test] - public void Constructor_WithoutOuterRing_ArgumentNullException() + public void Constructor_OuterRingNullWithoutData_ThrowsArgumentNullException() { // Setup var holes = new[] @@ -56,9 +56,30 @@ } [Test] - public void Constructor_WithoutHoles_ThrowsArgumentNullException() + public void Constructor_OuterRingNullWithData_ThrowsArgumentNullException() { // Setup + var holes = new[] + { + new Ring(new[] + { + new Point2D(0, 2), + new Point2D(2, 2) + }) + }; + + // Call + TestDelegate test = () => new MacroStabilityInwardsSoilLayer2D(null, holes, new MacroStabilityInwardsSoilLayerData()); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("outerRing", exception.ParamName); + } + + [Test] + public void Constructor_HolesNullWithoutData_ThrowsArgumentNullException() + { + // Setup var outerRing = new Ring(new[] { new Point2D(0, 2), @@ -74,6 +95,43 @@ } [Test] + public void Constructor_HolesNullWithData_ThrowsArgumentNullException() + { + // Setup + var outerRing = new Ring(new[] + { + new Point2D(0, 2), + new Point2D(2, 2) + }); + + // Call + TestDelegate test = () => new MacroStabilityInwardsSoilLayer2D(outerRing, null, new MacroStabilityInwardsSoilLayerData()); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("holes", exception.ParamName); + } + + [Test] + public void Constructor_DataNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(39); + Ring outerRing = CreateRandomRing(random); + var holes = new[] + { + CreateRandomRing(random) + }; + + // Call + TestDelegate test = () => new MacroStabilityInwardsSoilLayer2D(outerRing, holes, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("data", exception.ParamName); + } + + [Test] public void Constructor_WithOuterRingAndHoles_ReturnsNewInstance() { // Setup @@ -93,10 +151,34 @@ Assert.AreSame(outerRing, layer.OuterRing); Assert.AreNotSame(holes, layer.Holes); TestHelper.AssertCollectionsAreEqual(holes, layer.Holes, new ReferenceEqualityComparer()); - Assert.Null(layer.Data); + Assert.IsNotNull(layer.Data); } [Test] + public void Constructor_WithOuterRingHolesAndData_ReturnsNewInstance() + { + // Setup + var random = new Random(39); + Ring outerRing = CreateRandomRing(random); + var holes = new[] + { + CreateRandomRing(random) + }; + var data = new MacroStabilityInwardsSoilLayerData(); + + // Call + var layer = new MacroStabilityInwardsSoilLayer2D(outerRing, holes, data); + + // Assert + Assert.IsInstanceOf(layer); + Assert.NotNull(layer); + Assert.AreSame(outerRing, layer.OuterRing); + Assert.AreNotSame(holes, layer.Holes); + TestHelper.AssertCollectionsAreEqual(holes, layer.Holes, new ReferenceEqualityComparer()); + Assert.AreSame(data, layer.Data); + } + + [Test] public void GetHashCode_EqualLayers_AreEqual() { // Setup @@ -165,7 +247,7 @@ CreateRandomRing(new Random(22)) }) { - Data = new MacroStabilityInwardsSoilLayerData + Data = { Color = Color.Blue } @@ -177,7 +259,7 @@ CreateRandomRing(new Random(22)) }) { - Data = new MacroStabilityInwardsSoilLayerData + Data = { Color = Color.Blue } @@ -189,7 +271,7 @@ CreateRandomRing(new Random(32)) }) { - Data = new MacroStabilityInwardsSoilLayerData + Data = { Color = Color.Blue } @@ -201,7 +283,7 @@ CreateRandomRing(new Random(22)) }) { - Data = new MacroStabilityInwardsSoilLayerData + Data = { Color = Color.Gold } @@ -260,7 +342,7 @@ CreateRandomRing(random) }) { - Data = new MacroStabilityInwardsSoilLayerData + Data = { Color = Color.FromKnownColor(random.NextEnumValue()) },