// 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 Core.Common.TestUtil; using NUnit.Framework; using Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.Input; namespace Riskeer.MacroStabilityInwards.KernelWrapper.Test.Calculators.Input { [TestFixture] public class SoilLayerTest { [Test] public void Constructor_OuterRingNull_ThrowsArgumentNullException() { // Call void Call() => new SoilLayer(null, new SoilLayer.ConstructionProperties(), Enumerable.Empty()); // Assert var exception = Assert.Throws(Call); Assert.AreEqual("outerRing", exception.ParamName); } [Test] public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException() { // Call void Call() => new SoilLayer(new Point2D[0], null, Enumerable.Empty()); // Assert var exception = Assert.Throws(Call); Assert.AreEqual("properties", exception.ParamName); } [Test] public void Constructor_NestedLayersNull_ThrowsArgumentNullException() { // Call void Call() => new SoilLayer(new Point2D[0], new SoilLayer.ConstructionProperties(), null); // Assert var exception = Assert.Throws(Call); Assert.AreEqual("nestedLayers", exception.ParamName); } [Test] public void Constructor_WithAllParameters_ExpectedValues() { // Setup var outerRing = new Point2D[0]; var nestedLayers = new SoilLayer[0]; // Call var layer = new SoilLayer(outerRing, new SoilLayer.ConstructionProperties(), nestedLayers); // Assert Assert.AreSame(outerRing, layer.OuterRing); Assert.AreSame(nestedLayers, layer.NestedLayers); } [Test] public void Constructor_EmptyConstructionProperties_ExpectedValues() { // Call var layer = new SoilLayer(new Point2D[0], new SoilLayer.ConstructionProperties(), Enumerable.Empty()); // Assert Assert.IsFalse(layer.IsAquifer); Assert.IsFalse(layer.UsePop); Assert.IsEmpty(layer.MaterialName); Assert.AreEqual(ShearStrengthModel.CPhi, layer.ShearStrengthModel); Assert.IsNaN(layer.AbovePhreaticLevel); Assert.IsNaN(layer.BelowPhreaticLevel); Assert.IsNaN(layer.Cohesion); Assert.IsNaN(layer.FrictionAngle); Assert.IsNaN(layer.ShearStrengthRatio); Assert.IsNaN(layer.StrengthIncreaseExponent); Assert.IsNaN(layer.Pop); Assert.IsNaN(layer.Dilatancy); Assert.AreEqual(WaterPressureInterpolationModel.Automatic, layer.WaterPressureInterpolationModel); } [Test] public void Constructor_WithConstructionProperties_ExpectedValues() { // Setup const string materialName = "test"; var random = new Random(11); bool isAquifer = random.NextBoolean(); bool usePop = random.NextBoolean(); var shearStrengthModel = random.NextEnumValue(); double abovePhreaticLevel = random.NextDouble(); double belowPhreaticLevel = random.NextDouble(); double cohesion = random.NextDouble(); double frictionAngle = random.NextDouble(); double shearStrengthRatio = random.NextDouble(); double strengthIncreaseExponent = random.NextDouble(); double pop = random.NextDouble(); double dilatancy = random.NextDouble(); var waterPressureInterpolationModel = random.NextEnumValue(); // Call var layer = new SoilLayer(new Point2D[0], new SoilLayer.ConstructionProperties { MaterialName = materialName, IsAquifer = isAquifer, UsePop = usePop, ShearStrengthModel = shearStrengthModel, AbovePhreaticLevel = abovePhreaticLevel, BelowPhreaticLevel = belowPhreaticLevel, Cohesion = cohesion, FrictionAngle = frictionAngle, ShearStrengthRatio = shearStrengthRatio, StrengthIncreaseExponent = strengthIncreaseExponent, Pop = pop, Dilatancy = dilatancy, WaterPressureInterpolationModel = waterPressureInterpolationModel }, Enumerable.Empty()); // Assert Assert.AreEqual(materialName, layer.MaterialName); Assert.AreEqual(isAquifer, layer.IsAquifer); Assert.AreEqual(usePop, layer.UsePop); Assert.AreEqual(shearStrengthModel, layer.ShearStrengthModel); Assert.AreEqual(abovePhreaticLevel, layer.AbovePhreaticLevel); Assert.AreEqual(belowPhreaticLevel, layer.BelowPhreaticLevel); Assert.AreEqual(cohesion, layer.Cohesion); Assert.AreEqual(frictionAngle, layer.FrictionAngle); Assert.AreEqual(shearStrengthRatio, layer.ShearStrengthRatio); Assert.AreEqual(strengthIncreaseExponent, layer.StrengthIncreaseExponent); Assert.AreEqual(pop, layer.Pop); Assert.AreEqual(dilatancy, layer.Dilatancy); Assert.AreEqual(waterPressureInterpolationModel, layer.WaterPressureInterpolationModel); } } }