// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of the Dam Engine. // // The Dam Engine is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero 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 Affero General Public License for more details. // // You should have received a copy of the GNU Affero 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.Collections.Generic; using System.Data; using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability; using Deltares.DamEngine.Data.General.Results; using Deltares.DamEngine.Data.Standard.Logging; using NUnit.Framework; namespace Deltares.DamEngine.Calculators.Tests { [TestFixture] public class DamMacroStabilityTests { [Test] public void TestFullCalculation() { const double diff = 0.0001; // ToDo zant Fill input var damKernelInput = new DamKernelInput(); var kernelWrapper = new DamMacroStabilityKernelWrapper(); // Prepare the wrapper. Result is input for the calculation dll var damStabilityInput = kernelWrapper.Prepare(damKernelInput); // Validate the input List messages; kernelWrapper.Validate(damStabilityInput, out messages); // Assert.AreEqual(0, messages.Count); // Run the dll // DamMacroStabilityOutput output = (DamMacroStabilityOutput)kernelWrapper.Execute(damStabilityInput, out messages); // Assert.AreEqual(0, messages.Count); // ToDo zant specify output // Assert.AreEqual(0.0, output.xxx, diff); // Fill the design results // DesignResult result; // kernelWrapper.PostProcess(output, out result); // ToDo zant specify output // Assert.AreEqual(0.0, result.StabilityDesignResults.SafetyFactor, diff); } [Test] public void TestValidate() { var kernelWrapper = new DamMacroStabilityKernelWrapper(); // Validate without setting values. Expected error messages. var damStabilityInput = new DamMacroStabilityInput(); List messages; //ToDo zant Validate is not implemented yet // kernelWrapper.Validate(damStabilityInput, out messages); // Assert.IsTrue(messages.Count > 0); // Validate the input when valid input is provided. Expected no messages. damStabilityInput = new DamMacroStabilityInput { // ToDo zant Fill input }; // messages.Clear(); kernelWrapper.Validate(damStabilityInput, out messages); Assert.AreEqual(0, messages.Count); } [Test] public void TestPostProcess() { var kernelWrapper = new DamMacroStabilityKernelWrapper(); DamMacroStabilityOutput output = new DamMacroStabilityOutput(); // ToDo zant specify output // output.xxx = 1.1; // output.yyy = 2.2; DesignResult result; kernelWrapper.PostProcess(null, output, out result); // ToDo zant specify output // Assert.AreEqual(output.xxx, result.StabilityDesignResults.SafetyFactor); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen invoer object gedefinieerd voor Macrostabiliteit")] [SetUICulture("nl-NL")] public void TestLanguageNLThrowsExceptionWhenInputIsNull() { DamMacroStabilityKernelWrapper.StabilityCalculator(null); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "No input object defined for Macro Stability")] [SetUICulture("en-US")] public void TestLanguageENThrowsExceptionWhenInputIsNull() { DamMacroStabilityKernelWrapper.StabilityCalculator(null); } [Test] [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen uitvoer object gedefinieerd voor Macrostabiliteit")] [SetUICulture("nl-NL")] public void TestThrowsExceptionWhenOutputIsNull() { var kernelWrapper = new DamMacroStabilityKernelWrapper(); DesignResult result; kernelWrapper.PostProcess(null, null, out result); } } }