Fisheye: Tag 0a988b3667d32fbae19e420aa71038bcc97d3b38 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesBase.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesBase.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesBase.cs (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -0,0 +1,128 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using System.Collections.Generic; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Core.Gui.PropertyBag; +using Riskeer.GrassCoverErosionOutwards.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses +{ + /// + /// Base ViewModel of for properties panel. + /// + public abstract class GrassCoverErosionOutwardsFailureMechanismPropertiesBase : ObjectProperties + { + private readonly Dictionary propertyIndexLookup; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// The property values required to create an instance of + /// . + /// Thrown when any parameter is null. + protected GrassCoverErosionOutwardsFailureMechanismPropertiesBase(GrassCoverErosionOutwardsFailureMechanism data, + ConstructionProperties constructionProperties) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + if (constructionProperties == null) + { + throw new ArgumentNullException(nameof(constructionProperties)); + } + + Data = data; + + propertyIndexLookup = new Dictionary + { + { + nameof(Name), constructionProperties.NamePropertyIndex + }, + { + nameof(Code), constructionProperties.CodePropertyIndex + } + }; + } + + [DynamicPropertyOrderEvaluationMethod] + public int DynamicPropertyOrderEvaluationMethod(string propertyName) + { + propertyIndexLookup.TryGetValue(propertyName, out int propertyIndex); + + return propertyIndex; + } + + /// + /// Class holding the various construction parameters for . + /// + public class ConstructionProperties + { + #region General + + /// + /// Gets or sets the property index for . + /// + public int NamePropertyIndex { get; set; } + + /// + /// Gets or sets the property index for . + /// + public int CodePropertyIndex { get; set; } + + #endregion + } + + #region General + + [DynamicPropertyOrder] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_Description))] + public string Name + { + get + { + return data.Name; + } + } + + [DynamicPropertyOrder] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Code_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Code_Description))] + public string Code + { + get + { + return data.Code; + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag 0a988b3667d32fbae19e420aa71038bcc97d3b38 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0a988b3667d32fbae19e420aa71038bcc97d3b38 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismProperties.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismProperties.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismProperties.cs (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -0,0 +1,108 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using System.ComponentModel; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.Properties; +using Riskeer.Revetment.Forms.PropertyClasses; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.HydraulicLoadsState +{ + /// + /// Hydraulic loads state related ViewModel of for properties panel. + /// + public class GrassCoverErosionOutwardsFailureMechanismProperties : GrassCoverErosionOutwardsFailureMechanismPropertiesBase + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int waveRunUpPropertyIndex = 3; + private const int waveImpactPropertyIndex = 4; + private const int waveImpactWithWaveDirectionPropertyIndex = 5; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// Thrown when is null. + public GrassCoverErosionOutwardsFailureMechanismProperties(GrassCoverErosionOutwardsFailureMechanism data) + : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }) {} + + #region Model settings + + [PropertyOrder(waveRunUpPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveRunUp_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveRunUp_Description))] + public GeneralWaveConditionsInputProperties WaveRunUp + { + get + { + return new GeneralWaveConditionsInputProperties + { + Data = data.GeneralInput.GeneralWaveRunUpWaveConditionsInput + }; + } + } + + [PropertyOrder(waveImpactPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveImpact_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveImpact_Description))] + public GeneralWaveConditionsInputProperties WaveImpact + { + get + { + return new GeneralWaveConditionsInputProperties + { + Data = data.GeneralInput.GeneralWaveImpactWaveConditionsInput + }; + } + } + + [PropertyOrder(waveImpactWithWaveDirectionPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveImpactWithWaveDirection_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveImpactWithWaveDirection_Description))] + public GeneralWaveConditionsInputProperties WaveImpactWithWaveDirection + { + get + { + return new GeneralWaveConditionsInputProperties + { + Data = data.GeneralInput.GeneralWaveImpactWithWaveDirectionWaveConditionsInput + }; + } + } + + #endregion + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/RegistrationState/GrassCoverErosionOutwardsFailureMechanismProperties.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/RegistrationState/GrassCoverErosionOutwardsFailureMechanismProperties.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/RegistrationState/GrassCoverErosionOutwardsFailureMechanismProperties.cs (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -0,0 +1,127 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using Core.Common.Base.Data; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; +using Riskeer.GrassCoverErosionOutwards.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.RegistrationState +{ + /// + /// Registration state related ViewModel of for properties panel. + /// + public class GrassCoverErosionOutwardsFailureMechanismProperties : GrassCoverErosionOutwardsFailureMechanismPropertiesBase + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int inAssemblyPropertyIndex = 3; + private const int nPropertyIndex = 4; + private const int applyLengthEffectInSectionPropertyIndex = 5; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// Thrown when is null. + public GrassCoverErosionOutwardsFailureMechanismProperties(GrassCoverErosionOutwardsFailureMechanism data) + : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }) {} + + #region General + + [PropertyOrder(inAssemblyPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_InAssembly_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_InAssembly_Description))] + public bool InAssembly + { + get + { + return data.InAssembly; + } + } + + #endregion + + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + if (!data.InAssembly && ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(propertyName)) + { + return false; + } + + return true; + } + + private static bool ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(string propertyName) + { + return nameof(N).Equals(propertyName) + || nameof(ApplyLengthEffectInSection).Equals(propertyName); + } + + #region Length effect parameters + + [DynamicVisible] + [PropertyOrder(nPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Description))] + public RoundedDouble N + { + get + { + return data.GeneralInput.N; + } + set + { + data.GeneralInput.N = value; + data.NotifyObservers(); + } + } + + [DynamicVisible] + [PropertyOrder(applyLengthEffectInSectionPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_ApplyLengthEffectInSection_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailurePath_ApplyLengthEffectInSection_Description))] + public bool ApplyLengthEffectInSection + { + get + { + return data.GeneralInput.ApplyLengthEffectInSection; + } + set + { + data.GeneralInput.ApplyLengthEffectInSection = value; + data.NotifyObservers(); + } + } + + #endregion + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r160e88782fbd20958a9ebd55511782b203d141e5 -r0a988b3667d32fbae19e420aa71038bcc97d3b38 --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 160e88782fbd20958a9ebd55511782b203d141e5) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -59,6 +59,8 @@ using Riskeer.Revetment.Data; using Riskeer.Revetment.Forms.Views; using Riskeer.Revetment.Service; +using HydraulicLoadsStateFailureMechanismProperties = Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.HydraulicLoadsState.GrassCoverErosionOutwardsFailureMechanismProperties; +using RegistrationStateFailureMechanismProperties = Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.RegistrationState.GrassCoverErosionOutwardsFailureMechanismProperties; using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; using RiskeerCommonIoResources = Riskeer.Common.IO.Properties.Resources; @@ -72,15 +74,14 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new GrassCoverErosionOutwardsHydraulicLoadsProperties(context.WrappedData) + CreateInstance = context => new HydraulicLoadsStateFailureMechanismProperties(context.WrappedData) }; - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new GrassCoverErosionOutwardsFailurePathProperties( - context.WrappedData) + CreateInstance = context => new RegistrationStateFailureMechanismProperties(context.WrappedData) }; yield return new PropertyInfo Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesBaseTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesBaseTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesBaseTest.cs (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -0,0 +1,120 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using System.ComponentModel; +using Core.Gui.PropertyBag; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.Test.PropertyClasses +{ + [TestFixture] + public class GrassCoverErosionOutwardsFailureMechanismPropertiesBaseTest + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 0; + + [Test] + public void Constructor_DataNull_ThrowArgumentNullException() + { + // Call + void Call() => new TestGrassCoverErosionOutwardsFailureMechanismProperties( + null, new GrassCoverErosionOutwardsFailureMechanismPropertiesBase.ConstructionProperties()); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("data", exception.ParamName); + } + + [Test] + public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException() + { + // Call + void Call() => new TestGrassCoverErosionOutwardsFailureMechanismProperties( + new GrassCoverErosionOutwardsFailureMechanism(), null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("constructionProperties", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var properties = new TestGrassCoverErosionOutwardsFailureMechanismProperties( + failureMechanism, new GrassCoverErosionOutwardsFailureMechanismPropertiesBase.ConstructionProperties()); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var properties = new TestGrassCoverErosionOutwardsFailureMechanismProperties( + failureMechanism, new GrassCoverErosionOutwardsFailureMechanismPropertiesBase.ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(2, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + } + + private class TestGrassCoverErosionOutwardsFailureMechanismProperties : GrassCoverErosionOutwardsFailureMechanismPropertiesBase + { + public TestGrassCoverErosionOutwardsFailureMechanismProperties(GrassCoverErosionOutwardsFailureMechanism data, + ConstructionProperties constructionProperties) + : base(data, constructionProperties) {} + } + } +} \ No newline at end of file Fisheye: Tag 0a988b3667d32fbae19e420aa71038bcc97d3b38 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0a988b3667d32fbae19e420aa71038bcc97d3b38 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0a988b3667d32fbae19e420aa71038bcc97d3b38 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -0,0 +1,113 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Gui.PropertyBag; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.HydraulicLoadsState; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.Test.PropertyClasses.HydraulicLoadsState +{ + [TestFixture] + public class GrassCoverErosionOutwardsFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int waveRunUpPropertyIndex = 2; + private const int waveImpactPropertyIndex = 3; + private const int waveImpactWithWaveDirectionPropertyIndex = 4; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(failureMechanism, properties.Data); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + + GeneralGrassCoverErosionOutwardsInput generalInput = failureMechanism.GeneralInput; + Assert.AreSame(generalInput.GeneralWaveRunUpWaveConditionsInput, properties.WaveRunUp.Data); + Assert.AreSame(generalInput.GeneralWaveImpactWaveConditionsInput, properties.WaveImpact.Data); + Assert.AreSame(generalInput.GeneralWaveImpactWithWaveDirectionWaveConditionsInput, properties.WaveImpactWithWaveDirection.Data); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() + { + // Call + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(new GrassCoverErosionOutwardsFailureMechanism()); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(5, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + const string modelSettingsCategory = "Modelinstellingen"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + + PropertyDescriptor waveRunUpProperty = dynamicProperties[waveRunUpPropertyIndex]; + Assert.IsInstanceOf(waveRunUpProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveRunUpProperty, + modelSettingsCategory, + "Golfoploop", + "De modelinstellingen voor het berekenen van golfcondities voor golfoploop.", + true); + + PropertyDescriptor waveImpactProperty = dynamicProperties[waveImpactPropertyIndex]; + Assert.IsInstanceOf(waveImpactProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveImpactProperty, + modelSettingsCategory, + "Golfklap", + "De modelinstellingen voor het berekenen van golfcondities voor golfklap zonder invloed van de golfinvalshoek.", + true); + + PropertyDescriptor waveImpactWithWaveDirectionProperty = dynamicProperties[waveImpactWithWaveDirectionPropertyIndex]; + Assert.IsInstanceOf(waveImpactWithWaveDirectionProperty.Converter); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveImpactWithWaveDirectionProperty, + modelSettingsCategory, + "Golfklap met golfrichting", + "De modelinstellingen voor het berekenen van golfcondities voor golfklap met invloed van de golfinvalshoek.", + true); + } + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/RegistrationState/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/RegistrationState/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/RegistrationState/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -0,0 +1,266 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using System.ComponentModel; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.TestUtil; +using Core.Gui.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.TestUtil; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.RegistrationState; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.Test.PropertyClasses.RegistrationState +{ + [TestFixture] + public class GrassCoverErosionOutwardsFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int inAssemblyPropertyIndex = 2; + private const int nPropertyIndex = 3; + private const int applyLengthEffectInSectionPropertyIndex = 4; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var random = new Random(21); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + InAssembly = random.NextBoolean(), + GeneralInput = + { + ApplyLengthEffectInSection = random.NextBoolean() + } + }; + + // Call + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism); + + // Assert + Assert.IsInstanceOf(properties); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + Assert.AreEqual(failureMechanism.InAssembly, properties.InAssembly); + + GeneralGrassCoverErosionOutwardsInput generalInput = failureMechanism.GeneralInput; + Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); + Assert.AreEqual(generalInput.N, + properties.N, + properties.N.GetAccuracy()); + Assert.AreEqual(generalInput.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); + } + + [Test] + public void Constructor_InAssemblyTrue_PropertiesHaveExpectedAttributesValues() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(5, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + const string lengthEffectCategory = "Lengte-effect"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + + PropertyDescriptor inAssemblyProperty = dynamicProperties[inAssemblyPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(inAssemblyProperty, + generalCategory, + "In assemblage", + "Geeft aan of dit faalmechanisme wordt meegenomen in de assemblage.", + true); + + PropertyDescriptor nProperty = dynamicProperties[nPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty, + lengthEffectCategory, + "N [-]", + "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling."); + + PropertyDescriptor applySectionLengthInSectionProperty = dynamicProperties[applyLengthEffectInSectionPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(applySectionLengthInSectionProperty, + lengthEffectCategory, + "Toepassen lengte-effect binnen vak", + "Geeft aan of het lengte-effect binnen een vak toegepast wordt."); + } + + [Test] + public void Constructor_InAssemblyFalse_PropertiesHaveExpectedAttributesValues() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + InAssembly = false + }; + + // Call + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(3, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het faalmechanisme.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + + PropertyDescriptor inAssemblyProperty = dynamicProperties[inAssemblyPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(inAssemblyProperty, + generalCategory, + "In assemblage", + "Geeft aan of dit faalmechanisme wordt meegenomen in de assemblage.", + true); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(-20.0)] + public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN) + { + // Setup + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + failureMechanism.Attach(observer); + + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism); + + // Call + void Call() => properties.N = (RoundedDouble) newN; + + // Assert + const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(20.0)] + public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN) + { + // Setup + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + failureMechanism.Attach(observer); + + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism); + + // Call + properties.N = (RoundedDouble) newN; + + // Assert + Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); + + mocks.VerifyAll(); + } + + [Test] + public void ApplyLengthEffectInSection_SetNewValue_NotifyObservers() + { + // Setup + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + failureMechanism.Attach(observer); + + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism); + + // Call + properties.ApplyLengthEffectInSection = true; + + // Assert + Assert.IsTrue(failureMechanism.GeneralInput.ApplyLengthEffectInSection); + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_DependingOnInAssembly_ReturnExpectedVisibility(bool inAssembly) + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + InAssembly = inAssembly + }; + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism); + + // Call & Assert + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.InAssembly))); + + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.N))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.ApplyLengthEffectInSection))); + + Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + } + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs =================================================================== diff -u -rbe73db4b4573dd45d63d960bd5826b3ac33fbdf3 -r0a988b3667d32fbae19e420aa71038bcc97d3b38 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision be73db4b4573dd45d63d960bd5826b3ac33fbdf3) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -38,6 +38,8 @@ using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; using Riskeer.GrassCoverErosionOutwards.Forms.Views; using Riskeer.Revetment.Forms.Views; +using HydraulicLoadsStateFailureMechanismProperties = Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.HydraulicLoadsState.GrassCoverErosionOutwardsFailureMechanismProperties; +using RegistrationStateFailureMechanismProperties = Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.RegistrationState.GrassCoverErosionOutwardsFailureMechanismProperties; namespace Riskeer.GrassCoverErosionOutwards.Plugin.Test { @@ -147,12 +149,12 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(GrassCoverErosionOutwardsHydraulicLoadsContext), - typeof(GrassCoverErosionOutwardsHydraulicLoadsProperties)); + typeof(HydraulicLoadsStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(GrassCoverErosionOutwardsFailurePathContext), - typeof(GrassCoverErosionOutwardsFailurePathProperties)); + typeof(RegistrationStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, Fisheye: Tag 0a988b3667d32fbae19e420aa71038bcc97d3b38 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsFailurePathContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 0a988b3667d32fbae19e420aa71038bcc97d3b38 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsHydraulicLoadsContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismPropertyInfoTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/HydraulicLoadsState/GrassCoverErosionOutwardsFailureMechanismPropertyInfoTest.cs (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -0,0 +1,83 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Gui.Plugin; +using Core.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.HydraulicLoadsState; + +namespace Riskeer.GrassCoverErosionOutwards.Plugin.Test.PropertyInfos.HydraulicLoadsState +{ + [TestFixture] + public class GrassCoverErosionOutwardsFailureMechanismPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(GrassCoverErosionOutwardsHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsFailureMechanismProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new GrassCoverErosionOutwardsHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(failureMechanism, objectProperties.Data); + } + + mocks.VerifyAll(); + } + + private static PropertyInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(GrassCoverErosionOutwardsHydraulicLoadsContext)); + } + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/RegistrationState/GrassCoverErosionOutwardsFailureMechanismPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/RegistrationState/GrassCoverErosionOutwardsFailureMechanismPropertyInfoTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/RegistrationState/GrassCoverErosionOutwardsFailureMechanismPropertyInfoTest.cs (revision 0a988b3667d32fbae19e420aa71038bcc97d3b38) @@ -0,0 +1,83 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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.Linq; +using Core.Gui.Plugin; +using Core.Gui.PropertyBag; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.PresentationObjects; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses.RegistrationState; + +namespace Riskeer.GrassCoverErosionOutwards.Plugin.Test.PropertyInfos.RegistrationState +{ + [TestFixture] + public class GrassCoverErosionOutwardsFailureMechanismPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(GrassCoverErosionOutwardsFailurePathContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsFailureMechanismProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var context = new GrassCoverErosionOutwardsFailurePathContext(failureMechanism, assessmentSection); + + using (var plugin = new GrassCoverErosionOutwardsPlugin()) + { + PropertyInfo info = GetInfo(plugin); + + // Call + IObjectProperties objectProperties = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(objectProperties); + Assert.AreSame(failureMechanism, objectProperties.Data); + } + + mocks.VerifyAll(); + } + + private static PropertyInfo GetInfo(GrassCoverErosionOutwardsPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(GrassCoverErosionOutwardsFailurePathContext)); + } + } +} \ No newline at end of file