// Copyright (C) Stichting Deltares 2021. 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 DamFailureMechanismeCalculationSpecificationTest { [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)] [TestCase(FailureMechanismSystemType.FlowSlide)] 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.HorizontalBalance, false)] [TestCase(FailureMechanismSystemType.Piping, false)] [TestCase(FailureMechanismSystemType.FlowSlide, true)] public void IsVisible_WithFailureMechanismTypeAndCalledWithFailureMechanismeParamatersMStabProperty_ReturnsExpectedResult( FailureMechanismSystemType failureMechanismSystemType, bool expectedVisibility) { // Setup var specification = new DamFailureMechanismeCalculationSpecification { FailureMechanismSystemType = failureMechanismSystemType }; // Call bool isVisible = specification.IsVisible(nameof(DamFailureMechanismeCalculationSpecification.FailureMechanismeParamatersMStab)); // 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); } } }