// 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.Linq; using Core.Common.Base.Geometry; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Calculators.Waternet { [TestFixture] public class WaternetCalculatorTest { [Test] public void Constructor_InputNull_ArgumentNullException() { // Setup var mocks = new MockRepository(); var factory = mocks.Stub(); mocks.ReplayAll(); // Call TestDelegate call = () => new WaternetCalculator(null, factory); // Assert var exception = Assert.Throws(call); Assert.AreEqual("input", exception.ParamName); mocks.VerifyAll(); } [Test] public void Constructor_FactoryNull_ArgumentNullException() { // Setup WaternetCalculatorInput input = CreateValidCalculatorInput(); // Call TestDelegate call = () => new WaternetCalculator(input, null); // Assert var exception = Assert.Throws(call); Assert.AreEqual("factory", exception.ParamName); } [Test] public void Constructor_ExpectedValues() { // Setup var mocks = new MockRepository(); var factory = mocks.Stub(); mocks.ReplayAll(); WaternetCalculatorInput input = CreateValidCalculatorInput(); // Call var calculator = new WaternetCalculator(input, factory); // Assert Assert.IsInstanceOf(calculator); mocks.VerifyAll(); } private WaternetCalculatorInput CreateValidCalculatorInput() { var random = new Random(21); MacroStabilityInwardsSurfaceLine surfaceLine = CreateValidSurfaceLine(); return new WaternetCalculatorInput(new WaternetCalculatorInput.ConstructionProperties { AssessmentLevel = random.NextDouble(), SurfaceLine = surfaceLine, SoilProfile = CreateValidSoilProfile(surfaceLine), DrainageConstruction = new DrainageConstruction(), PhreaticLineOffsetsExtreme = new PhreaticLineOffsets(), PhreaticLineOffsetsDaily = new PhreaticLineOffsets() }); } private static SoilProfile CreateValidSoilProfile(MacroStabilityInwardsSurfaceLine surfaceLine) { return new SoilProfile(new[] { new SoilLayer( new[] { surfaceLine.LocalGeometry.First(), surfaceLine.LocalGeometry.Last() }, Enumerable.Empty(), new SoilLayer.ConstructionProperties()), new SoilLayer( new[] { surfaceLine.LocalGeometry.First(), surfaceLine.LocalGeometry.Last() }, Enumerable.Empty(), new SoilLayer.ConstructionProperties { IsAquifer = true }), new SoilLayer( new[] { surfaceLine.LocalGeometry.First(), surfaceLine.LocalGeometry.Last() }, Enumerable.Empty(), new SoilLayer.ConstructionProperties()), new SoilLayer( new[] { surfaceLine.LocalGeometry.First(), surfaceLine.LocalGeometry.Last() }, Enumerable.Empty(), new SoilLayer.ConstructionProperties()) }, new[] { new PreconsolidationStress(new Point2D(0, 0), 1.1) }); } private static MacroStabilityInwardsSurfaceLine CreateValidSurfaceLine() { var surfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); var dikeToeAtRiver = new Point3D(1, 0, 8); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 2), dikeToeAtRiver, new Point3D(2, 0, -1) }); surfaceLine.SetDikeToeAtRiverAt(dikeToeAtRiver); return surfaceLine; } } }