// 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.Standard;
using Deltares.Dam.Data;
using NUnit.Framework;
namespace Deltares.Dam.Tests
{
[TestFixture]
public class DamFailureMechanismeCalculationSpecificationTest
{
[Test]
public void Constructor_ExpectedValues()
{
// Call
var parameters = new DamFailureMechanismeCalculationSpecification();
// Assert
Assert.That(parameters, Is.InstanceOf>());
Assert.That(parameters, Is.InstanceOf());
Assert.Multiple(() =>
{
Assert.That(parameters.StabilityModelType, Is.EqualTo(StabilityModelType.UpliftVan));
Assert.That(parameters.SearchMethod, Is.EqualTo(StabilitySearchMethod.BeeSwarm));
Assert.That(parameters.SlipCircleDefinition, Is.Not.Null);
});
}
[Test]
[TestCase(FailureMechanismSystemType.StabilityInside, true)]
[TestCase(FailureMechanismSystemType.StabilityOutside, false)]
public void GivenSpecificationWithStabilityModel_WhenIsEnabledCalledWithCalculationModel_ThenReturnsExpectedResult(
FailureMechanismSystemType failureMechanism, bool expectedIsEnabled)
{
// Given
var specification = new DamFailureMechanismeCalculationSpecification
{
FailureMechanismSystemType = failureMechanism
};
// When
bool isEnabled = specification.IsEnabled(nameof(specification.CalculationModel));
// Then
Assert.That(isEnabled, Is.EqualTo(expectedIsEnabled));
}
[Test]
[TestCase(null)]
[TestCase("")]
[TestCase(" ")]
[TestCase("Property")]
public void GivenSpecificationWithStabilityInside_WhenIsEnabledCalledWithOtherProperty_ThenReturnsTrue(
string property)
{
// Given
var specification = new DamFailureMechanismeCalculationSpecification
{
FailureMechanismSystemType = FailureMechanismSystemType.StabilityInside
};
// When
bool isEnabled = specification.IsEnabled(property);
// Then
Assert.That(isEnabled, Is.True);
}
[Test]
[TestCase(null)]
[TestCase("")]
[TestCase(" ")]
[TestCase("Property")]
public void GivenSpecificationWithStabilityOutside_WhenIsEnabledCalledWithOtherProperty_ThenReturnsTrue(
string property)
{
// Given
var specification = new DamFailureMechanismeCalculationSpecification
{
FailureMechanismSystemType = FailureMechanismSystemType.StabilityOutside
};
// When
bool isEnabled = specification.IsEnabled(property);
// Then
Assert.That(isEnabled, Is.True);
}
[Test]
[TestCase(FailureMechanismSystemType.Piping)]
public void GivenSpecificationWithNotStabilityModel_WhenIsEnabledCalledWithCalculationModel_ThenReturnsTrue(
FailureMechanismSystemType failureMechanism)
{
// Given
var specification = new DamFailureMechanismeCalculationSpecification
{
FailureMechanismSystemType = failureMechanism
};
// When
bool isEnabled = specification.IsEnabled(nameof(specification.CalculationModel));
// Then
Assert.That(isEnabled, Is.True);
}
[Test]
[TestCase(FailureMechanismSystemType.StabilityInside, true)]
[TestCase(FailureMechanismSystemType.StabilityOutside, false)]
[TestCase(FailureMechanismSystemType.Piping, false)]
public void IsVisible_WithFailureMechanismTypeAndCalledWithStabilityParametersProperty_ReturnsExpectedResult(
FailureMechanismSystemType failureMechanismSystemType, bool expectedVisibility)
{
// Setup
var specification = new DamFailureMechanismeCalculationSpecification
{
FailureMechanismSystemType = failureMechanismSystemType
};
// Call
bool isVisible = specification.IsVisible(nameof(DamFailureMechanismeCalculationSpecification.StabilityModelType));
// Assert
Assert.That(isVisible, Is.EqualTo(expectedVisibility));
}
[Test]
[TestCase(null)]
[TestCase("")]
[TestCase(" ")]
[TestCase("Property")]
public void IsVisible_CalledWithProperty_ReturnsTrue(string property)
{
// Setup
var specification = new DamFailureMechanismeCalculationSpecification
{
FailureMechanismSystemType = FailureMechanismSystemType.StabilityInside
};
// Call
bool isVisible = specification.IsVisible(property);
// Assert
Assert.That(isVisible, Is.True);
}
}
}