// Copyright (C) Stichting Deltares 2024. All rights reserved.
//
// This file is part of the application DAM - UI.
//
// DAM - UI 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 Deltares.Dam.Data;
using NUnit.Framework;
namespace Deltares.Dam.Tests
{
[TestFixture]
public class UpliftFactorToBetaCalculatorTest
{
private const double CTolerance = 0.0001;
private const double CBetaMax = 18.0;
private const double CBetaMin = -10.8;
[Test]
public void UpliftFactorsBelowLowerBoundaryComputedCorrectly()
{
Assert.AreEqual(CBetaMin, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.4), CTolerance);
Assert.IsTrue(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.2) < CBetaMin);
Assert.IsTrue(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.0) < CBetaMin);
}
[Test]
public void UpliftFactorsAboveUpperBoundaryComputedCorrectly()
{
Assert.AreEqual(CBetaMax, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(2.0), CTolerance);
Assert.IsTrue(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(3.0) > CBetaMax);
}
[Test]
public void UpliftFactorsWithinNormalRangeComputedCorrectly()
{
Assert.AreEqual(-7.2, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.6), CTolerance);
Assert.AreEqual(-3.6, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.8), CTolerance);
Assert.AreEqual(-1.8, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.9), CTolerance);
Assert.AreEqual(-0.36, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.98), CTolerance);
Assert.AreEqual(0.0, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(1.0), CTolerance);
Assert.AreEqual(1.8, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(1.1), CTolerance);
Assert.AreEqual(3.6, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(1.2), CTolerance);
Assert.AreEqual(14.4, UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(1.8), CTolerance);
}
[Test]
public void UpliftFactorLessThanZeroRaisesException()
{
Assert.That(() => UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(-1.0), Throws.InstanceOf());
}
}
}