// Copyright (C) Stichting Deltares 2025. 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.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.4), Is.EqualTo(CBetaMin).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.2), Is.LessThan(CBetaMin));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.0), Is.LessThan(CBetaMin));
}
[Test]
public void UpliftFactorsAboveUpperBoundaryComputedCorrectly()
{
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(2.0), Is.EqualTo(CBetaMax).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(3.0), Is.GreaterThan(CBetaMax));
}
[Test]
public void UpliftFactorsWithinNormalRangeComputedCorrectly()
{
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.6), Is.EqualTo(-7.2).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.8), Is.EqualTo(-3.6).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.9), Is.EqualTo(-1.8).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(0.98), Is.EqualTo(-0.36).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(1.0), Is.EqualTo(0.0).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(1.1), Is.EqualTo(1.8).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(1.2), Is.EqualTo(3.6).Within(CTolerance));
Assert.That(UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(1.8), Is.EqualTo(14.4).Within(CTolerance));
}
[Test]
public void UpliftFactorLessThanZeroRaisesException()
{
Assert.That(() => UpliftFactorToBetaCalculator.ComputeBetaFromUpliftFactor(-1.0), Throws.InstanceOf());
}
}
}