Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructure.cs =================================================================== diff -u -rfbf9eca188c20c352a702ee20c183e5dc3c7acf1 -re2197d5a4596fc769d89bd2f661d657490017d76 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructure.cs (.../ClosingStructure.cs) (revision fbf9eca188c20c352a702ee20c183e5dc3c7acf1) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Data/ClosingStructure.cs (.../ClosingStructure.cs) (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -19,12 +19,26 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Geometry; +using Ringtoets.Common.Data; + namespace Ringtoets.ClosingStructures.Data { /// /// Definition of a closing structure for the /// - public class ClosingStructure + public class ClosingStructure : StructureBase { + /// + /// Creates a new instance of . + /// + /// The name of the structure. + /// The identifier of the structure. + /// The location of the structure. + /// Thrown when or is null + /// , empty or consists of whitespace. + /// Thrown when is null. + public ClosingStructure(string name, string id, Point2D location) : base(name, id, location) {} } -} +} \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructureTest.cs =================================================================== diff -u -rfbf9eca188c20c352a702ee20c183e5dc3c7acf1 -re2197d5a4596fc769d89bd2f661d657490017d76 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructureTest.cs (.../ClosingStructureTest.cs) (revision fbf9eca188c20c352a702ee20c183e5dc3c7acf1) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructureTest.cs (.../ClosingStructureTest.cs) (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -19,12 +19,30 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Core.Common.Base.Geometry; using NUnit.Framework; +using Ringtoets.Common.Data; namespace Ringtoets.ClosingStructures.Data.Test { [TestFixture] public class ClosingStructureTest { + [Test] + public void Constructor_ValidData_ExpectedValues() + { + // Setup + var location = new Point2D(1.22, 2.333); + + // Call + var structure = new ClosingStructure("aName", "anId", location); + + // Assert + Assert.IsInstanceOf(structure); + Assert.AreEqual("aName", structure.Name); + Assert.AreEqual("anId", structure.Id); + Assert.AreEqual(location.X, structure.Location.X); + Assert.AreEqual(location.Y, structure.Location.Y); + } } } Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj =================================================================== diff -u -r1dddcf22e6d496a00dcfe85cf8d1302a8df121cd -re2197d5a4596fc769d89bd2f661d657490017d76 --- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 1dddcf22e6d496a00dcfe85cf8d1302a8df121cd) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -81,6 +81,7 @@ Resources.resx + Index: Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/StructureBase.cs (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -0,0 +1,76 @@ +// Copyright (C) Stichting Deltares 2016. 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 Core.Common.Base.Geometry; + +namespace Ringtoets.Common.Data +{ + /// + /// Base definition of a structure. + /// + public abstract class StructureBase + { + /// + /// Creates a new instance of . + /// + /// The name of the structure. + /// The identifier of the structure. + /// The location of the structure. + /// Thrown when or is null + /// , empty or consists of whitespace. + /// Thrown when is null. + protected StructureBase(string name, string id, Point2D location) + { + if (string.IsNullOrWhiteSpace(name)) + { + throw new ArgumentException("name"); + } + if (string.IsNullOrWhiteSpace(id)) + { + throw new ArgumentException("id"); + } + if (location == null) + { + throw new ArgumentNullException("location"); + } + + Name = name; + Id = id; + Location = location; + } + + /// + /// Gets the name of the structure. + /// + public string Name { get; private set; } + + /// + /// Gets the identifier of the structure. + /// + public string Id { get; private set; } + + /// + /// Gets the location of the structure. + /// + public Point2D Location { get; private set; } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj =================================================================== diff -u -rb34f55ea9331b4e253fb9f0d19a11a9e48768f03 -re2197d5a4596fc769d89bd2f661d657490017d76 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision b34f55ea9331b4e253fb9f0d19a11a9e48768f03) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -75,6 +75,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/StructureBaseTest.cs (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -0,0 +1,90 @@ +// Copyright (C) Stichting Deltares 2016. 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 Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.Common.Data.Test +{ + [TestFixture] + public class StructureBaseTest + { + [Test] + [TestCase(null)] + [TestCase("")] + [TestCase(" ")] + public void Constructor_NameNullOrWhiteSpace_ThrowArgumentException(string name) + { + // Call + TestDelegate call = () => new TestStructure(name, "anId", new Point2D(0, 0)); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "name"); + } + + [Test] + [TestCase(null)] + [TestCase("")] + [TestCase(" ")] + public void Constructor_IdNullOrWhiteSpace_ThrowArgumentException(string id) + { + // Call + TestDelegate call = () => new TestStructure("aName", id, new Point2D(0, 0)); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "id"); + } + + [Test] + public void Constructor_LocationNull_ThrowArgumentNullException() + { + // Call + TestDelegate call = () => new TestStructure("aName", "anId", null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("location", paramName); + } + + [Test] + public void Constructor_ValidData_ExpectedValues() + { + // Setup + var location = new Point2D(1.22, 2.333); + + // Call + var structure = new TestStructure("aName", "anId", location); + + // Assert + Assert.AreEqual("aName", structure.Name); + Assert.AreEqual("anId", structure.Id); + Assert.AreEqual(location.X, structure.Location.X); + Assert.AreEqual(location.Y, structure.Location.Y); + } + + private class TestStructure : StructureBase + { + public TestStructure(string name, string id, Point2D location) : base(name, id, location) {} + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructure.cs =================================================================== diff -u -r423010168fe01b2373e9be55f047659911e670f5 -re2197d5a4596fc769d89bd2f661d657490017d76 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructure.cs (.../HeightStructure.cs) (revision 423010168fe01b2373e9be55f047659911e670f5) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructure.cs (.../HeightStructure.cs) (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -22,14 +22,15 @@ using System; using Core.Common.Base.Data; using Core.Common.Base.Geometry; +using Ringtoets.Common.Data; using Ringtoets.Common.Data.Probabilistics; namespace Ringtoets.HeightStructures.Data { /// /// Definition of a height structure for the . /// - public class HeightStructure + public class HeightStructure : StructureBase { /// /// Creates a new instance of . @@ -51,7 +52,8 @@ /// The standard deviation of storage area of the height structure. /// The mean allowable increase of level for storage of the height structure. /// The standard deviation of allowable increase of level for storage of the height structure. - /// Thrown when or is null. + /// Thrown when or is null + /// , empty or consists of whitespace. /// Thrown when is null. public HeightStructure(string name, string id, Point2D location, double orientationOfTheNormalOfTheStructure, @@ -62,24 +64,8 @@ double failureProbabilityOfStructureGivenErosion, double storageStructureAreaMean, double storageStructureAreaStandardDeviation, double allowableIncreaseOfLevelForStorageMean, double allowableIncreaseOfLevelForStorageStandardDeviation - ) + ) : base(name, id, location) { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentException("name"); - } - if (string.IsNullOrWhiteSpace(id)) - { - throw new ArgumentException("id"); - } - if (location == null) - { - throw new ArgumentNullException("location"); - } - - Name = name; - Id = id; - Location = location; OrientationOfTheNormalOfTheStructure = new RoundedDouble(2, orientationOfTheNormalOfTheStructure); LevelOfCrestOfStructure = new NormalDistribution(2) { @@ -115,21 +101,6 @@ } /// - /// Gets the name of the height structure. - /// - public string Name { get; private set; } - - /// - /// Gets the identifier of the height structure. - /// - public string Id { get; private set; } - - /// - /// Gets the location of the height structure. - /// - public Point2D Location { get; private set; } - - /// /// Gets the orientation of the height structure, relative to north. /// public RoundedDouble OrientationOfTheNormalOfTheStructure { get; private set; } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructureTest.cs =================================================================== diff -u -r423010168fe01b2373e9be55f047659911e670f5 -re2197d5a4596fc769d89bd2f661d657490017d76 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructureTest.cs (.../HeightStructureTest.cs) (revision 423010168fe01b2373e9be55f047659911e670f5) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Data.Test/HeightStructureTest.cs (.../HeightStructureTest.cs) (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -24,6 +24,7 @@ using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; +using Ringtoets.Common.Data; using Ringtoets.Common.Data.Probabilistics; namespace Ringtoets.HeightStructures.Data.Test @@ -32,43 +33,6 @@ public class HeightStructureTest { [Test] - [TestCase(null)] - [TestCase("")] - [TestCase(" ")] - public void Constructor_NameNullOrWhiteSpace_ThrowsArgumentException(string name) - { - // Call - TestDelegate call = () => new HeightStructure(name, "anId", new Point2D(0, 0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "name"); - } - - [Test] - [TestCase(null)] - [TestCase("")] - [TestCase(" ")] - public void Constructor_IdNullOrWhiteSpace_ThrowsArgumentException(string id) - { - // Call - TestDelegate call = () => new HeightStructure("aName", id, new Point2D(0, 0), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "id"); - } - - [Test] - public void Constructor_LocationNull_ThrowsArgumentNullException() - { - // Call - TestDelegate call = () => new HeightStructure("aName", "anId", null, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); - - // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("location", paramName); - } - - [Test] public void Constructor_ValidData_ExpectedValues() { // Setup @@ -86,6 +50,7 @@ 225.336, 0.22533); // Assert + Assert.IsInstanceOf(heightStructure); Assert.AreEqual("aName", heightStructure.Name); Assert.AreEqual("anId", heightStructure.Id); Assert.IsInstanceOf(heightStructure.Location); Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructure.cs =================================================================== diff -u -r341ddc4bed3bbbae529c1c282d15cc9b593d1e6a -re2197d5a4596fc769d89bd2f661d657490017d76 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructure.cs (.../StabilityPointStructure.cs) (revision 341ddc4bed3bbbae529c1c282d15cc9b593d1e6a) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Data/StabilityPointStructure.cs (.../StabilityPointStructure.cs) (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -21,53 +21,24 @@ using System; using Core.Common.Base.Geometry; +using Ringtoets.Common.Data; namespace Ringtoets.StabilityPointStructures.Data { /// - /// Definition of a stability point structure for the + /// Definition of a stability point structure for the . /// - public class StabilityPointStructure + public class StabilityPointStructure : StructureBase { /// /// Creates a new instance of . /// /// The name of the structure. /// The identifier of the structure. /// The location of the structure. - public StabilityPointStructure(string name, string id, Point2D location) - { - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentException("name"); - } - if (string.IsNullOrWhiteSpace(id)) - { - throw new ArgumentException("id"); - } - if (location == null) - { - throw new ArgumentNullException("location"); - } - - Name = name; - Id = id; - Location = location; - } - - /// - /// Gets the name of the structure. - /// - public string Name { get; private set; } - - /// - /// Gets the identifier of the structure. - /// - public string Id { get; private set; } - - /// - /// Gets the location of the structure. - /// - public Point2D Location { get; private set; } + /// Thrown when or is null + /// , empty or consists of whitespace. + /// Thrown when is null. + public StabilityPointStructure(string name, string id, Point2D location) : base(name, id, location) {} } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructureTest.cs =================================================================== diff -u -r341ddc4bed3bbbae529c1c282d15cc9b593d1e6a -re2197d5a4596fc769d89bd2f661d657490017d76 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructureTest.cs (.../StabilityPointStructureTest.cs) (revision 341ddc4bed3bbbae529c1c282d15cc9b593d1e6a) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.Test/StabilityPointStructureTest.cs (.../StabilityPointStructureTest.cs) (revision e2197d5a4596fc769d89bd2f661d657490017d76) @@ -19,54 +19,16 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using Core.Common.Base.Geometry; -using Core.Common.TestUtil; using NUnit.Framework; +using Ringtoets.Common.Data; namespace Ringtoets.StabilityPointStructures.Data.Test { [TestFixture] public class StabilityPointStructureTest { [Test] - [TestCase(null)] - [TestCase("")] - [TestCase(" ")] - public void Constructor_NameNullOrWhiteSpace_ThrowArgumentException(string name) - { - // Call - TestDelegate call = () => new StabilityPointStructure(name, "anId", new Point2D(0, 0)); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "name"); - } - - [Test] - [TestCase(null)] - [TestCase("")] - [TestCase(" ")] - public void Constructor_IdNullOrWhiteSpace_ThrowArgumentException(string id) - { - // Call - TestDelegate call = () => new StabilityPointStructure("aName", id, new Point2D(0, 0)); - - // Assert - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "id"); - } - - [Test] - public void Constructor_LocationNull_ThrowArgumentNullException() - { - // Call - TestDelegate call = () => new StabilityPointStructure("aName", "anId", null); - - // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("location", paramName); - } - - [Test] public void Constructor_ValidData_ExpectedValues() { // Setup @@ -76,6 +38,7 @@ var structure = new StabilityPointStructure("aName", "anId", location); // Assert + Assert.IsInstanceOf(structure); Assert.AreEqual("aName", structure.Name); Assert.AreEqual("anId", structure.Id); Assert.AreEqual(location.X, structure.Location.X);