// 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.ComponentModel;
using System.Linq;
using NUnit.Framework;
using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input;
using Ringtoets.MacroStabilityInwards.Primitives;
namespace Ringtoets.MacroStabilityInwards.CalculatedInput.TestUtil
{
///
/// Class for asserting calculator input.
///
public static class CalculatorInputAssert
{
///
/// Asserts whether corresponds to .
///
/// The original .
/// The actual .
/// Thrown when
/// does not correspond to .
public static void AssertSoilProfile(IMacroStabilityInwardsSoilProfileUnderSurfaceLine original, SoilProfile actual)
{
IMacroStabilityInwardsSoilLayer2D[] expectedLayers = original.Layers.ToArray();
SoilLayer[] actualLayers = actual.Layers.ToArray();
IMacroStabilityInwardsPreconsolidationStress[] expectedPreconsolidationStresses = original.PreconsolidationStresses.ToArray();
PreconsolidationStress[] actualPreconsolidationStresses = actual.PreconsolidationStresses.ToArray();
AssertLayers(expectedLayers, actualLayers);
AssertPreconsolidationStresses(expectedPreconsolidationStresses, actualPreconsolidationStresses);
}
///
/// Asserts whether corresponds to .
///
/// The original .
/// The actual .
/// Thrown when
/// does not correspond to .
public static void AssertDrainageConstruction(IMacroStabilityInwardsWaternetInput original, DrainageConstruction actual)
{
Assert.AreEqual(original.DrainageConstructionPresent, actual.IsPresent);
Assert.AreEqual(original.XCoordinateDrainageConstruction, actual.XCoordinate);
Assert.AreEqual(original.ZCoordinateDrainageConstruction, actual.ZCoordinate);
}
///
/// Asserts whether corresponds to .
///
/// The original .
/// The actual .
/// Thrown when
/// does not correspond to .
public static void AssertPhreaticLineOffsets(IMacroStabilityInwardsLocationInput original, PhreaticLineOffsets actual)
{
Assert.AreEqual(original.UseDefaultOffsets, actual.UseDefaults);
Assert.AreEqual(original.PhreaticLineOffsetBelowDikeTopAtRiver, actual.BelowDikeTopAtRiver);
Assert.AreEqual(original.PhreaticLineOffsetBelowDikeTopAtPolder, actual.BelowDikeTopAtPolder);
Assert.AreEqual(original.PhreaticLineOffsetBelowDikeToeAtPolder, actual.BelowDikeToeAtPolder);
Assert.AreEqual(original.PhreaticLineOffsetBelowShoulderBaseInside, actual.BelowShoulderBaseInside);
}
///
/// Asserts whether corresponds to .
///
/// The original array.
/// The actual array.
/// Thrown when
/// does not correspond to .
private static void AssertPreconsolidationStresses(IMacroStabilityInwardsPreconsolidationStress[] original,
PreconsolidationStress[] actual)
{
Assert.AreEqual(original.Length, actual.Length);
for (var i = 0; i < original.Length; i++)
{
Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPreconsolidationStress(original[i]).GetDesignValue(), actual[i].Stress);
Assert.AreSame(original[i].Location, actual[i].Coordinate);
}
}
///
/// Asserts whether corresponds to .
///
/// The original array.
/// The actual array.
/// Thrown when
/// does not correspond to .
private static void AssertLayers(IMacroStabilityInwardsSoilLayer2D[] original, SoilLayer[] actual)
{
Assert.AreEqual(original.Length, actual.Length);
for (var i = 0; i < original.Length; i++)
{
CollectionAssert.AreEqual(original[i].OuterRing.Points, actual[i].OuterRing);
AssertLayers(original[i].NestedLayers.ToArray(), actual[i].NestedLayers.ToArray());
IMacroStabilityInwardsSoilLayerData expectedData = original[i].Data;
Assert.AreEqual(expectedData.MaterialName, actual[i].MaterialName);
Assert.AreEqual(expectedData.UsePop, actual[i].UsePop);
Assert.AreEqual(expectedData.IsAquifer, actual[i].IsAquifer);
Assert.AreEqual(DilatancyType.Zero, actual[i].DilatancyType);
Assert.AreEqual(WaterPressureInterpolationModel.Automatic, actual[i].WaterPressureInterpolationModel);
Assert.AreEqual(ConvertShearStrengthModel(expectedData.ShearStrengthModel), actual[i].ShearStrengthModel);
Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetAbovePhreaticLevel(expectedData).GetDesignValue(), actual[i].AbovePhreaticLevel);
Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetBelowPhreaticLevel(expectedData).GetDesignValue(), actual[i].BelowPhreaticLevel);
Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetCohesion(expectedData).GetDesignValue(), actual[i].Cohesion);
Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetFrictionAngle(expectedData).GetDesignValue(), actual[i].FrictionAngle);
Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetStrengthIncreaseExponent(expectedData).GetDesignValue(), actual[i].StrengthIncreaseExponent);
Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetShearStrengthRatio(expectedData).GetDesignValue(), actual[i].ShearStrengthRatio);
Assert.AreEqual(MacroStabilityInwardsSemiProbabilisticDesignVariableFactory.GetPop(expectedData).GetDesignValue(), actual[i].Pop);
}
}
///
/// Converts to a .
///
/// The original shear strength model
/// A converted shear strength model
/// Thrown when
/// is an invalid value.
private static ShearStrengthModel ConvertShearStrengthModel(MacroStabilityInwardsShearStrengthModel shearStrengthModel)
{
switch (shearStrengthModel)
{
case MacroStabilityInwardsShearStrengthModel.SuCalculated:
return ShearStrengthModel.SuCalculated;
case MacroStabilityInwardsShearStrengthModel.CPhi:
return ShearStrengthModel.CPhi;
case MacroStabilityInwardsShearStrengthModel.CPhiOrSuCalculated:
return ShearStrengthModel.CPhiOrSuCalculated;
default:
throw new InvalidEnumArgumentException();
}
}
}
}