Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesProperties.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesProperties.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesProperties.cs (revision 72ac518de9bbb165cdd1595cf6f460d8e0f760e3) @@ -0,0 +1,58 @@ +// 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.Linq; +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; + +namespace Ringtoets.Common.Forms.PropertyClasses +{ + /// + /// ViewModel of the assembly categories in a for properties panel. + /// + public class FailureMechanismAssemblyCategoriesProperties : FailureMechanismAssemblyCategoriesBaseProperties + { + /// + /// + /// Creates a new instance of . + /// + public FailureMechanismAssemblyCategoriesProperties(IFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + Func getNFunc) : base(failureMechanism, assessmentSection, getNFunc) {} + + /// + /// Thrown when an error occurred while creating the categories. + protected override IEnumerable CreateFailureMechanismSectionAssemblyCategories() + { + FailureMechanismContribution failureMechanismContribution = AssessmentSection.FailureMechanismContribution; + return AssemblyToolCategoriesFactory.CreateFailureMechanismSectionAssemblyCategories(failureMechanismContribution.SignalingNorm, + failureMechanismContribution.LowerLimitNorm, + data.Contribution, + GetNFunc()) + .Select(category => new FailureMechanismSectionAssemblyCategoryProperties(category)); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/GeotechnicFailureMechanismAssemblyCategoriesProperties.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/GeotechnicFailureMechanismAssemblyCategoriesProperties.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/GeotechnicFailureMechanismAssemblyCategoriesProperties.cs (revision 72ac518de9bbb165cdd1595cf6f460d8e0f760e3) @@ -0,0 +1,58 @@ +// 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.Linq; +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; + +namespace Ringtoets.Common.Forms.PropertyClasses +{ + /// + /// ViewModel of the category boundaries in a geotechnic for properties panel. + /// + public class GeotechnicFailureMechanismAssemblyCategoriesProperties : FailureMechanismAssemblyCategoriesBaseProperties + { + /// + /// + /// Creates a new instance of . + /// + public GeotechnicFailureMechanismAssemblyCategoriesProperties(IFailureMechanism failureMechanism, + IAssessmentSection assessmentSection, + Func getNFunc) : base(failureMechanism, assessmentSection, getNFunc) {} + + /// + /// Thrown when an error occurred while creating the categories. + protected override IEnumerable CreateFailureMechanismSectionAssemblyCategories() + { + FailureMechanismContribution failureMechanismContribution = AssessmentSection.FailureMechanismContribution; + return AssemblyToolCategoriesFactory.CreateGeotechnicFailureMechanismSectionAssemblyCategories(failureMechanismContribution.SignalingNorm, + failureMechanismContribution.LowerLimitNorm, + data.Contribution, + GetNFunc()) + .Select(category => new FailureMechanismSectionAssemblyCategoryProperties(category)); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -r4d7632a55f75ca47d7cee49166570d91a75d3d8f -r72ac518de9bbb165cdd1595cf6f460d8e0f760e3 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 4d7632a55f75ca47d7cee49166570d91a75d3d8f) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 72ac518de9bbb165cdd1595cf6f460d8e0f760e3) @@ -93,7 +93,9 @@ Resources.resx - + + + Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesPropertiesTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesPropertiesTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesPropertiesTest.cs (revision 72ac518de9bbb165cdd1595cf6f460d8e0f760e3) @@ -0,0 +1,104 @@ +// 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.Collections.Generic; +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.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 FailureMechanismAssemblyCategoriesPropertiesTest + { + [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 FailureMechanismAssemblyCategoriesProperties(failureMechanism, + assessmentSection, + () => n); + + // Assert + Assert.IsInstanceOf(properties); + + FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; + IEnumerable expectedFailureMechanismCategories = + AssemblyToolCategoriesFactory.CreateFailureMechanismAssemblyCategories( + failureMechanismContribution.SignalingNorm, + failureMechanismContribution.LowerLimitNorm, + failureMechanism.Contribution, + n); + + IEnumerable expectedFailureMechanismSectionCategories = + AssemblyToolCategoriesFactory.CreateFailureMechanismSectionAssemblyCategories( + failureMechanismContribution.SignalingNorm, + failureMechanismContribution.LowerLimitNorm, + failureMechanism.Contribution, + n); + + AssemblyCategoryPropertiesTestHelper.AssertFailureMechanismAssemblyCategoryProperties( + expectedFailureMechanismCategories, + expectedFailureMechanismSectionCategories, + properties); + + mocks.VerifyAll(); + } + } + + [Test] + public void Constructor_Always_ReturnsExpectedPropertyCount() + { + // Setup + var mocks = new MockRepository(); + var failureMechanism = mocks.Stub(); + var assessmentSection = new AssessmentSectionStub(); + mocks.ReplayAll(); + + // Call + var properties = new FailureMechanismAssemblyCategoriesProperties(failureMechanism, + assessmentSection, + () => 0.01); + // Assert + Assert.AreEqual(2, PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties).Count); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/GeotechnicFailureMechanismAssemblyCategoriesPropertiesTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/GeotechnicFailureMechanismAssemblyCategoriesPropertiesTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/GeotechnicFailureMechanismAssemblyCategoriesPropertiesTest.cs (revision 72ac518de9bbb165cdd1595cf6f460d8e0f760e3) @@ -0,0 +1,104 @@ +// 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.Collections.Generic; +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.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 GeotechnicFailureMechanismAssemblyCategoriesPropertiesTest + { + [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 GeotechnicFailureMechanismAssemblyCategoriesProperties(failureMechanism, + assessmentSection, + () => n); + + // Assert + Assert.IsInstanceOf(properties); + + FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; + IEnumerable expectedFailureMechanismCategories = + AssemblyToolCategoriesFactory.CreateFailureMechanismAssemblyCategories( + failureMechanismContribution.SignalingNorm, + failureMechanismContribution.LowerLimitNorm, + failureMechanism.Contribution, + n); + + IEnumerable expectedFailureMechanismSectionCategories = + AssemblyToolCategoriesFactory.CreateGeotechnicFailureMechanismSectionAssemblyCategories( + failureMechanismContribution.SignalingNorm, + failureMechanismContribution.LowerLimitNorm, + failureMechanism.Contribution, + n); + + AssemblyCategoryPropertiesTestHelper.AssertFailureMechanismAssemblyCategoryProperties( + expectedFailureMechanismCategories, + expectedFailureMechanismSectionCategories, + properties); + + mocks.VerifyAll(); + } + } + + [Test] + public void Constructor_Always_ReturnsExpectedPropertyCount() + { + // Setup + var mocks = new MockRepository(); + var failureMechanism = mocks.Stub(); + var assessmentSection = new AssessmentSectionStub(); + mocks.ReplayAll(); + + // Call + var properties = new GeotechnicFailureMechanismAssemblyCategoriesProperties(failureMechanism, + assessmentSection, + () => 0.01); + // Assert + Assert.AreEqual(2, PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties).Count); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -r4d7632a55f75ca47d7cee49166570d91a75d3d8f -r72ac518de9bbb165cdd1595cf6f460d8e0f760e3 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 4d7632a55f75ca47d7cee49166570d91a75d3d8f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 72ac518de9bbb165cdd1595cf6f460d8e0f760e3) @@ -95,10 +95,12 @@ + + - + @@ -255,6 +257,10 @@ {22C5DDB8-2491-4BC6-BDC6-2A7B7EBF40C1} Ringtoets.AssemblyTool.Forms + + {0AB432BB-E2CC-42EA-A72C-7AFEF7536B38} + Ringtoets.AssemblyTool.KernelWrapper.TestUtil + {888D4097-8BC2-4703-9FB1-8744C94D525E} Ringtoets.HydraRing.Calculation