using System; using Deltares.DamUplift; using NUnit.Framework; namespace Deltares.DamUpliftTests { [TestFixture] public class SoilVolumeMassCalculatorTest { [Test] public void TestCalculateForComplexProfileWithPhreaticLineInProfile1() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 const double cTolerance = 0.001; var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateComplexProfile(); calculator.SurfaceLevel = 0.21; calculator.PhreaticLevel = -0.98; calculator.TopOfLayerToBeEvaluated = -5.0; Assert.AreEqual(76.358, calculator.CalculateTotalMass(), cTolerance); } [Test] public void TestCalculateForComplexProfileWithPhreaticLineInProfile2() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 const double cTolerance = 0.001; var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateComplexProfile(); calculator.SurfaceLevel = 10.0; calculator.PhreaticLevel = -1.8; calculator.TopOfLayerToBeEvaluated = -5.0; Assert.AreEqual(230.22, calculator.CalculateTotalMass(), cTolerance); } [Test] public void TestCalculateForSimpleProfileWithPhreaticLineAboveProfile() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 const double cTolerance = 0.0001; var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); calculator.SurfaceLevel = 5.0; calculator.PhreaticLevel = 10.0; calculator.TopOfLayerToBeEvaluated = -10; calculator.VolumicWeightOfWater = 10.0; // All wet soil // wet 15 m x 16 kN/m3 = 240 // water above surface 5 m x 10.0 kN/m3 = 50 // Total: 240 + 50 = 290 Assert.AreEqual(290.0, calculator.CalculateTotalMass(), cTolerance); } [Test] public void TestCalculateForSimpleProfileWithPhreaticLineBelowProfile() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 const double cTolerance = 0.0001; var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); calculator.SurfaceLevel = 5.0; calculator.PhreaticLevel = -20.0; calculator.TopOfLayerToBeEvaluated = -10; // All dry soil // dry 15 m x 12 kN/m3 = 180 Assert.AreEqual(180.0, calculator.CalculateTotalMass(), cTolerance); } [Test] public void TestCalculateForSimpleProfileWithPhreaticLineInProfile() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 const double cTolerance = 0.0001; var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); calculator.SurfaceLevel = 5.0; calculator.PhreaticLevel = -1.0; calculator.TopOfLayerToBeEvaluated = -10; // Phreatic level in profile // dry 6 m x 12 kN/m3 = 72 // wet 9 m x 16 kN/m3 = 144 // Total: 72 + 144 = 216 Assert.AreEqual(216.0, calculator.CalculateTotalMass(), cTolerance); } /// /// Same as above test, but now the oven dry unit weight has to be used /// [Test] public void TestCalculateForSimpleProfileWithPhreaticLineInProfileAndDryOption() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 const double cTolerance = 0.0001; var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); foreach (var layer in calculator.SoilProfile.Layers) { layer.DryUnitWeight = layer.AbovePhreaticLevel; layer.AbovePhreaticLevel = layer.AbovePhreaticLevel + 1.0; } calculator.SurfaceLevel = 5.0; calculator.PhreaticLevel = -1.0; calculator.TopOfLayerToBeEvaluated = -10; calculator.IsUseOvenDryUnitWeight = true; // Phreatic level in profile // dry 6 m x 12 kN/m3 = 72 // wet 9 m x 16 kN/m3 = 144 // Total: 72 + 144 = 216 Assert.AreEqual(216.0, calculator.CalculateTotalMass(), cTolerance); } [Test] public void TestCalculateForTwoLayerProfileWithPhreaticLineOnBoundary() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 const double cTolerance = 0.0001; var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateTwoLayerProfile(); calculator.SurfaceLevel = 10.0; calculator.PhreaticLevel = 2.0; calculator.TopOfLayerToBeEvaluated = -10; calculator.VolumicWeightOfWater = 10.0; // All wet soil // dry 8 m x 10 kN/m3 = 80 // wet 12 m x 22 kN/m3 = 264 // Total: 80 + 264 = 344 Assert.AreEqual(344.0, calculator.CalculateTotalMass(), cTolerance); } [Test] [ExpectedException(typeof(SoilVolumicMassCalculatorException))] public void TestThrowsExceptionWhenSoilProfileParameterIsMissing() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 var calculator = new SoilVolumicMassCalculator(); calculator.CalculateTotalMass(); } [Test] [ExpectedException(typeof(SoilVolumicMassCalculatorException))] public void TestThrowsExceptionWhenSurfaceLevelIsAboveProfile() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); calculator.SurfaceLevel = 15.0; calculator.CalculateTotalMass(); } [Test] [ExpectedException(typeof(SoilVolumicMassCalculatorException), ExpectedMessage = "Het maaiveld ligt buiten het ondergrondprofiel")] [SetUICulture("nl-NL")] public void TestLanguageNlThrowsExceptionWhenSurfaceLevelIsAboveProfile() { var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); calculator.SurfaceLevel = 15.0; calculator.CalculateTotalMass(); } [Test] [ExpectedException(typeof(SoilVolumicMassCalculatorException), ExpectedMessage = "Surfacelevel is not inside soil profile")] [SetUICulture("en-US")] public void TestLanguageEnThrowsExceptionWhenSurfaceLevelIsAboveProfile() { var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); calculator.SurfaceLevel = 15.0; calculator.CalculateTotalMass(); } [Test] [ExpectedException(typeof(SoilVolumicMassCalculatorException))] public void TestThrowsExceptionWhenSurfaceLevelIsBelowProfile() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); calculator.SurfaceLevel = -100.0; calculator.CalculateTotalMass(); } [Test] [ExpectedException(typeof(SoilVolumicMassCalculatorException))] public void TestThrowsExceptionWhenTopLevelToBeValuatedIsBelowProfile() { // test is copied from 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 var calculator = new SoilVolumicMassCalculator(); calculator.SoilProfile = FactoryForSoilProfileTests.CreateSimpleProfile(); calculator.TopOfLayerToBeEvaluated = -100.0; calculator.CalculateTotalMass(); } } }