Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj =================================================================== diff -u -r74be63b9f6ac8bc60a6754667a3bcee0485853a0 -r5add1ecd1be36fd829a95fc68d32bd4b0ec70525 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj (.../Ringtoets.MacroStabilityInwards.IO.csproj) (revision 74be63b9f6ac8bc60a6754667a3bcee0485853a0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Ringtoets.MacroStabilityInwards.IO.csproj (.../Ringtoets.MacroStabilityInwards.IO.csproj) (revision 5add1ecd1be36fd829a95fc68d32bd4b0ec70525) @@ -52,6 +52,7 @@ + Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelMechanismFilter.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelMechanismFilter.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelMechanismFilter.cs (revision 5add1ecd1be36fd829a95fc68d32bd4b0ec70525) @@ -0,0 +1,43 @@ +// 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 Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.SoilProfile.Schema; + +namespace Ringtoets.MacroStabilityInwards.IO.SoilProfiles +{ + /// + /// Class to that can be used to filter stochastic soil models for the macro stability inwards failure mechanism. + /// + public class MacroStabilityInwardsStochasticSoilModelMechanismFilter : IStochasticSoilModelMechanismFilter + { + public bool IsValidForFailureMechanism(StochasticSoilModel stochasticSoilModel) + { + if (stochasticSoilModel == null) + { + throw new ArgumentNullException(nameof(stochasticSoilModel)); + } + + return stochasticSoilModel.FailureMechanismType == FailureMechanismType.Stability; + } + } +} Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj =================================================================== diff -u -r74be63b9f6ac8bc60a6754667a3bcee0485853a0 -r5add1ecd1be36fd829a95fc68d32bd4b0ec70525 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj (.../Ringtoets.MacroStabilityInwards.IO.Test.csproj) (revision 74be63b9f6ac8bc60a6754667a3bcee0485853a0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Ringtoets.MacroStabilityInwards.IO.Test.csproj (.../Ringtoets.MacroStabilityInwards.IO.Test.csproj) (revision 5add1ecd1be36fd829a95fc68d32bd4b0ec70525) @@ -80,6 +80,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelMechanismFilterTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelMechanismFilterTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelMechanismFilterTest.cs (revision 5add1ecd1be36fd829a95fc68d32bd4b0ec70525) @@ -0,0 +1,88 @@ +// 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 System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using Ringtoets.Common.IO.SoilProfile; +using Ringtoets.Common.IO.SoilProfile.Schema; +using Ringtoets.MacroStabilityInwards.IO.SoilProfiles; + +namespace Ringtoets.MacroStabilityInwards.IO.Test.SoilProfiles +{ + [TestFixture] + public class MacroStabilityInwardsStochasticSoilModelMechanismFilterTest + { + [Test] + public void Constructor_StochasticSoilModelNull_ThrowsArgumentNullException() + { + // Setup + var filter = new MacroStabilityInwardsStochasticSoilModelMechanismFilter(); + + // Call + TestDelegate test = () => filter.IsValidForFailureMechanism(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochasticSoilModel", exception.ParamName); + } + + [Test] + [TestCaseSource(nameof(StochasticSoilModelsOfInvalidType))] + public void Constructor_StochasticSoilModelOfInvalidType_ReturnsFalse(StochasticSoilModel model) + { + // Setup + var filter = new MacroStabilityInwardsStochasticSoilModelMechanismFilter(); + + // Call + bool isValid = filter.IsValidForFailureMechanism(model); + + // Assert + Assert.IsFalse(isValid); + } + + [Test] + public void Constructor_ValidStochasticSoilModelType_ReturnsFalse() + { + // Setup + var filter = new MacroStabilityInwardsStochasticSoilModelMechanismFilter(); + var model = new StochasticSoilModel(nameof(FailureMechanismType.Stability), FailureMechanismType.Stability); + + // Call + bool isValid = filter.IsValidForFailureMechanism(model); + + // Assert + Assert.IsTrue(isValid); + } + + private static IEnumerable StochasticSoilModelsOfInvalidType() + { + return Enum.GetValues(typeof(FailureMechanismType)) + .Cast() + .Where(type => type != FailureMechanismType.Stability) + .Select(type => new TestCaseData( + new StochasticSoilModel(type.ToString(), type)) + .SetName($"Constructor_InvalidType_ReturnsFalse({type.ToString()})") + ); + } + } +} \ No newline at end of file