Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.TestUtil.Test/GrassCoverErosionInwardsCalculationScenarioTestFactoryTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.TestUtil.Test/GrassCoverErosionInwardsCalculationScenarioTestFactoryTest.cs (revision 0) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.TestUtil.Test/GrassCoverErosionInwardsCalculationScenarioTestFactoryTest.cs (revision 25c3f52ddce51f46f56cd796ea9b902eb1d6604c) @@ -0,0 +1,86 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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 Riskeer.Common.Data.FailureMechanism; +using Riskeer.Common.Data.TestUtil; + +namespace Riskeer.GrassCoverErosionInwards.Data.TestUtil.Test +{ + [TestFixture] + public class GrassCoverErosionInwardsCalculationScenarioTestFactoryTest + { + [Test] + public void CreateGrassCoverErosionInwardsCalculationScenario_SectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateGrassCoverErosionInwardsCalculationScenario(null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("section", exception.ParamName); + } + + [Test] + public void CreateGrassCoverErosionInwardsCalculationScenario_WithSection_CreatesRelevantCalculationWithOutput() + { + // Setup + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + + // Call + GrassCoverErosionInwardsCalculationScenario scenario = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateGrassCoverErosionInwardsCalculationScenario(section); + + // Assert + Assert.IsNotNull(scenario.Output); + Assert.IsTrue(scenario.IsRelevant); + Assert.IsNotNull(scenario.InputParameters.DikeProfile); + Assert.AreSame(section.StartPoint, scenario.InputParameters.DikeProfile.WorldReferencePoint); + } + + [Test] + public void CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario_SectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario(null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("section", exception.ParamName); + } + + [Test] + public void CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario_WithSection_CreatesRelevantCalculationWithoutOutput() + { + // Setup + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + + // Call + GrassCoverErosionInwardsCalculationScenario scenario = GrassCoverErosionInwardsCalculationScenarioTestFactory.CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario(section); + + // Assert + Assert.IsNull(scenario.Output); + Assert.IsTrue(scenario.IsRelevant); + Assert.IsNotNull(scenario.InputParameters.DikeProfile); + Assert.AreSame(section.StartPoint, scenario.InputParameters.DikeProfile.WorldReferencePoint); + } + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.TestUtil/GrassCoverErosionInwardsCalculationScenarioTestFactory.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.TestUtil/GrassCoverErosionInwardsCalculationScenarioTestFactory.cs (revision 0) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Data.TestUtil/GrassCoverErosionInwardsCalculationScenarioTestFactory.cs (revision 25c3f52ddce51f46f56cd796ea9b902eb1d6604c) @@ -0,0 +1,77 @@ +// Copyright (C) Stichting Deltares 2019. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Common.Base.Geometry; +using Riskeer.Common.Data.DikeProfiles; +using Riskeer.Common.Data.FailureMechanism; +using Riskeer.Common.Data.TestUtil; + +namespace Riskeer.GrassCoverErosionInwards.Data.TestUtil +{ + /// + /// Helper class for creating different instances of + /// for testing purposes. + /// + public static class GrassCoverErosionInwardsCalculationScenarioTestFactory + { + /// + /// Creates a calculated scenario for which the surface line on the input intersects with . + /// + /// The section for which an intersection will be created. + /// A new . + /// Thrown when is null. + public static GrassCoverErosionInwardsCalculationScenario CreateGrassCoverErosionInwardsCalculationScenario(FailureMechanismSection section) + { + GrassCoverErosionInwardsCalculationScenario scenario = CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario(section); + scenario.Output = new TestGrassCoverErosionInwardsOutput(); + + return scenario; + } + + /// + /// Creates a scenario for which the dike profile on the input intersects with and + /// the calculation has not been performed. + /// + /// The section for which an intersection will be created. + /// A new . + /// Thrown when is null. + public static GrassCoverErosionInwardsCalculationScenario CreateNotCalculatedGrassCoverErosionInwardsCalculationScenario(FailureMechanismSection section) + { + if (section == null) + { + throw new ArgumentNullException(nameof(section)); + } + + var scenario = new GrassCoverErosionInwardsCalculationScenario + { + IsRelevant = true, + InputParameters = + { + DikeProfile = DikeProfileTestFactory.CreateDikeProfile(section.StartPoint) + } + }; + + return scenario; + } + } +} \ No newline at end of file Index: Riskeer/Piping/test/Riskeer.Piping.Data.TestUtil.Test/PipingCalculationScenarioTestFactoryTest.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r25c3f52ddce51f46f56cd796ea9b902eb1d6604c --- Riskeer/Piping/test/Riskeer.Piping.Data.TestUtil.Test/PipingCalculationScenarioTestFactoryTest.cs (.../PipingCalculationScenarioTestFactoryTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/Piping/test/Riskeer.Piping.Data.TestUtil.Test/PipingCalculationScenarioTestFactoryTest.cs (.../PipingCalculationScenarioTestFactoryTest.cs) (revision 25c3f52ddce51f46f56cd796ea9b902eb1d6604c) @@ -32,17 +32,44 @@ public class PipingCalculationScenarioTestFactoryTest { [Test] - public void CreateIrrelevantPipingCalculationScenario_WithNoSection_ThrowsArgumentNullException() + public void CreatePipingCalculationScenario_SectionNull_ThrowsArgumentNullException() { // Call - TestDelegate test = () => PipingCalculationScenarioTestFactory.CreateIrrelevantPipingCalculationScenario(null); + void Call() => PipingCalculationScenarioTestFactory.CreatePipingCalculationScenario(null); // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("section", paramName); + var exception = Assert.Throws(Call); + Assert.AreEqual("section", exception.ParamName); } [Test] + public void CreatePipingCalculationScenario_WithSection_CreatesRelevantCalculationWithOutput() + { + // Setup + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + + // Call + PipingCalculationScenario scenario = PipingCalculationScenarioTestFactory.CreatePipingCalculationScenario(section); + + // Assert + Assert.IsNotNull(scenario.Output); + Assert.IsTrue(scenario.IsRelevant); + Assert.IsNotNull(scenario.InputParameters.SurfaceLine); + Assert.AreSame(section.StartPoint, scenario.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint); + } + + [Test] + public void CreateIrrelevantPipingCalculationScenario_SectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => PipingCalculationScenarioTestFactory.CreateIrrelevantPipingCalculationScenario(null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("section", exception.ParamName); + } + + [Test] public void CreateIrrelevantPipingCalculationScenario_WithSection_CreatesIrrelevantCalculation() { // Setup @@ -56,14 +83,14 @@ } [Test] - public void CreateNotCalculatedPipingCalculationScenario_WithNoSection_ThrowsArgumentNullException() + public void CreateNotCalculatedPipingCalculationScenario_SectionNull_ThrowsArgumentNullException() { // Call - TestDelegate test = () => PipingCalculationScenarioTestFactory.CreateNotCalculatedPipingCalculationScenario(null); + void Call() => PipingCalculationScenarioTestFactory.CreateNotCalculatedPipingCalculationScenario(null); // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("section", paramName); + var exception = Assert.Throws(Call); + Assert.AreEqual("section", exception.ParamName); } [Test] @@ -78,6 +105,8 @@ // Assert Assert.IsNull(scenario.Output); Assert.IsTrue(scenario.IsRelevant); + Assert.IsNotNull(scenario.InputParameters.SurfaceLine); + Assert.AreSame(section.StartPoint, scenario.InputParameters.SurfaceLine.ReferenceLineIntersectionWorldPoint); } [Test] @@ -94,11 +123,11 @@ public void CreatePipingCalculationScenarioWithValidInput_HydraulicBoundaryLocationNull_ThrowsArgumentnullException() { // Call - TestDelegate test = () => PipingCalculationScenarioTestFactory.CreatePipingCalculationScenarioWithValidInput(null); + void Call() => PipingCalculationScenarioTestFactory.CreatePipingCalculationScenarioWithValidInput(null); // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("hydraulicBoundaryLocation", paramName); + var exception = Assert.Throws(Call); + Assert.AreEqual("hydraulicBoundaryLocation", exception.ParamName); } [Test]