Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismSectionAssemblyCategoriesProperties.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismSectionAssemblyCategoriesProperties.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismSectionAssemblyCategoriesProperties.cs (revision 77c36f122eb8e81b6fc54d1f8d34b3246bf03be8)
@@ -0,0 +1,71 @@
+// 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.AssemblyTool.Data;
+using Ringtoets.Integration.Forms.Properties;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Integration.Forms.PropertyClasses
+{
+ ///
+ /// ViewModel of a collection of for properties panel.
+ ///
+ public class FailureMechanismSectionAssemblyCategoriesProperties : ObjectProperties>
+ {
+ private const int failureMechanismSectionAssemblyCategoryPropertyIndex = 1;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The collection of .
+ /// Thrown when any parameter is null.
+ public FailureMechanismSectionAssemblyCategoriesProperties(IEnumerable failureMechanismSectionAssemblyCategories)
+ {
+ if (failureMechanismSectionAssemblyCategories == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanismSectionAssemblyCategories));
+ }
+
+ Data = failureMechanismSectionAssemblyCategories;
+ }
+
+ [PropertyOrder(failureMechanismSectionAssemblyCategoryPropertyIndex)]
+ [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.FailureMechanismSectionAssemblyCategories_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.FailureMechanismAssemblyCategoriesProperties_FailureMechanismSectionAssemblyCategories_Description))]
+ [TypeConverter(typeof(ExpandableArrayConverter))]
+ public FailureMechanismSectionAssemblyCategoryProperties[] FailureMechanismSectionAssemblyCategories
+ {
+ get
+ {
+ return data.Select(category => new FailureMechanismSectionAssemblyCategoryProperties(category)).ToArray();
+ }
+ }
+ }
+}
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj
===================================================================
diff -u -r2da5195c838a61f9b98a178d4add2e93d7c7bfb7 -r77c36f122eb8e81b6fc54d1f8d34b3246bf03be8
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 2da5195c838a61f9b98a178d4add2e93d7c7bfb7)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Ringtoets.Integration.Forms.csproj (.../Ringtoets.Integration.Forms.csproj) (revision 77c36f122eb8e81b6fc54d1f8d34b3246bf03be8)
@@ -67,6 +67,7 @@
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesPropertiesTest.cs
===================================================================
diff -u -r2018b9555ce1ea7636921c6303f6477a934015cb -r77c36f122eb8e81b6fc54d1f8d34b3246bf03be8
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesPropertiesTest.cs (.../FailureMechanismAssemblyCategoriesPropertiesTest.cs) (revision 2018b9555ce1ea7636921c6303f6477a934015cb)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesPropertiesTest.cs (.../FailureMechanismAssemblyCategoriesPropertiesTest.cs) (revision 77c36f122eb8e81b6fc54d1f8d34b3246bf03be8)
@@ -36,7 +36,7 @@
public class FailureMechanismAssemblyCategoriesPropertiesTest
{
[Test]
- public void Constructor_GetFailureMechanismAssemblyCategoryFuncNull_ThrowsArgumentNullException()
+ public void Constructor_GetFailureMechanismAssemblyCategoriesNull_ThrowsArgumentNullException()
{
// Call
TestDelegate call = () => new FailureMechanismAssemblyCategoriesProperties(null,
@@ -48,7 +48,7 @@
}
[Test]
- public void Constructor_GetFailureMechanismSectionAssemblyCategoryFuncNull_ThrowsArgumentNullException()
+ public void Constructor_GetFailureMechanismSectionAssemblyCategoriesNull_ThrowsArgumentNullException()
{
// Call
TestDelegate call = () => new FailureMechanismAssemblyCategoriesProperties(GetFailureMechanismAssemblyCategories(),
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismSectionAssemblyCategoriesPropertiesTest.cs
===================================================================
diff -u
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismSectionAssemblyCategoriesPropertiesTest.cs (revision 0)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismSectionAssemblyCategoriesPropertiesTest.cs (revision 77c36f122eb8e81b6fc54d1f8d34b3246bf03be8)
@@ -0,0 +1,100 @@
+// 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 Ringtoets.AssemblyTool.Data;
+using Ringtoets.Integration.Forms.PropertyClasses;
+using Ringtoets.Integration.Forms.TestUtil;
+
+namespace Ringtoets.Integration.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class FailureMechanismSectionAssemblyCategoriesPropertiesTest
+ {
+ [Test]
+ public void Constructor_GetFailureMechanismSectionAssemblyCategoriesNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => new FailureMechanismSectionAssemblyCategoriesProperties(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("failureMechanismSectionAssemblyCategories", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_ValidParameters_ExpectedValues()
+ {
+ // Setup
+ IEnumerable expectedFailureMechanismSectionCategories = GetFailureMechanismSectionAssemblyCategories();
+
+ // Call
+ var properties = new FailureMechanismSectionAssemblyCategoriesProperties(expectedFailureMechanismSectionCategories);
+
+ // Assert
+ Assert.IsInstanceOf>>(properties);
+ Assert.AreSame(expectedFailureMechanismSectionCategories, properties.Data);
+ TestHelper.AssertTypeConverter(
+ nameof(FailureMechanismSectionAssemblyCategoriesProperties.FailureMechanismSectionAssemblyCategories));
+
+ AssemblyCategoryPropertiesTestHelper.AssertFailureMechanismSectionAssemblyCategoryProperties(
+ expectedFailureMechanismSectionCategories,
+ properties);
+ }
+
+ [Test]
+ public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
+ {
+ // Call
+ var properties = new FailureMechanismSectionAssemblyCategoriesProperties(GetFailureMechanismSectionAssemblyCategories());
+ // Assert
+ PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
+ Assert.AreEqual(1, dynamicProperties.Count);
+
+ const string generalCategoryName = "Algemeen";
+
+ PropertyDescriptor failureMechanismSectionCategoriesProperty = dynamicProperties[0];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(failureMechanismSectionCategoriesProperty,
+ generalCategoryName,
+ "Categoriegrenzen per vak",
+ "De categoriegrenzen per vak voor dit toetsspoor.",
+ true);
+ }
+
+ private static IEnumerable GetFailureMechanismSectionAssemblyCategories()
+ {
+ var random = new Random(21);
+
+ return new[]
+ {
+ new FailureMechanismSectionAssemblyCategory(random.NextDouble(),
+ random.NextDouble(),
+ random.NextEnumValue())
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj
===================================================================
diff -u -r2da5195c838a61f9b98a178d4add2e93d7c7bfb7 -r77c36f122eb8e81b6fc54d1f8d34b3246bf03be8
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 2da5195c838a61f9b98a178d4add2e93d7c7bfb7)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 77c36f122eb8e81b6fc54d1f8d34b3246bf03be8)
@@ -63,6 +63,7 @@
+
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.TestUtil/AssemblyCategoryPropertiesTestHelper.cs
===================================================================
diff -u -r2018b9555ce1ea7636921c6303f6477a934015cb -r77c36f122eb8e81b6fc54d1f8d34b3246bf03be8
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.TestUtil/AssemblyCategoryPropertiesTestHelper.cs (.../AssemblyCategoryPropertiesTestHelper.cs) (revision 2018b9555ce1ea7636921c6303f6477a934015cb)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.TestUtil/AssemblyCategoryPropertiesTestHelper.cs (.../AssemblyCategoryPropertiesTestHelper.cs) (revision 77c36f122eb8e81b6fc54d1f8d34b3246bf03be8)
@@ -55,7 +55,21 @@
Assert.AreEqual(category.UpperBoundary, property.UpperBoundary);
Assert.AreEqual(category.LowerBoundary, property.LowerBoundary);
}
+
+ Assert.AreEqual(expectedFailureMechanismSectionCategories.Count(), properties.FailureMechanismSectionAssemblyCategories.Length);
+ for (var i = 0; i < expectedFailureMechanismSectionCategories.Count(); i++)
+ {
+ FailureMechanismSectionAssemblyCategory category = expectedFailureMechanismSectionCategories.ElementAt(i);
+ FailureMechanismSectionAssemblyCategoryProperties property = properties.FailureMechanismSectionAssemblyCategories[i];
+ Assert.AreEqual(category.Group, property.Group);
+ Assert.AreEqual(category.UpperBoundary, property.UpperBoundary);
+ Assert.AreEqual(category.LowerBoundary, property.LowerBoundary);
+ }
+ }
+ public static void AssertFailureMechanismSectionAssemblyCategoryProperties(IEnumerable expectedFailureMechanismSectionCategories,
+ FailureMechanismSectionAssemblyCategoriesProperties properties)
+ {
Assert.AreEqual(expectedFailureMechanismSectionCategories.Count(), properties.FailureMechanismSectionAssemblyCategories.Length);
for (var i = 0; i < expectedFailureMechanismSectionCategories.Count(); i++)
{