Index: Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/AssessmentSectionAssemblyGroupProperties.cs
===================================================================
diff -u
--- Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/AssessmentSectionAssemblyGroupProperties.cs (revision 0)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/AssessmentSectionAssemblyGroupProperties.cs (revision 839c963cd7ecbc5d3931041e7d9840d5fdcf7d06)
@@ -0,0 +1,103 @@
+// 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;
+using Core.Common.Util.Attributes;
+using Core.Gui.Attributes;
+using Core.Gui.PropertyBag;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.Common.Forms.TypeConverters;
+using Riskeer.Integration.Forms.Properties;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.Integration.Forms.PropertyClasses
+{
+ ///
+ /// ViewModel of a for properties panel.
+ ///
+ [TypeConverter(typeof(ExpandableObjectConverter))]
+ public class AssessmentSectionAssemblyGroupProperties : ObjectProperties
+ {
+ private const int groupPropertyIndex = 1;
+ private const int lowerBoundaryPropertyIndex = 2;
+ private const int upperBoundaryPropertyIndex = 3;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// Thrown when is null.
+ public AssessmentSectionAssemblyGroupProperties(AssessmentSectionAssemblyGroupBoundaries assemblyGroupBoundaries)
+ {
+ if (assemblyGroupBoundaries == null)
+ {
+ throw new ArgumentNullException(nameof(assemblyGroupBoundaries));
+ }
+
+ Data = assemblyGroupBoundaries;
+ }
+
+ [PropertyOrder(groupPropertyIndex)]
+ [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssemblyGroup_Name_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.AssemblyGroup_Name_Description))]
+ [TypeConverter(typeof(EnumTypeConverter))]
+ public AssessmentSectionAssemblyGroup Group
+ {
+ get
+ {
+ return data.Group;
+ }
+ }
+
+ [PropertyOrder(lowerBoundaryPropertyIndex)]
+ [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssemblyGroup_LowerBoundary_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.AssemblyGroup_LowerBoundary_Description))]
+ [TypeConverter(typeof(NoProbabilityValueDoubleConverter))]
+ public double LowerBoundary
+ {
+ get
+ {
+ return data.LowerBoundary;
+ }
+ }
+
+ [PropertyOrder(upperBoundaryPropertyIndex)]
+ [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.AssemblyGroup_UpperBoundary_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.AssemblyGroup_UpperBoundary_Description))]
+ [TypeConverter(typeof(NoProbabilityValueDoubleConverter))]
+ public double UpperBoundary
+ {
+ get
+ {
+ return data.UpperBoundary;
+ }
+ }
+
+ public override string ToString()
+ {
+ return new EnumDisplayWrapper(Group).DisplayName;
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/AssessmentSectionAssemblyGroupsProperties.cs
===================================================================
diff -u
--- Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/AssessmentSectionAssemblyGroupsProperties.cs (revision 0)
+++ Riskeer/Integration/src/Riskeer.Integration.Forms/PropertyClasses/AssessmentSectionAssemblyGroupsProperties.cs (revision 839c963cd7ecbc5d3931041e7d9840d5fdcf7d06)
@@ -0,0 +1,93 @@
+// 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 System.Linq;
+using Core.Common.Util.Attributes;
+using Core.Gui.Attributes;
+using Core.Gui.Converters;
+using Core.Gui.PropertyBag;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.Common.Data.AssemblyTool;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Common.Data.Contribution;
+using Riskeer.Common.Data.Exceptions;
+using Riskeer.Integration.Data;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.Integration.Forms.PropertyClasses
+{
+ ///
+ /// ViewModel of a collection of for properties panel.
+ ///
+ public class AssessmentSectionAssemblyGroupsProperties : ObjectProperties
+ {
+ private const int assessmentSectionAssemblyGroupPropertyIndex = 1;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The .
+ /// Thrown when is null.
+ public AssessmentSectionAssemblyGroupsProperties(IAssessmentSection assessmentSection)
+ {
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ Data = assessmentSection;
+ }
+
+ [PropertyOrder(assessmentSectionAssemblyGroupPropertyIndex)]
+ [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.AssemblyGroups_DisplayName))]
+ [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.AssemblyGroups_Description))]
+ [TypeConverter(typeof(ExpandableArrayConverter))]
+ public AssessmentSectionAssemblyGroupProperties[] AssessmentSectionAssemblyGroups
+ {
+ get
+ {
+ return GetAssessmentSectionAssemblyGroups();
+ }
+ }
+
+ private AssessmentSectionAssemblyGroupProperties[] GetAssessmentSectionAssemblyGroups()
+ {
+ FailureMechanismContribution contribution = data.FailureMechanismContribution;
+ AssessmentSectionAssemblyGroupProperties[] dataToSet;
+
+ try
+ {
+ dataToSet = AssessmentSectionAssemblyGroupBoundariesFactory.CreateAssessmentSectionAssemblyGroupBoundaries(contribution.SignalingNorm, contribution.LowerLimitNorm)
+ .Select(category => new AssessmentSectionAssemblyGroupProperties(category))
+ .ToArray();
+ }
+ catch (AssemblyException)
+ {
+ dataToSet = Array.Empty();
+ }
+
+ return dataToSet;
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs
===================================================================
diff -u -r331694af36c7d4ff5751e1b0d78bcd026e2a2ac9 -r839c963cd7ecbc5d3931041e7d9840d5fdcf7d06
--- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 331694af36c7d4ff5751e1b0d78bcd026e2a2ac9)
+++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 839c963cd7ecbc5d3931041e7d9840d5fdcf7d06)
@@ -318,11 +318,14 @@
{
CreateInstance = context => new StructuresOutputProperties(context.WrappedData.Output)
};
-
yield return new PropertyInfo
{
CreateInstance = context => new FailureMechanismSectionAssemblyGroupsProperties(context.WrappedData)
};
+ yield return new PropertyInfo
+ {
+ CreateInstance = context => new AssessmentSectionAssemblyGroupsProperties(context.WrappedData)
+ };
}
public override IEnumerable GetViewInfos()
Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/AssessmentSectionAssemblyGroupPropertiesTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/AssessmentSectionAssemblyGroupPropertiesTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/AssessmentSectionAssemblyGroupPropertiesTest.cs (revision 839c963cd7ecbc5d3931041e7d9840d5fdcf7d06)
@@ -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 System.ComponentModel;
+using Core.Common.TestUtil;
+using Core.Common.Util;
+using Core.Gui.PropertyBag;
+using Core.Gui.TestUtil;
+using NUnit.Framework;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.Integration.Forms.PropertyClasses;
+
+namespace Riskeer.Integration.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class AssessmentSectionAssemblyGroupPropertiesTest
+ {
+ [Test]
+ public void Constructor_AssemblyGroupBoundariesNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => new AssessmentSectionAssemblyGroupProperties(null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assemblyGroupBoundaries", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_ValidParameters_ExpectedValues()
+ {
+ // Setup
+ var random = new Random(39);
+ var assemblyCategory = new AssessmentSectionAssemblyGroupBoundaries(random.NextDouble(),
+ random.NextDouble(),
+ random.NextEnumValue());
+
+ // Call
+ var properties = new AssessmentSectionAssemblyGroupProperties(assemblyCategory);
+
+ // Assert
+ Assert.IsInstanceOf>(properties);
+ Assert.AreSame(assemblyCategory, properties.Data);
+ TestHelper.AssertTypeConverter();
+
+ Assert.AreEqual(assemblyCategory.Group, properties.Group);
+ Assert.AreEqual(assemblyCategory.LowerBoundary, properties.LowerBoundary);
+ Assert.AreEqual(assemblyCategory.UpperBoundary, properties.UpperBoundary);
+ }
+
+ [Test]
+ public void Constructor_Always_PropertiesHaveExpectedAttributeValues()
+ {
+ // Setup
+ var random = new Random(39);
+ var assemblyCategory = new AssessmentSectionAssemblyGroupBoundaries(random.NextDouble(),
+ random.NextDouble(),
+ random.NextEnumValue());
+
+ // Call
+ var properties = new AssessmentSectionAssemblyGroupProperties(assemblyCategory);
+ // Assert
+ PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
+ Assert.AreEqual(3, dynamicProperties.Count);
+
+ const string generalCategoryName = "Algemeen";
+
+ PropertyDescriptor nameProperty = dynamicProperties[0];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
+ generalCategoryName,
+ "Naam",
+ "Naam van de duidingsklasse.",
+ true);
+
+ PropertyDescriptor lowerBoundaryProperty = dynamicProperties[1];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lowerBoundaryProperty,
+ generalCategoryName,
+ "Ondergrens [1/jaar]",
+ "Ondergrens van de duidingsklasse.",
+ true);
+
+ PropertyDescriptor upperBoundaryProperty = dynamicProperties[2];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(upperBoundaryProperty,
+ generalCategoryName,
+ "Bovengrens [1/jaar]",
+ "Bovengrens van de duidingsklasse.",
+ true);
+ }
+
+ [Test]
+ public void ToString_Always_ReturnsAssemblyGroupDisplayName()
+ {
+ // Setup
+ var random = new Random(39);
+ var categoryGroup = random.NextEnumValue();
+ var properties = new AssessmentSectionAssemblyGroupProperties(new AssessmentSectionAssemblyGroupBoundaries(
+ random.NextDouble(),
+ random.NextDouble(),
+ categoryGroup));
+
+ // Call
+ var result = properties.ToString();
+
+ // Assert
+ Assert.AreEqual(new EnumDisplayWrapper(categoryGroup).DisplayName, result);
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/AssessmentSectionAssemblyGroupsPropertiesTest.cs
===================================================================
diff -u
--- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/AssessmentSectionAssemblyGroupsPropertiesTest.cs (revision 0)
+++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/PropertyClasses/AssessmentSectionAssemblyGroupsPropertiesTest.cs (revision 839c963cd7ecbc5d3931041e7d9840d5fdcf7d06)
@@ -0,0 +1,136 @@
+// 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 System.ComponentModel;
+using System.Linq;
+using Core.Common.TestUtil;
+using Core.Gui.Converters;
+using Core.Gui.TestUtil;
+using NUnit.Framework;
+using Riskeer.AssemblyTool.Data;
+using Riskeer.AssemblyTool.KernelWrapper.Calculators;
+using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators;
+using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Categories;
+using Riskeer.Common.Data.AssessmentSection;
+using Riskeer.Integration.Data;
+using Riskeer.Integration.Forms.PropertyClasses;
+
+namespace Riskeer.Integration.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class AssessmentSectionAssemblyGroupsPropertiesTest
+ {
+ [Test]
+ public void Constructor_assessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => new AssessmentSectionAssemblyGroupsProperties(null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_ValidParameters_ExpectedValues()
+ {
+ // Setup
+ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
+
+ // Call
+ var properties = new AssessmentSectionAssemblyGroupsProperties(assessmentSection);
+
+ // Assert
+ Assert.IsInstanceOf(properties);
+ Assert.AreSame(assessmentSection, properties.Data);
+ TestHelper.AssertTypeConverter(
+ nameof(AssessmentSectionAssemblyGroupsProperties.AssessmentSectionAssemblyGroups));
+ }
+
+ [Test]
+ public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
+ {
+ // Call
+ var properties = new AssessmentSectionAssemblyGroupsProperties(new AssessmentSection(AssessmentSectionComposition.Dike));
+
+ // Assert
+ PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
+ Assert.AreEqual(1, dynamicProperties.Count);
+
+ const string generalCategoryName = "Algemeen";
+
+ PropertyDescriptor failureMechanismSectionCategoriesProperty = dynamicProperties[0];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(failureMechanismSectionCategoriesProperty,
+ generalCategoryName,
+ "Duidingsklassen",
+ "De duidingsklassen per vak voor dit toetsspoor.",
+ true);
+ }
+
+ [Test]
+ public void GetFailureMechanismAssemblyGroups_AssemblyThrowsException_SetsEmptyProperties()
+ {
+ // Setup
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ AssessmentSectionAssemblyGroupBoundariesCalculatorStub calculator = calculatorFactory.LastCreatedAssessmentSectionAssemblyGroupBoundariesCalculator;
+ calculator.ThrowExceptionOnCalculate = true;
+
+ // Call
+ var properties = new AssessmentSectionAssemblyGroupsProperties(new AssessmentSection(AssessmentSectionComposition.Dike));
+
+ // Assert
+ Assert.IsEmpty(properties.AssessmentSectionAssemblyGroups);
+ }
+ }
+
+ [Test]
+ public void GetFailureMechanismAssemblyGroups_AssemblySucceeds_CorrectlySetsProperties()
+ {
+ // Setup
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ AssessmentSectionAssemblyGroupBoundariesCalculatorStub calculator = calculatorFactory.LastCreatedAssessmentSectionAssemblyGroupBoundariesCalculator;
+
+ // Call
+ var properties = new AssessmentSectionAssemblyGroupsProperties(new AssessmentSection(AssessmentSectionComposition.Dike));
+
+ // Assert
+ AssessmentSectionAssemblyGroupProperties[] failureMechanismAssemblyGroups = properties.AssessmentSectionAssemblyGroups;
+ IEnumerable output = calculator.AssessmentSectionAssemblyGroupBoundariesOutput;
+ Assert.AreEqual(output.Count(), failureMechanismAssemblyGroups.Length);
+ for (var i = 0; i < output.Count(); i++)
+ {
+ AssessmentSectionAssemblyGroupBoundaries category = output.ElementAt(i);
+
+ AssessmentSectionAssemblyGroupProperties property = failureMechanismAssemblyGroups[i];
+ Assert.AreEqual(category.Group, property.Group);
+ Assert.AreEqual(category.UpperBoundary, property.UpperBoundary);
+ Assert.AreEqual(category.LowerBoundary, property.LowerBoundary);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs
===================================================================
diff -u -r0b522a31f55a06325a2f4ec7bf4055b12d5a93fe -r839c963cd7ecbc5d3931041e7d9840d5fdcf7d06
--- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision 0b522a31f55a06325a2f4ec7bf4055b12d5a93fe)
+++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/RiskeerPluginTest.cs (.../RiskeerPluginTest.cs) (revision 839c963cd7ecbc5d3931041e7d9840d5fdcf7d06)
@@ -216,7 +216,7 @@
PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray();
// Assert
- Assert.AreEqual(24, propertyInfos.Length);
+ Assert.AreEqual(25, propertyInfos.Length);
PluginTestHelper.AssertPropertyInfoDefined(
propertyInfos,
@@ -337,6 +337,11 @@
propertyInfos,
typeof(FailureMechanismSectionAssemblyGroupsContext),
typeof(FailureMechanismSectionAssemblyGroupsProperties));
+
+ PluginTestHelper.AssertPropertyInfoDefined(
+ propertyInfos,
+ typeof(AssessmentSectionAssemblyGroupsContext),
+ typeof(AssessmentSectionAssemblyGroupsProperties));
}
}