Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesBaseProperties.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesBaseProperties.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesBaseProperties.cs (revision 2d8411b48599eb45028ec924641b50ee6edd71c2)
@@ -0,0 +1,130 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using Core.Common.Gui.Attributes;
+using Core.Common.Gui.Converters;
+using Core.Common.Gui.PropertyBag;
+using Core.Common.Util.Attributes;
+using Ringtoets.Common.Data.AssemblyTool;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Contribution;
+using Ringtoets.Common.Data.Exceptions;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Forms.Properties;
+
+namespace Ringtoets.Common.Forms.PropertyClasses
+{
+ ///
+ /// Base ViewModel of the assembly categories in a for properties panel.
+ ///
+ public abstract class FailureMechanismAssemblyCategoriesBaseProperties : ObjectProperties
+ {
+ private const int failureMechanismAssemblyCategoryPropertyIndex = 1;
+ private const int failureMechanismSectionAssemblyCategoryPropertyIndex = 2;
+
+ protected readonly IAssessmentSection AssessmentSection;
+ protected readonly Func GetNFunc;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The failure mechanism to show the properties for.
+ /// The assessment section to show the properties for.
+ /// The function to get the 'N' parameter used to factor in the 'length effect'.
+ /// Thrown when any parameter is null.
+ protected FailureMechanismAssemblyCategoriesBaseProperties(IFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection,
+ Func getNFunc)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ if (getNFunc == null)
+ {
+ throw new ArgumentNullException(nameof(getNFunc));
+ }
+
+ AssessmentSection = assessmentSection;
+ GetNFunc = getNFunc;
+ Data = failureMechanism;
+ }
+
+ [PropertyOrder(failureMechanismAssemblyCategoryPropertyIndex)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.FailureMechanismAssemblyCategoriesProperties_FailureMechanismAssemblyCategories_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.FailureMechanismAssemblyCategoriesProperties_FailureMechanismAssemblyCategories_Description))]
+ [TypeConverter(typeof(ExpandableArrayConverter))]
+ public FailureMechanismAssemblyCategoryProperties[] FailureMechanismAssemblyCategories
+ {
+ get
+ {
+ return CreateFailureMechanismAssemblyCategories().ToArray();
+ }
+ }
+
+ [PropertyOrder(failureMechanismSectionAssemblyCategoryPropertyIndex)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.FailureMechanismAssemblyCategoriesProperties_FailureMechanismSectionAssemblyCategories_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.FailureMechanismAssemblyCategoriesProperties_FailureMechanismSectionAssemblyCategories_Description))]
+ [TypeConverter(typeof(ExpandableArrayConverter))]
+ public FailureMechanismSectionAssemblyCategoryProperties[] FailureMechanismSectionAssemblyCategories
+ {
+ get
+ {
+ return CreateFailureMechanismSectionAssemblyCategories().ToArray();
+ }
+ }
+
+ ///
+ /// Creates the collection of for the
+ /// in .
+ ///
+ /// A collection of .
+ protected abstract IEnumerable CreateFailureMechanismSectionAssemblyCategories();
+
+ ///
+ /// Creates the collection of for the
+ /// in .
+ ///
+ /// A collection of .
+ /// Thrown when an error occurred while creating the categories.
+ private IEnumerable CreateFailureMechanismAssemblyCategories()
+ {
+ FailureMechanismContribution failureMechanismContribution = AssessmentSection.FailureMechanismContribution;
+ return AssemblyToolCategoriesFactory.CreateFailureMechanismAssemblyCategories(failureMechanismContribution.SignalingNorm,
+ failureMechanismContribution.LowerLimitNorm,
+ data.Contribution,
+ GetNFunc())
+ .Select(category => new FailureMechanismAssemblyCategoryProperties(category));
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 2d8411b48599eb45028ec924641b50ee6edd71c2 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismCategoryBoundariesBaseProperties.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesBasePropertiesTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesBasePropertiesTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesBasePropertiesTest.cs (revision 2d8411b48599eb45028ec924641b50ee6edd71c2)
@@ -0,0 +1,202 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using Core.Common.Gui.Converters;
+using Core.Common.Gui.PropertyBag;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators;
+using Ringtoets.Common.Data.AssemblyTool;
+using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Contribution;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.PropertyClasses;
+using Ringtoets.Common.Forms.TestUtil;
+
+namespace Ringtoets.Common.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class FailureMechanismAssemblyCategoriesBasePropertiesTest
+ {
+ [Test]
+ public void Constructor_FailureMechanismNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new TestFailureMechanismAssemblyCategoriesProperties(null,
+ assessmentSection,
+ () => 0.01);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanism = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new TestFailureMechanismAssemblyCategoriesProperties(failureMechanism,
+ null,
+ () => 0.01);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_GetNFuncNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanism = mocks.Stub();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate call = () => new TestFailureMechanismAssemblyCategoriesProperties(failureMechanism,
+ assessmentSection,
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("getNFunc", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_ValidParameters_ExpectedValues()
+ {
+ // Setup
+ const double n = 1.0;
+
+ var mocks = new MockRepository();
+ var failureMechanism = mocks.Stub();
+ failureMechanism.Contribution = 5;
+ var assessmentSection = new AssessmentSectionStub();
+ mocks.ReplayAll();
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ {
+ // Call
+ var properties = new TestFailureMechanismAssemblyCategoriesProperties(failureMechanism,
+ assessmentSection,
+ () => n);
+
+ // Assert
+ Assert.IsInstanceOf>(properties);
+ Assert.AreSame(failureMechanism, properties.Data);
+
+ TestHelper.AssertTypeConverter(
+ nameof(TestFailureMechanismAssemblyCategoriesProperties.FailureMechanismAssemblyCategories));
+ TestHelper.AssertTypeConverter(
+ nameof(TestFailureMechanismAssemblyCategoriesProperties.FailureMechanismSectionAssemblyCategories));
+
+ FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution;
+ IEnumerable expectedFailureMechanismCategories =
+ AssemblyToolCategoriesFactory.CreateFailureMechanismAssemblyCategories(
+ failureMechanismContribution.SignalingNorm,
+ failureMechanismContribution.LowerLimitNorm,
+ failureMechanism.Contribution,
+ n);
+
+ AssemblyCategoryPropertiesTestHelper.AssertFailureMechanismAssemblyCategoryProperties(
+ expectedFailureMechanismCategories,
+ new[]
+ {
+ new FailureMechanismSectionAssemblyCategory(0.0, 1.0, FailureMechanismSectionAssemblyCategoryGroup.IIIv)
+ },
+ properties);
+
+ mocks.VerifyAll();
+ }
+ }
+
+ [Test]
+ public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var failureMechanism = mocks.Stub();
+ var assessmentSection = new AssessmentSectionStub();
+ mocks.ReplayAll();
+
+ // Call
+ var properties = new TestFailureMechanismAssemblyCategoriesProperties(failureMechanism,
+ assessmentSection,
+ () => 0.01);
+ // Assert
+ PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
+ Assert.AreEqual(2, dynamicProperties.Count);
+
+ const string generalCategoryName = "Algemeen";
+
+ PropertyDescriptor failureMechanismCategoriesProperty = dynamicProperties[0];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(failureMechanismCategoriesProperty,
+ generalCategoryName,
+ "Categoriegrenzen per traject",
+ "De categoriegrenzen per traject voor dit toetsspoor.",
+ true);
+
+ PropertyDescriptor failureMechanismSectionCategoriesProperty = dynamicProperties[1];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(failureMechanismSectionCategoriesProperty,
+ generalCategoryName,
+ "Categoriegrenzen per vak",
+ "De categoriegrenzen per vak voor dit toetsspoor.",
+ true);
+
+ mocks.VerifyAll();
+ }
+
+ private class TestFailureMechanismAssemblyCategoriesProperties : FailureMechanismAssemblyCategoriesBaseProperties
+ {
+ public TestFailureMechanismAssemblyCategoriesProperties(IFailureMechanism failureMechanism, IAssessmentSection assessmentSection, Func getNFunc)
+ : base(failureMechanism, assessmentSection, getNFunc) {}
+
+ protected override IEnumerable CreateFailureMechanismSectionAssemblyCategories()
+ {
+ return new[]
+ {
+ new FailureMechanismSectionAssemblyCategoryProperties(
+ new FailureMechanismSectionAssemblyCategory(0.0, 1.0, FailureMechanismSectionAssemblyCategoryGroup.IIIv))
+ };
+ }
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 2d8411b48599eb45028ec924641b50ee6edd71c2 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismCategoryBoundariesBasePropertiesTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?