Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelFaultTreeIllustrationPoint.cs =================================================================== diff -u -r72cdd802a67613c6e93bb92ae0b1478c5c943b0a -r723e8357991d59d7784212cb433bb4571e0cdefb --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelFaultTreeIllustrationPoint.cs (.../TopLevelFaultTreeIllustrationPoint.cs) (revision 72cdd802a67613c6e93bb92ae0b1478c5c943b0a) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelFaultTreeIllustrationPoint.cs (.../TopLevelFaultTreeIllustrationPoint.cs) (revision 723e8357991d59d7784212cb433bb4571e0cdefb) @@ -27,7 +27,7 @@ /// Represents the top level combination of wind direction, closing situation /// and the fault tree. /// - public class TopLevelFaultTreeIllustrationPoint + public class TopLevelFaultTreeIllustrationPoint : TopLevelIllustrationPointBase { /// /// Creates an instance of . @@ -40,6 +40,7 @@ public TopLevelFaultTreeIllustrationPoint(WindDirection windDirection, string closingSituation, FaultTreeIllustrationPointNode faultTreeNodeRoot) + : base(windDirection, closingSituation) { if (windDirection == null) { @@ -54,22 +55,10 @@ throw new ArgumentNullException(nameof(faultTreeNodeRoot)); } - WindDirection = windDirection; - ClosingSituation = closingSituation; FaultTreeNodeRoot = faultTreeNodeRoot; } /// - /// Gets the wind direction. - /// - public WindDirection WindDirection { get; } - - /// - /// Gets the closing situation. - /// - public string ClosingSituation { get; } - - /// /// Gets the root of the illustration points of the fault tree. /// public FaultTreeIllustrationPointNode FaultTreeNodeRoot { get; } Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelIllustrationPointBase.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelIllustrationPointBase.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelIllustrationPointBase.cs (revision 723e8357991d59d7784212cb433bb4571e0cdefb) @@ -0,0 +1,64 @@ +// 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; + +namespace Ringtoets.Common.Data.IllustrationPoints +{ + /// + /// A base class for combinations of wind direction, closing situations + /// and illustration points. + /// + public abstract class TopLevelIllustrationPointBase + { + /// + /// Creates a . + /// + /// The wind direction. + /// The closing situation. + /// Thrown when any of the parameters + /// is null. + protected TopLevelIllustrationPointBase(WindDirection windDirection, string closingSituation) + { + if (windDirection == null) + { + throw new ArgumentNullException(nameof(windDirection)); + } + if (closingSituation == null) + { + throw new ArgumentNullException(nameof(closingSituation)); + } + + WindDirection = windDirection; + ClosingSituation = closingSituation; + } + + /// + /// Gets the wind direction. + /// + public WindDirection WindDirection { get; } + + /// + /// Gets the closing situation. + /// + public string ClosingSituation { get; } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelSubMechanismIllustrationPoint.cs =================================================================== diff -u -r72cdd802a67613c6e93bb92ae0b1478c5c943b0a -r723e8357991d59d7784212cb433bb4571e0cdefb --- Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelSubMechanismIllustrationPoint.cs (.../TopLevelSubMechanismIllustrationPoint.cs) (revision 72cdd802a67613c6e93bb92ae0b1478c5c943b0a) +++ Ringtoets/Common/src/Ringtoets.Common.Data/IllustrationPoints/TopLevelSubMechanismIllustrationPoint.cs (.../TopLevelSubMechanismIllustrationPoint.cs) (revision 723e8357991d59d7784212cb433bb4571e0cdefb) @@ -27,7 +27,7 @@ /// Represents the top level combination of wind direction, closing situation and /// a submechanism illustration point. /// - public class TopLevelSubMechanismIllustrationPoint + public class TopLevelSubMechanismIllustrationPoint : TopLevelIllustrationPointBase { /// /// Creates a new instance of . @@ -38,7 +38,8 @@ /// Thrown when any input parameter is null. public TopLevelSubMechanismIllustrationPoint(WindDirection windDirection, string closingSituation, - SubMechanismIllustrationPoint subMechanismIllustrationPoint) + SubMechanismIllustrationPoint subMechanismIllustrationPoint) + : base(windDirection, closingSituation) { if (windDirection == null) { @@ -53,22 +54,10 @@ throw new ArgumentNullException(nameof(subMechanismIllustrationPoint)); } - WindDirection = windDirection; - ClosingSituation = closingSituation; SubMechanismIllustrationPoint = subMechanismIllustrationPoint; } /// - /// Gets the closing situation. - /// - public string ClosingSituation { get; } - - /// - /// Gets the wind direction. - /// - public WindDirection WindDirection { get; } - - /// /// Gets the submechanism illustration point. /// public SubMechanismIllustrationPoint SubMechanismIllustrationPoint { get; } Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj =================================================================== diff -u -r72cdd802a67613c6e93bb92ae0b1478c5c943b0a -r723e8357991d59d7784212cb433bb4571e0cdefb --- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 72cdd802a67613c6e93bb92ae0b1478c5c943b0a) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 723e8357991d59d7784212cb433bb4571e0cdefb) @@ -76,6 +76,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointTest.cs =================================================================== diff -u -r72cdd802a67613c6e93bb92ae0b1478c5c943b0a -r723e8357991d59d7784212cb433bb4571e0cdefb --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointTest.cs (.../TopLevelFaultTreeIllustrationPointTest.cs) (revision 72cdd802a67613c6e93bb92ae0b1478c5c943b0a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelFaultTreeIllustrationPointTest.cs (.../TopLevelFaultTreeIllustrationPointTest.cs) (revision 723e8357991d59d7784212cb433bb4571e0cdefb) @@ -87,6 +87,8 @@ var illustrationPoint = new TopLevelFaultTreeIllustrationPoint(windDirection, closingSituation, faultTreeNode); // Assert + Assert.IsInstanceOf(illustrationPoint); + Assert.AreSame(windDirection, illustrationPoint.WindDirection); Assert.AreEqual(closingSituation, illustrationPoint.ClosingSituation); Assert.AreSame(faultTreeNode, illustrationPoint.FaultTreeNodeRoot); Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelIllustrationPointBaseTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelIllustrationPointBaseTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelIllustrationPointBaseTest.cs (revision 723e8357991d59d7784212cb433bb4571e0cdefb) @@ -0,0 +1,86 @@ +// 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 NUnit.Framework; +using Ringtoets.Common.Data.IllustrationPoints; + +namespace Ringtoets.Common.Data.Test.IllustrationPoints +{ + [TestFixture] + public class TopLevelIllustrationPointBaseTest + { + [Test] + public void Constructor_WindDirectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new TestTopLevelIllustrationPointBase(null, "closing situation"); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("windDirection", exception.ParamName); + } + + [Test] + public void Constructor_ClosingSituationNull_ThrowsArgumentNullException() + { + // Setup + var random = new Random(21); + + const string windDirectionName = "Name of the wind"; + double windDirectionAngle = random.NextDouble(); + var windDirection = new WindDirection(windDirectionName, windDirectionAngle); + + // Call + TestDelegate call = () => new TestTopLevelIllustrationPointBase(windDirection, null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("closingSituation", exception.ParamName); + } + + [Test] + public void Constructor_ValidArguments_ReturnExpectedValues() + { + // Setup + var random = new Random(21); + + const string windDirectionName = "Name of the wind"; + double windDirectionAngle = random.NextDouble(); + var windDirection = new WindDirection(windDirectionName, windDirectionAngle); + + const string closingSituation = "closing situation"; + + // Call + var topLevelIllustrationPoint = new TestTopLevelIllustrationPointBase(windDirection, closingSituation); + + // Assert + Assert.AreSame(windDirection, topLevelIllustrationPoint.WindDirection); + Assert.AreEqual(closingSituation, topLevelIllustrationPoint.ClosingSituation); + } + + private class TestTopLevelIllustrationPointBase : TopLevelIllustrationPointBase + { + public TestTopLevelIllustrationPointBase(WindDirection windDirection, string closingSituation) + : base(windDirection, closingSituation) {} + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointTest.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r723e8357991d59d7784212cb433bb4571e0cdefb --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointTest.cs (.../TopLevelSubMechanismIllustrationPointTest.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/IllustrationPoints/TopLevelSubMechanismIllustrationPointTest.cs (.../TopLevelSubMechanismIllustrationPointTest.cs) (revision 723e8357991d59d7784212cb433bb4571e0cdefb) @@ -88,6 +88,8 @@ new TopLevelSubMechanismIllustrationPoint(windDirection, closingScenario, submechanismIllustrationPoint); // Assert + Assert.IsInstanceOf(windDirectionClosingScenarioIllustrationPoint); + Assert.AreEqual(closingScenario, windDirectionClosingScenarioIllustrationPoint.ClosingSituation); Assert.AreSame(windDirection, windDirectionClosingScenarioIllustrationPoint.WindDirection); Assert.AreSame(submechanismIllustrationPoint, windDirectionClosingScenarioIllustrationPoint.SubMechanismIllustrationPoint); Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj =================================================================== diff -u -r72cdd802a67613c6e93bb92ae0b1478c5c943b0a -r723e8357991d59d7784212cb433bb4571e0cdefb --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 72cdd802a67613c6e93bb92ae0b1478c5c943b0a) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 723e8357991d59d7784212cb433bb4571e0cdefb) @@ -89,6 +89,7 @@ +