Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismProperties.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismProperties.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismProperties.cs (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -0,0 +1,94 @@ +// 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.WaveImpactAsphaltCover.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; +using RiskeerRevetmentFormsResources = Riskeer.Revetment.Forms.Properties.Resources; + +namespace Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.HydraulicLoadsState +{ + /// + /// Hydraulic loads state related ViewModel of for properties panel. + /// + public class WaveImpactAsphaltCoverFailureMechanismProperties : WaveImpactAsphaltCoverFailureMechanismPropertiesBase + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int aPropertyIndex = 3; + private const int bPropertyIndex = 4; + private const int cPropertyIndex = 5; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// Thrown when is null. + public WaveImpactAsphaltCoverFailureMechanismProperties(WaveImpactAsphaltCoverFailureMechanism data) : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }) {} + + #region Model settings + + [PropertyOrder(aPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(RiskeerRevetmentFormsResources), nameof(RiskeerRevetmentFormsResources.GeneralWaveConditionsInput_A_DisplayName))] + [ResourcesDescription(typeof(RiskeerRevetmentFormsResources), nameof(RiskeerRevetmentFormsResources.GeneralWaveConditionsInput_A_Description))] + public RoundedDouble A + { + get + { + return data.GeneralInput.A; + } + } + + [PropertyOrder(bPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(RiskeerRevetmentFormsResources), nameof(RiskeerRevetmentFormsResources.GeneralWaveConditionsInput_B_DisplayName))] + [ResourcesDescription(typeof(RiskeerRevetmentFormsResources), nameof(RiskeerRevetmentFormsResources.GeneralWaveConditionsInput_B_Description))] + public RoundedDouble B + { + get + { + return data.GeneralInput.B; + } + } + + [PropertyOrder(cPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(RiskeerRevetmentFormsResources), nameof(RiskeerRevetmentFormsResources.GeneralWaveConditionsInput_C_DisplayName))] + [ResourcesDescription(typeof(RiskeerRevetmentFormsResources), nameof(RiskeerRevetmentFormsResources.GeneralWaveConditionsInput_C_Description))] + public RoundedDouble C + { + get + { + return data.GeneralInput.C; + } + } + + #endregion + } +} \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/RegistrationState/WaveImpactAsphaltCoverFailureMechanismProperties.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/RegistrationState/WaveImpactAsphaltCoverFailureMechanismProperties.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/RegistrationState/WaveImpactAsphaltCoverFailureMechanismProperties.cs (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -0,0 +1,166 @@ +// 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.Common.Data.AssessmentSection; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.Properties; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; +using RiskeerRevetmentFormsResources = Riskeer.Revetment.Forms.Properties.Resources; + +namespace Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.RegistrationState +{ + /// + /// Registration state related ViewModel of for properties panel. + /// + public class WaveImpactAsphaltCoverFailureMechanismProperties : WaveImpactAsphaltCoverFailureMechanismPropertiesBase + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int inAssemblyPropertyIndex = 3; + private const int sectionLengthPropertyIndex = 4; + private const int deltaLPropertyIndex = 5; + private const int nPropertyIndex = 6; + private const int applyLengthEffectInSectionPropertyIndex = 7; + + private readonly IAssessmentSection assessmentSection; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// The assessment section the failure mechanism belongs to. + /// Thrown when any parameter is null. + public WaveImpactAsphaltCoverFailureMechanismProperties(WaveImpactAsphaltCoverFailureMechanism data, IAssessmentSection assessmentSection) + : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex + }) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + this.assessmentSection = assessmentSection; + } + + #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) + { + return data.InAssembly || !ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(propertyName); + } + + private static bool ShouldHidePropertyWhenFailureMechanismNotPartOfAssembly(string propertyName) + { + return nameof(DeltaL).Equals(propertyName) + || nameof(SectionLength).Equals(propertyName) + || nameof(N).Equals(propertyName) + || nameof(ApplyLengthEffectInSection).Equals(propertyName); + } + + #region Length effect parameters + + [DynamicVisible] + [PropertyOrder(sectionLengthPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.ReferenceLine_Length_Rounded_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.ReferenceLine_Length_Rounded_Description))] + public RoundedDouble SectionLength + { + get + { + return new RoundedDouble(2, assessmentSection.ReferenceLine.Length); + } + } + + [DynamicVisible] + [PropertyOrder(deltaLPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.WaveImpactAsphaltCoverFailureMechanismProperties_DeltaL_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.WaveImpactAsphaltCoverFailureMechanismProperties_DeltaL_Description))] + public RoundedDouble DeltaL + { + get + { + return data.GeneralWaveImpactAsphaltCoverInput.DeltaL; + } + set + { + data.GeneralWaveImpactAsphaltCoverInput.DeltaL = value; + data.NotifyObservers(); + } + } + + [DynamicVisible] + [PropertyOrder(nPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_Description))] + public RoundedDouble N + { + get + { + return new RoundedDouble(2, data.GeneralWaveImpactAsphaltCoverInput.GetN(assessmentSection.ReferenceLine.Length)); + } + } + + [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.GeneralWaveImpactAsphaltCoverInput.ApplyLengthEffectInSection; + } + set + { + data.GeneralWaveImpactAsphaltCoverInput.ApplyLengthEffectInSection = value; + data.NotifyObservers(); + } + } + + #endregion + } +} \ No newline at end of file Fisheye: Tag 5319a71f64c1faa285332c83df061eb511d93c59 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverFailureMechanismProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverFailureMechanismPropertiesBase.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverFailureMechanismPropertiesBase.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverFailureMechanismPropertiesBase.cs (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -0,0 +1,129 @@ +// 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.WaveImpactAsphaltCover.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; +using RiskeerRevetmentFormsResources = Riskeer.Revetment.Forms.Properties.Resources; + +namespace Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses +{ + /// + /// Base ViewModel of for properties panel. + /// + public abstract class WaveImpactAsphaltCoverFailureMechanismPropertiesBase : 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 WaveImpactAsphaltCoverFailureMechanismPropertiesBase(WaveImpactAsphaltCoverFailureMechanism 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 5319a71f64c1faa285332c83df061eb511d93c59 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverFailurePathProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5319a71f64c1faa285332c83df061eb511d93c59 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverHydraulicLoadsProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -r160e88782fbd20958a9ebd55511782b203d141e5 -r5319a71f64c1faa285332c83df061eb511d93c59 --- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 160e88782fbd20958a9ebd55511782b203d141e5) +++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -61,6 +61,8 @@ using Riskeer.WaveImpactAsphaltCover.Service; using RiskeerCommonDataResources = Riskeer.Common.Data.Properties.Resources; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; +using HydraulicLoadsStateFailureMechanismProperties = Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.HydraulicLoadsState.WaveImpactAsphaltCoverFailureMechanismProperties; +using RegistrationStateFailureMechanismProperties = Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.RegistrationState.WaveImpactAsphaltCoverFailureMechanismProperties; namespace Riskeer.WaveImpactAsphaltCover.Plugin { @@ -71,13 +73,13 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new WaveImpactAsphaltCoverHydraulicLoadsProperties(context.WrappedData) + CreateInstance = context => new HydraulicLoadsStateFailureMechanismProperties(context.WrappedData) }; - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new WaveImpactAsphaltCoverFailurePathProperties(context.WrappedData, context.Parent) + CreateInstance = context => new RegistrationStateFailureMechanismProperties(context.WrappedData, context.Parent) }; yield return new PropertyInfo(); yield return new PropertyInfo Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -0,0 +1,111 @@ +// 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.TestUtil; +using NUnit.Framework; +using Riskeer.Revetment.Data; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses; +using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.HydraulicLoadsState; + +namespace Riskeer.WaveImpactAsphaltCover.Forms.Test.PropertyClasses.HydraulicLoadsState +{ + [TestFixture] + public class WaveImpactAsphaltCoverFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int aPropertyIndex = 2; + private const int bPropertyIndex = 3; + private const int cPropertyIndex = 4; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + // Call + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism); + + // Assert + Assert.IsInstanceOf(properties); + Assert.AreSame(failureMechanism, properties.Data); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + + GeneralWaveConditionsInput generalWaveConditionsInput = failureMechanism.GeneralInput; + Assert.AreEqual(generalWaveConditionsInput.A, properties.A); + Assert.AreEqual(generalWaveConditionsInput.B, properties.B); + Assert.AreEqual(generalWaveConditionsInput.C, properties.C); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() + { + // Call + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(new WaveImpactAsphaltCoverFailureMechanism()); + + // 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 aProperty = dynamicProperties[aPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(aProperty, + modelSettingsCategory, + "a", + "De waarde van de parameter 'a' in de berekening voor golfcondities.", + true); + + PropertyDescriptor bProperty = dynamicProperties[bPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(bProperty, + modelSettingsCategory, + "b", + "De waarde van de parameter 'b' in de berekening voor golfcondities.", + true); + + PropertyDescriptor cProperty = dynamicProperties[cPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(cProperty, + modelSettingsCategory, + "c", + "De waarde van de parameter 'c' in de berekening voor golfcondities.", + true); + } + } +} \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/RegistrationState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/RegistrationState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/RegistrationState/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -0,0 +1,339 @@ +// 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.AssessmentSection; +using Riskeer.Common.Data.TestUtil; +using Riskeer.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses; +using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.RegistrationState; + +namespace Riskeer.WaveImpactAsphaltCover.Forms.Test.PropertyClasses.RegistrationState +{ + [TestFixture] + public class WaveImpactAsphaltCoverFailureMechanismPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int inAssemblyPropertyIndex = 2; + private const int sectionLengthPropertyIndex = 3; + private const int deltaLPropertyIndex = 4; + private const int nPropertyIndex = 5; + private const int applyLengthEffectInSectionPropertyIndex = 6; + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => new WaveImpactAsphaltCoverFailureMechanismProperties(new WaveImpactAsphaltCoverFailureMechanism(), null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + assessmentSection.Stub(a => a.ReferenceLine).Return(new ReferenceLine()); + mocks.ReplayAll(); + + var random = new Random(21); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism + { + InAssembly = random.NextBoolean(), + GeneralWaveImpactAsphaltCoverInput = + { + ApplyLengthEffectInSection = random.NextBoolean() + } + }; + + // Call + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf(properties); + Assert.AreSame(failureMechanism, properties.Data); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + Assert.AreEqual(failureMechanism.InAssembly, properties.InAssembly); + + Assert.AreEqual(2, properties.SectionLength.NumberOfDecimalPlaces); + Assert.AreEqual(assessmentSection.ReferenceLine.Length, + properties.SectionLength, + properties.SectionLength.GetAccuracy()); + + GeneralWaveImpactAsphaltCoverInput generalWaveImpactAsphaltCoverInput = failureMechanism.GeneralWaveImpactAsphaltCoverInput; + Assert.AreEqual(2, properties.DeltaL.NumberOfDecimalPlaces); + Assert.AreEqual(generalWaveImpactAsphaltCoverInput.DeltaL, + properties.DeltaL, + properties.DeltaL.GetAccuracy()); + + Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); + Assert.AreEqual(generalWaveImpactAsphaltCoverInput.GetN(assessmentSection.ReferenceLine.Length), + properties.N, + properties.N.GetAccuracy()); + Assert.AreEqual(generalWaveImpactAsphaltCoverInput.ApplyLengthEffectInSection, properties.ApplyLengthEffectInSection); + + mocks.VerifyAll(); + } + + [Test] + public void Constructor_InAssemblyTrue_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(new WaveImpactAsphaltCoverFailureMechanism(), assessmentSection); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(7, 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 codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + 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 sectionLength = dynamicProperties[sectionLengthPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sectionLength, + lengthEffectCategory, + "Lengte* [m]", + "Totale lengte van het traject in meters (afgerond).", + true); + + PropertyDescriptor deltaLProperty = dynamicProperties[deltaLPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(deltaLProperty, + lengthEffectCategory, + "ΔL [m]", + "Lengte van onafhankelijke dijkstrekkingen voor dit faalmechanisme."); + + 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 (afgerond).", + true); + + PropertyDescriptor applySectionLengthInSectionProperty = dynamicProperties[applyLengthEffectInSectionPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(applySectionLengthInSectionProperty, + lengthEffectCategory, + "Toepassen lengte-effect binnen vak", + "Geeft aan of het lengte-effect binnen een vak toegepast wordt."); + + mocks.VerifyAll(); + } + + [Test] + public void Constructor_InAssemblyFalse_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism + { + InAssembly = false + }; + + // Call + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism, assessmentSection); + + // 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 codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + 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); + + mocks.VerifyAll(); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(-20.0)] + public void DeltaL_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.Attach(observer); + + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties( + failureMechanism, + assessmentSection); + + // Call + void Call() => properties.DeltaL = (RoundedDouble) newN; + + // Assert + const string expectedMessage = "De waarde voor 'ΔL' moet groter zijn dan 0."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(20.0)] + public void DeltaL_SetValidValue_UpdateDataAndNotifyObservers(double newN) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + failureMechanism.Attach(observer); + + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties( + failureMechanism, + assessmentSection); + + // Call + properties.DeltaL = (RoundedDouble) newN; + + // Assert + Assert.AreEqual(newN, failureMechanism.GeneralWaveImpactAsphaltCoverInput.DeltaL); + + mocks.VerifyAll(); + } + + [Test] + public void ApplyLengthEffectInSection_SetNewValue_NotifyObservers() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + failureMechanism.Attach(observer); + + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism, assessmentSection); + + // Call + properties.ApplyLengthEffectInSection = true; + + // Assert + Assert.IsTrue(failureMechanism.GeneralWaveImpactAsphaltCoverInput.ApplyLengthEffectInSection); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_DependingOnInAssembly_ReturnExpectedVisibility(bool inAssembly) + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism + { + InAssembly = inAssembly + }; + var properties = new WaveImpactAsphaltCoverFailureMechanismProperties(failureMechanism, assessmentSection); + + // 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.DeltaL))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.SectionLength))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.N))); + Assert.AreEqual(inAssembly, properties.DynamicVisibleValidationMethod(nameof(properties.ApplyLengthEffectInSection))); + + Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverFailureMechanismPropertiesBaseTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverFailureMechanismPropertiesBaseTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverFailureMechanismPropertiesBaseTest.cs (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -0,0 +1,117 @@ +// 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.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses; + +namespace Riskeer.WaveImpactAsphaltCover.Forms.Test.PropertyClasses +{ + [TestFixture] + public class WaveImpactAsphaltCoverFailureMechanismPropertiesBaseTest + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 0; + + [Test] + public void Constructor_DataNull_ThrowsArgumentNullException() + { + // Call + void Call() => new TestWaveImpactAsphaltCoverFailureMechanismProperties( + null, new WaveImpactAsphaltCoverFailureMechanismPropertiesBase.ConstructionProperties()); + + // Assert + string paramName = Assert.Throws(Call).ParamName; + Assert.AreEqual("data", paramName); + } + + [Test] + public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException() + { + // Call + void Call() => new TestWaveImpactAsphaltCoverFailureMechanismProperties( + new WaveImpactAsphaltCoverFailureMechanism(), null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("constructionProperties", exception.ParamName); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + + // Call + var properties = new TestWaveImpactAsphaltCoverFailureMechanismProperties( + failureMechanism, new WaveImpactAsphaltCoverFailureMechanismPropertiesBase.ConstructionProperties()); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(failureMechanism, properties.Data); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributeValues() + { + // Call + var properties = new TestWaveImpactAsphaltCoverFailureMechanismProperties( + new WaveImpactAsphaltCoverFailureMechanism(), new WaveImpactAsphaltCoverFailureMechanismPropertiesBase.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 codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + generalCategory, + "Label", + "Het label van het faalmechanisme.", + true); + } + + private class TestWaveImpactAsphaltCoverFailureMechanismProperties : WaveImpactAsphaltCoverFailureMechanismPropertiesBase + { + public TestWaveImpactAsphaltCoverFailureMechanismProperties(WaveImpactAsphaltCoverFailureMechanism data, ConstructionProperties constructionProperties) + : base(data, constructionProperties) {} + } + } +} \ No newline at end of file Fisheye: Tag 5319a71f64c1faa285332c83df061eb511d93c59 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverFailureMechanismPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5319a71f64c1faa285332c83df061eb511d93c59 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverFailurePathPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5319a71f64c1faa285332c83df061eb511d93c59 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Forms.Test/PropertyClasses/WaveImpactAsphaltCoverHydraulicLoadsPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertyInfoTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/HydraulicLoadsState/WaveImpactAsphaltCoverFailureMechanismPropertyInfoTest.cs (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -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.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.HydraulicLoadsState; + +namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test.PropertyInfos.HydraulicLoadsState +{ + [TestFixture] + public class WaveImpactAsphaltCoverFailureMechanismPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(WaveImpactAsphaltCoverHydraulicLoadsContext), info.DataType); + Assert.AreEqual(typeof(WaveImpactAsphaltCoverFailureMechanismProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverHydraulicLoadsContext(failureMechanism, assessmentSection); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + 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(WaveImpactAsphaltCoverPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(WaveImpactAsphaltCoverHydraulicLoadsContext)); + } + } +} \ No newline at end of file Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/RegistrationState/WaveImpactAsphaltCoverFailureMechanismPropertyInfoTest.cs =================================================================== diff -u --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/RegistrationState/WaveImpactAsphaltCoverFailureMechanismPropertyInfoTest.cs (revision 0) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/RegistrationState/WaveImpactAsphaltCoverFailureMechanismPropertyInfoTest.cs (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -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.WaveImpactAsphaltCover.Data; +using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; +using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.RegistrationState; + +namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test.PropertyInfos.RegistrationState +{ + [TestFixture] + public class WaveImpactAsphaltCoverFailureMechanismPropertyInfoTest + { + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + // Call + PropertyInfo info = GetInfo(plugin); + + // Assert + Assert.AreEqual(typeof(WaveImpactAsphaltCoverFailurePathContext), info.DataType); + Assert.AreEqual(typeof(WaveImpactAsphaltCoverFailureMechanismProperties), info.PropertyObjectType); + } + } + + [Test] + public void CreateInstance_WithContext_SetsFailureMechanismAsData() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var context = new WaveImpactAsphaltCoverFailurePathContext(failureMechanism, assessmentSection); + + using (var plugin = new WaveImpactAsphaltCoverPlugin()) + { + 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(WaveImpactAsphaltCoverPlugin plugin) + { + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(WaveImpactAsphaltCoverFailurePathContext)); + } + } +} \ No newline at end of file Fisheye: Tag 5319a71f64c1faa285332c83df061eb511d93c59 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/WaveImpactAsphaltCoverFailurePathContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 5319a71f64c1faa285332c83df061eb511d93c59 refers to a dead (removed) revision in file `Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/PropertyInfos/WaveImpactAsphaltCoverHydraulicLoadsContextPropertyInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/Riskeer.WaveImpactAsphaltCover.Plugin.Test.csproj =================================================================== diff -u -re3b8937a862993685f17f944a7656a7def8b8c3b -r5319a71f64c1faa285332c83df061eb511d93c59 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/Riskeer.WaveImpactAsphaltCover.Plugin.Test.csproj (.../Riskeer.WaveImpactAsphaltCover.Plugin.Test.csproj) (revision e3b8937a862993685f17f944a7656a7def8b8c3b) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/Riskeer.WaveImpactAsphaltCover.Plugin.Test.csproj (.../Riskeer.WaveImpactAsphaltCover.Plugin.Test.csproj) (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -28,7 +28,7 @@ - + Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs =================================================================== diff -u -r8da89db9c186cedc26c4baa657f2dd8961877ec4 -r5319a71f64c1faa285332c83df061eb511d93c59 --- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs (.../WaveImpactAsphaltCoverPluginTest.cs) (revision 8da89db9c186cedc26c4baa657f2dd8961877ec4) +++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Plugin.Test/WaveImpactAsphaltCoverPluginTest.cs (.../WaveImpactAsphaltCoverPluginTest.cs) (revision 5319a71f64c1faa285332c83df061eb511d93c59) @@ -39,6 +39,8 @@ using Riskeer.WaveImpactAsphaltCover.Forms.PresentationObjects; using Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses; using Riskeer.WaveImpactAsphaltCover.Forms.Views; +using HydraulicLoadsStateFailureMechanismProperties = Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.HydraulicLoadsState.WaveImpactAsphaltCoverFailureMechanismProperties; +using RegistrationStateFailureMechanismProperties = Riskeer.WaveImpactAsphaltCover.Forms.PropertyClasses.RegistrationState.WaveImpactAsphaltCoverFailureMechanismProperties; namespace Riskeer.WaveImpactAsphaltCover.Plugin.Test { @@ -71,12 +73,12 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(WaveImpactAsphaltCoverHydraulicLoadsContext), - typeof(WaveImpactAsphaltCoverHydraulicLoadsProperties)); + typeof(HydraulicLoadsStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(WaveImpactAsphaltCoverFailurePathContext), - typeof(WaveImpactAsphaltCoverFailurePathProperties)); + typeof(RegistrationStateFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos,