Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSurfaceLineTest.cs =================================================================== diff -u -r9b791eb0a5c7d9bf4842ac9c79d4acb31bf69612 -r99f686f22091051a65ff1ee20abd68ffad713647 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSurfaceLineTest.cs (.../MacroStabilityInwardsSurfaceLineTest.cs) (revision 9b791eb0a5c7d9bf4842ac9c79d4acb31bf69612) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Primitives.Test/MacroStabilityInwardsSurfaceLineTest.cs (.../MacroStabilityInwardsSurfaceLineTest.cs) (revision 99f686f22091051a65ff1ee20abd68ffad713647) @@ -34,20 +34,35 @@ public class MacroStabilityInwardsSurfaceLineTest { [Test] + public void Constructor_NameNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacroStabilityInwardsSurfaceLine(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("name", exception.ParamName); + } + + [Test] public void DefaultConstructor_ExpectedValues() { + // Setup + const string name = "some name"; + // Call - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + var surfaceLine = new MacroStabilityInwardsSurfaceLine(name); // Assert Assert.IsInstanceOf(surfaceLine); + Assert.AreEqual(name, surfaceLine.Name); } [Test] public void CopyProperties_WithSurfaceLineNull_ThrowsArgumentNullException() { // Setup - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); // Call TestDelegate call = () => surfaceLine.CopyProperties(null); @@ -85,9 +100,8 @@ { // Setup MacroStabilityInwardsSurfaceLine surfaceLine = CreateSurfaceLineWithCharacteristicPoints(); - var surfaceLineToUpdateFrom = new MacroStabilityInwardsSurfaceLine + var surfaceLineToUpdateFrom = new MacroStabilityInwardsSurfaceLine(surfaceLine.Name) { - Name = surfaceLine.Name, ReferenceLineIntersectionWorldPoint = surfaceLine.ReferenceLineIntersectionWorldPoint }; surfaceLineToUpdateFrom.SetGeometry(surfaceLine.Points); @@ -120,7 +134,7 @@ public void CopyProperties_LineWithUpdatedGeometryAndReferenceLineIntersectionAndCharacteristicPoints_PropertiesUpdated() { // Setup - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); MacroStabilityInwardsSurfaceLine surfaceLineToUpdateFrom = CreateSurfaceLineWithCharacteristicPoints(); // Call @@ -148,7 +162,7 @@ public void Equals_ToItself_ReturnsTrue() { // Setup - var surfaceLineOne = new MacroStabilityInwardsSurfaceLine(); + var surfaceLineOne = new MacroStabilityInwardsSurfaceLine(string.Empty); // Call bool isLineOneEqualToLineOne = surfaceLineOne.Equals(surfaceLineOne); @@ -161,7 +175,7 @@ public void Equals_SameReference_ReturnsTrue() { // Setup - var surfaceLineOne = new MacroStabilityInwardsSurfaceLine(); + var surfaceLineOne = new MacroStabilityInwardsSurfaceLine(string.Empty); MacroStabilityInwardsSurfaceLine surfaceLineTwo = surfaceLineOne; // Call @@ -177,10 +191,7 @@ public void Equals_ToNull_ReturnsFalse() { // Setup - var surfaceLineOne = new MacroStabilityInwardsSurfaceLine - { - Name = "Name A" - }; + var surfaceLineOne = new MacroStabilityInwardsSurfaceLine("Name A"); // Call bool isLineOneEqualToNull = surfaceLineOne.Equals(null); @@ -193,11 +204,7 @@ public void Equals_ToDifferentType_ReturnsFalse() { // Setup - var surfaceLineOne = new MacroStabilityInwardsSurfaceLine - { - Name = "Name A" - }; - + var surfaceLineOne = new MacroStabilityInwardsSurfaceLine("Name A"); var differentType = new object(); // Call @@ -213,12 +220,9 @@ public void Equals_DifferentNames_ReturnsFalse() { // Setup - MacroStabilityInwardsSurfaceLine surfaceLineOne = CreateSurfaceLineWithCharacteristicPoints(); - surfaceLineOne.Name = "Name A"; + MacroStabilityInwardsSurfaceLine surfaceLineOne = CreateSurfaceLineWithCharacteristicPoints("Name one"); + MacroStabilityInwardsSurfaceLine surfaceLineTwo = CreateSurfaceLineWithCharacteristicPoints("Name two"); - MacroStabilityInwardsSurfaceLine surfaceLineTwo = CreateSurfaceLineWithCharacteristicPoints(); - surfaceLineTwo.Name = "Name B"; - // Call bool isLineOneEqualToLineTwo = surfaceLineOne.Equals(surfaceLineTwo); bool isLineTwoEqualToLineOne = surfaceLineTwo.Equals(surfaceLineOne); @@ -232,19 +236,13 @@ public void Equals_DifferentGeometries_ReturnsFalse() { // Setup - var surfaceLineOne = new MacroStabilityInwardsSurfaceLine - { - Name = "Name A" - }; + var surfaceLineOne = new MacroStabilityInwardsSurfaceLine("Name A"); surfaceLineOne.SetGeometry(new[] { new Point3D(1, 2, 3) }); - var surfaceLineTwo = new MacroStabilityInwardsSurfaceLine - { - Name = "Name A" - }; + var surfaceLineTwo = new MacroStabilityInwardsSurfaceLine("Name A"); surfaceLineTwo.SetGeometry(new[] { new Point3D(3, 4, 5) @@ -551,8 +549,8 @@ public void GetHashCode_EqualSurfaceLines_ReturnSameHashCode() { // Setup - var surfaceLineOne = new MacroStabilityInwardsSurfaceLine(); - var surfaceLineTwo = new MacroStabilityInwardsSurfaceLine(); + var surfaceLineOne = new MacroStabilityInwardsSurfaceLine(string.Empty); + var surfaceLineTwo = new MacroStabilityInwardsSurfaceLine(string.Empty); // Call int hashCodeOne = surfaceLineOne.GetHashCode(); @@ -572,7 +570,7 @@ const double testY = 2.2; const double testZ = 4.4; var testPoint = new Point3D(testX, testY, testZ); - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); CreateTestGeometry(testPoint, surfaceLine); // Call @@ -589,7 +587,7 @@ // Setup var random = new Random(21); var testPoint = new Point3D(random.NextDouble(), random.NextDouble(), random.NextDouble()); - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); // Call TestDelegate test = () => SetCharacteristicPoint(surfaceLine, testPoint); @@ -603,7 +601,7 @@ public void Null_ThrowsArgumentNullException() { // Setup - var surfaceLine = new MacroStabilityInwardsSurfaceLine(); + var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); // Call TestDelegate test = () => SetCharacteristicPoint(surfaceLine, null); @@ -867,7 +865,7 @@ private class TestSurfaceLine : MacroStabilityInwardsSurfaceLine { - public TestSurfaceLine(MacroStabilityInwardsSurfaceLine profile) + public TestSurfaceLine(MacroStabilityInwardsSurfaceLine profile) : base(string.Empty) { CopyProperties(profile); } @@ -907,11 +905,10 @@ } } - private static MacroStabilityInwardsSurfaceLine CreateSurfaceLineWithCharacteristicPoints() + private static MacroStabilityInwardsSurfaceLine CreateSurfaceLineWithCharacteristicPoints(string name = "Name A") { - var surfaceLine = new MacroStabilityInwardsSurfaceLine + var surfaceLine = new MacroStabilityInwardsSurfaceLine(name) { - Name = "Name A", ReferenceLineIntersectionWorldPoint = new Point2D(0, 0) }; var geometry = new[]