// Copyright (C) Stichting Deltares 2016. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets 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 System.ComponentModel; using Core.Common.Gui.PropertyBag; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.WaveImpactAsphaltCover.Data; using Ringtoets.WaveImpactAsphaltCover.Forms.PropertyClasses; namespace Ringtoets.WaveImpactAsphaltCover.Forms.Test.PropertyClasses { [TestFixture] public class WaveImpactAsphaltCoverFailureMechanismPropertiesTest { [Test] public void Constructor_ExpectedValues() { // Call var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(); // Assert Assert.IsInstanceOf>(properties); } [Test] [TestCase(true)] [TestCase(false)] public void Data_SetNewWaveImpactAsphaltCoverFailureMechanismContext_ReturnCorrectPropertyValues(bool isRelevant) { // Setup var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism { IsRelevant = isRelevant }; var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(); // Call properties.Data = failureMechanism; // Assert Assert.AreEqual(failureMechanism.Name, properties.Name); Assert.AreEqual(failureMechanism.Code, properties.Code); Assert.AreEqual(isRelevant, properties.IsRelevant); Assert.AreEqual(failureMechanism.GeneralInput.A, properties.A); Assert.AreEqual(failureMechanism.GeneralInput.B, properties.B); Assert.AreEqual(failureMechanism.GeneralInput.C, properties.C); } [Test] public void Constructor_IsRelevantTrue_PropertiesHaveExpectedAttributesValues() { // Call var properties = new WaveImpactAsphaltCoverFailureMechanismProperties { Data = new WaveImpactAsphaltCoverFailureMechanism { IsRelevant = true } }; // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(6, dynamicProperties.Count); const string generalCategory = "Algemeen"; const string modelSettingsCategory = "Modelinstellingen"; PropertyDescriptor nameProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "De naam van het toetsspoor.", true); PropertyDescriptor codeProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, generalCategory, "Label", "Het label van het toetsspoor.", true); PropertyDescriptor isRelevantProperty = dynamicProperties[2]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, generalCategory, "Is relevant", "Geeft aan of dit toetsspoor relevant is of niet.", true); PropertyDescriptor aProperty = dynamicProperties[3]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(aProperty, modelSettingsCategory, "a", "De waarde van de parameter 'a' in de berekening voor golf condities.", true); PropertyDescriptor bProperty = dynamicProperties[4]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(bProperty, modelSettingsCategory, "b", "De waarde van de parameter 'b' in de berekening voor golf condities.", true); PropertyDescriptor cProperty = dynamicProperties[5]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(cProperty, modelSettingsCategory, "c", "De waarde van de parameter 'c' in de berekening voor golf condities.", true); } [Test] public void Constructor_IsRelevantFalse_PropertiesHaveExpectedAttributesValues() { // Call var properties = new WaveImpactAsphaltCoverFailureMechanismProperties { Data = new WaveImpactAsphaltCoverFailureMechanism { IsRelevant = false } }; // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(3, dynamicProperties.Count); const string generalCategory = "Algemeen"; PropertyDescriptor nameProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, generalCategory, "Naam", "De naam van het toetsspoor.", true); PropertyDescriptor codeProperty = dynamicProperties[1]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, generalCategory, "Label", "Het label van het toetsspoor.", true); PropertyDescriptor isRelevantProperty = dynamicProperties[2]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, generalCategory, "Is relevant", "Geeft aan of dit toetsspoor relevant is of niet.", true); } [Test] public void DynamicVisibleValidationMethod_ForRelevantFailureMechanism_ReturnExpectedVisibility() { // Setup var properties = new WaveImpactAsphaltCoverFailureMechanismProperties { Data = new WaveImpactAsphaltCoverFailureMechanism { IsRelevant = true } }; // Call & Assert Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.A))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.B))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.C))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.IsRelevant))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); } [Test] public void DynamicVisibleValidationMethod_ForIrrelevantFailureMechanism_ReturnExpectedVisibility() { // Setup var properties = new WaveImpactAsphaltCoverFailureMechanismProperties { Data = new WaveImpactAsphaltCoverFailureMechanism { IsRelevant = false } }; // Call & Assert Assert.IsFalse(properties.DynamicVisibleValidationMethod(nameof(properties.A))); Assert.IsFalse(properties.DynamicVisibleValidationMethod(nameof(properties.B))); Assert.IsFalse(properties.DynamicVisibleValidationMethod(nameof(properties.C))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.IsRelevant))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); } } }