Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesBaseProperties.cs =================================================================== diff -u -r2d8411b48599eb45028ec924641b50ee6edd71c2 -re6944724df4a525632b83d596ca0ae4b2ebc0766 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesBaseProperties.cs (.../FailureMechanismAssemblyCategoriesBaseProperties.cs) (revision 2d8411b48599eb45028ec924641b50ee6edd71c2) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesBaseProperties.cs (.../FailureMechanismAssemblyCategoriesBaseProperties.cs) (revision e6944724df4a525632b83d596ca0ae4b2ebc0766) @@ -27,10 +27,7 @@ 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.AssemblyTool.Data; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.Properties; @@ -39,42 +36,42 @@ /// /// Base ViewModel of the assembly categories in a for properties panel. /// - public abstract class FailureMechanismAssemblyCategoriesBaseProperties : ObjectProperties + public class FailureMechanismAssemblyCategoriesBaseProperties : ObjectProperties { private const int failureMechanismAssemblyCategoryPropertyIndex = 1; private const int failureMechanismSectionAssemblyCategoryPropertyIndex = 2; + private readonly Func> getFailureMechanismAssemblyCategoryFunc; + private readonly Func> getFailureMechanismSectionAssemblyCategoryFunc; - 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'. + /// The function to get a collection of . + /// The function to get a collection of . /// Thrown when any parameter is null. - protected FailureMechanismAssemblyCategoriesBaseProperties(IFailureMechanism failureMechanism, - IAssessmentSection assessmentSection, - Func getNFunc) + public FailureMechanismAssemblyCategoriesBaseProperties(IFailureMechanism failureMechanism, + Func> getFailureMechanismAssemblyCategoryFunc, + Func> getFailureMechanismSectionAssemblyCategoryFunc) { if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism)); } - if (assessmentSection == null) + if (getFailureMechanismAssemblyCategoryFunc == null) { - throw new ArgumentNullException(nameof(assessmentSection)); + throw new ArgumentNullException(nameof(getFailureMechanismAssemblyCategoryFunc)); } - if (getNFunc == null) + if (getFailureMechanismSectionAssemblyCategoryFunc == null) { - throw new ArgumentNullException(nameof(getNFunc)); + throw new ArgumentNullException(nameof(getFailureMechanismSectionAssemblyCategoryFunc)); } - AssessmentSection = assessmentSection; - GetNFunc = getNFunc; + this.getFailureMechanismAssemblyCategoryFunc = getFailureMechanismAssemblyCategoryFunc; + this.getFailureMechanismSectionAssemblyCategoryFunc = getFailureMechanismSectionAssemblyCategoryFunc; + Data = failureMechanism; } @@ -87,7 +84,7 @@ { get { - return CreateFailureMechanismAssemblyCategories().ToArray(); + return getFailureMechanismAssemblyCategoryFunc().Select(category => new FailureMechanismAssemblyCategoryProperties(category)).ToArray(); } } @@ -100,31 +97,8 @@ { get { - return CreateFailureMechanismSectionAssemblyCategories().ToArray(); + return getFailureMechanismSectionAssemblyCategoryFunc().Select(category => new FailureMechanismSectionAssemblyCategoryProperties(category)).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 e6944724df4a525632b83d596ca0ae4b2ebc0766 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/FailureMechanismAssemblyCategoriesProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e6944724df4a525632b83d596ca0ae4b2ebc0766 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/GeotechnicalFailureMechanismAssemblyCategoriesProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -rbed9a78467c584c41edfdeadd4dce27b9e23d1ae -re6944724df4a525632b83d596ca0ae4b2ebc0766 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision bed9a78467c584c41edfdeadd4dce27b9e23d1ae) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision e6944724df4a525632b83d596ca0ae4b2ebc0766) @@ -96,8 +96,6 @@ - - Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesBasePropertiesTest.cs =================================================================== diff -u -r2d8411b48599eb45028ec924641b50ee6edd71c2 -re6944724df4a525632b83d596ca0ae4b2ebc0766 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesBasePropertiesTest.cs (.../FailureMechanismAssemblyCategoriesBasePropertiesTest.cs) (revision 2d8411b48599eb45028ec924641b50ee6edd71c2) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesBasePropertiesTest.cs (.../FailureMechanismAssemblyCategoriesBasePropertiesTest.cs) (revision e6944724df4a525632b83d596ca0ae4b2ebc0766) @@ -28,12 +28,7 @@ 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; @@ -45,107 +40,82 @@ [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); + TestDelegate call = () => new FailureMechanismAssemblyCategoriesBaseProperties(null, + GetFailureMechanismAssemblyCategory, + GetFailureMechanismSectionAssemblyCategory); // Assert var exception = Assert.Throws(call); Assert.AreEqual("failureMechanism", exception.ParamName); - mocks.VerifyAll(); } [Test] - public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + public void Constructor_GetFailureMechanismAssemblyCategoryFuncNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var failureMechanism = mocks.Stub(); mocks.ReplayAll(); // Call - TestDelegate call = () => new TestFailureMechanismAssemblyCategoriesProperties(failureMechanism, + TestDelegate call = () => new FailureMechanismAssemblyCategoriesBaseProperties(failureMechanism, null, - () => 0.01); + GetFailureMechanismSectionAssemblyCategory); // Assert var exception = Assert.Throws(call); - Assert.AreEqual("assessmentSection", exception.ParamName); + Assert.AreEqual("getFailureMechanismAssemblyCategoryFunc", exception.ParamName); mocks.VerifyAll(); } [Test] - public void Constructor_GetNFuncNull_ThrowsArgumentNullException() + public void Constructor_GetFailureMechanismSectionAssemblyCategoryFuncNull_ThrowsArgumentNullException() { // Setup var mocks = new MockRepository(); var failureMechanism = mocks.Stub(); - var assessmentSection = mocks.Stub(); mocks.ReplayAll(); // Call - TestDelegate call = () => new TestFailureMechanismAssemblyCategoriesProperties(failureMechanism, - assessmentSection, + TestDelegate call = () => new FailureMechanismAssemblyCategoriesBaseProperties(failureMechanism, + GetFailureMechanismAssemblyCategory, null); // Assert var exception = Assert.Throws(call); - Assert.AreEqual("getNFunc", exception.ParamName); + Assert.AreEqual("getFailureMechanismSectionAssemblyCategoryFunc", 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); + // Call + var properties = new FailureMechanismAssemblyCategoriesBaseProperties(failureMechanism, + GetFailureMechanismAssemblyCategory, + GetFailureMechanismSectionAssemblyCategory); - // Assert - Assert.IsInstanceOf>(properties); - Assert.AreSame(failureMechanism, properties.Data); + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(failureMechanism, properties.Data); - TestHelper.AssertTypeConverter( - nameof(TestFailureMechanismAssemblyCategoriesProperties.FailureMechanismAssemblyCategories)); - TestHelper.AssertTypeConverter( - nameof(TestFailureMechanismAssemblyCategoriesProperties.FailureMechanismSectionAssemblyCategories)); + TestHelper.AssertTypeConverter( + nameof(FailureMechanismAssemblyCategoriesBaseProperties.FailureMechanismAssemblyCategories)); + TestHelper.AssertTypeConverter( + nameof(FailureMechanismAssemblyCategoriesBaseProperties.FailureMechanismSectionAssemblyCategories)); - FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; - IEnumerable expectedFailureMechanismCategories = - AssemblyToolCategoriesFactory.CreateFailureMechanismAssemblyCategories( - failureMechanismContribution.SignalingNorm, - failureMechanismContribution.LowerLimitNorm, - failureMechanism.Contribution, - n); + AssemblyCategoryPropertiesTestHelper.AssertFailureMechanismAssemblyCategoryProperties( + GetFailureMechanismAssemblyCategory(), + GetFailureMechanismSectionAssemblyCategory(), + properties); - AssemblyCategoryPropertiesTestHelper.AssertFailureMechanismAssemblyCategoryProperties( - expectedFailureMechanismCategories, - new[] - { - new FailureMechanismSectionAssemblyCategory(0.0, 1.0, FailureMechanismSectionAssemblyCategoryGroup.IIIv) - }, - properties); - - mocks.VerifyAll(); - } + mocks.VerifyAll(); } [Test] @@ -154,13 +124,12 @@ // Setup var mocks = new MockRepository(); var failureMechanism = mocks.Stub(); - var assessmentSection = new AssessmentSectionStub(); mocks.ReplayAll(); // Call - var properties = new TestFailureMechanismAssemblyCategoriesProperties(failureMechanism, - assessmentSection, - () => 0.01); + var properties = new FailureMechanismAssemblyCategoriesBaseProperties(failureMechanism, + GetFailureMechanismAssemblyCategory, + GetFailureMechanismSectionAssemblyCategory); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Assert.AreEqual(2, dynamicProperties.Count); @@ -184,19 +153,18 @@ mocks.VerifyAll(); } - private class TestFailureMechanismAssemblyCategoriesProperties : FailureMechanismAssemblyCategoriesBaseProperties + private IEnumerable GetFailureMechanismSectionAssemblyCategory() { - public TestFailureMechanismAssemblyCategoriesProperties(IFailureMechanism failureMechanism, IAssessmentSection assessmentSection, Func getNFunc) - : base(failureMechanism, assessmentSection, getNFunc) {} + var random = new Random(21); - protected override IEnumerable CreateFailureMechanismSectionAssemblyCategories() - { - return new[] - { - new FailureMechanismSectionAssemblyCategoryProperties( - new FailureMechanismSectionAssemblyCategory(0.0, 1.0, FailureMechanismSectionAssemblyCategoryGroup.IIIv)) - }; - } + yield return new FailureMechanismSectionAssemblyCategory(random.NextDouble(), random.NextDouble(), random.NextEnumValue()); } + + private IEnumerable GetFailureMechanismAssemblyCategory() + { + var random = new Random(21); + + yield return new FailureMechanismAssemblyCategory(random.NextDouble(), random.NextDouble(), random.NextEnumValue()); + } } } \ No newline at end of file Fisheye: Tag e6944724df4a525632b83d596ca0ae4b2ebc0766 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/FailureMechanismAssemblyCategoriesPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag e6944724df4a525632b83d596ca0ae4b2ebc0766 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/GeotechnicalFailureMechanismAssemblyCategoriesPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -rbed9a78467c584c41edfdeadd4dce27b9e23d1ae -re6944724df4a525632b83d596ca0ae4b2ebc0766 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision bed9a78467c584c41edfdeadd4dce27b9e23d1ae) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision e6944724df4a525632b83d596ca0ae4b2ebc0766) @@ -98,8 +98,6 @@ - -