Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs =================================================================== diff -u -r73ce73546dd3805de5a1dcedf8dea86671899302 -r0212a34000a191d09b6c59274b26e7bfbfa01f4d --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision 73ce73546dd3805de5a1dcedf8dea86671899302) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision 0212a34000a191d09b6c59274b26e7bfbfa01f4d) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.ComponentModel; +using Core.Common.Controls.DataGrid; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Exceptions; @@ -97,10 +99,17 @@ combinedAssemblyCategoryGroupIndex = constructionProperties.CombinedAssemblyCategoryGroupIndex; manualAssemblyCategoryGroupIndex = constructionProperties.ManualAssemblyCategoryGroupIndex; + ColumnStateDefinitions = CreateColumnStateDefinitions(); + Update(); } /// + /// Gets the column state definitions for the given indices. + /// + public IDictionary ColumnStateDefinitions { get; } + + /// /// Gets or sets the value representing the simple assessment result. /// public SimpleAssessmentResultType SimpleAssessmentResult @@ -253,6 +262,43 @@ } } + private Dictionary CreateColumnStateDefinitions() + { + return new Dictionary + { + { + simpleAssessmentResultIndex, new DataGridViewColumnStateDefinition() + }, + { + detailedAssessmentResultIndex, new DataGridViewColumnStateDefinition() + }, + { + detailedAssessmentProbabilityIndex, new DataGridViewColumnStateDefinition() + }, + { + tailorMadeAssessmentResultIndex, new DataGridViewColumnStateDefinition() + }, + { + tailorMadeAssessmentProbabilityIndex, new DataGridViewColumnStateDefinition() + }, + { + simpleAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition() + }, + { + detailedAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition() + }, + { + tailorMadeAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition() + }, + { + combinedAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition() + }, + { + manualAssemblyCategoryGroupIndex, new DataGridViewColumnStateDefinition() + } + }; + } + /// /// Updates the derived assembly category groups. /// @@ -292,7 +338,7 @@ /// Gets or sets the detailed assessment result index. /// public int DetailedAssessmentResultIndex { internal get; set; } - + /// /// Gets or sets the detailed assessment probability index. /// Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs =================================================================== diff -u -r73ce73546dd3805de5a1dcedf8dea86671899302 -r0212a34000a191d09b6c59274b26e7bfbfa01f4d --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs (.../MacroStabilityOutwardsSectionResultRowTest.cs) (revision 73ce73546dd3805de5a1dcedf8dea86671899302) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs (.../MacroStabilityOutwardsSectionResultRowTest.cs) (revision 0212a34000a191d09b6c59274b26e7bfbfa01f4d) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using System.Collections.Generic; using Core.Common.Base; +using Core.Common.Controls.DataGrid; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; @@ -44,6 +46,26 @@ [TestFixture] public class MacroStabilityOutwardsSectionResultRowTest { + private static MacroStabilityOutwardsSectionResultRow.ConstructionProperties ConstructionProperties + { + get + { + return new MacroStabilityOutwardsSectionResultRow.ConstructionProperties + { + SimpleAssessmentResultIndex = 1, + DetailedAssessmentResultIndex = 2, + DetailedAssessmentProbabilityIndex = 3, + TailorMadeAssessmentResultIndex = 4, + TailorMadeAssessmentProbabilityIndex = 5, + SimpleAssemblyCategoryGroupIndex = 6, + DetailedAssemblyCategoryGroupIndex = 7, + TailorMadeAssemblyCategoryGroupIndex = 8, + CombinedAssemblyCategoryGroupIndex = 9, + ManualAssemblyCategoryGroupIndex = 10 + }; + } + } + [Test] public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() { @@ -57,7 +79,7 @@ // Call TestDelegate test = () => new MacroStabilityOutwardsSectionResultRow(result, null, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Assert string paramName = Assert.Throws(test).ParamName; @@ -74,7 +96,7 @@ // Call TestDelegate test = () => new MacroStabilityOutwardsSectionResultRow(result, new MacroStabilityOutwardsFailureMechanism(), null, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Assert string paramName = Assert.Throws(test).ParamName; @@ -116,7 +138,7 @@ { // Call var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Assert Assert.IsInstanceOf>(row); @@ -139,6 +161,40 @@ } [Test] + public void Constructor_WithConstructionProperties_ExpectedValues() + { + // Setup + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + var mocks = new MockRepository(); + IAssessmentSection assessmentSection = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mocks); + mocks.ReplayAll(); + + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var result = new MacroStabilityOutwardsFailureMechanismSectionResult(section); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + // Call + var row = new MacroStabilityOutwardsSectionResultRow( + result, failureMechanism, assessmentSection, + ConstructionProperties); + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + Assert.AreEqual(10, columnStateDefinitions.Count); + + for (var i = 1; i < 11; i++) + { + Assert.IsTrue(columnStateDefinitions.ContainsKey(i)); + Assert.IsNotNull(columnStateDefinitions[i]); + } + + mocks.VerifyAll(); + } + } + + [Test] public void Constructor_AssemblyThrowsException_ThrowsAssemblyException() { // Setup @@ -159,7 +215,7 @@ // Call TestDelegate test = () => new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Assert Assert.Throws(test); @@ -186,7 +242,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Precondition Assert.IsFalse(result.UseManualAssemblyCategoryGroup); @@ -222,7 +278,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Call row.ManualAssemblyCategoryGroup = newValue; @@ -257,7 +313,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Call row.SimpleAssessmentResult = newValue; @@ -290,7 +346,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Call row.DetailedAssessmentResult = newValue; @@ -325,7 +381,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Call row.DetailedAssessmentProbability = value; @@ -357,7 +413,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Call TestDelegate test = () => row.DetailedAssessmentProbability = value; @@ -392,7 +448,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Call row.TailorMadeAssessmentResult = newValue; @@ -427,7 +483,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Call row.TailorMadeAssessmentProbability = value; @@ -459,7 +515,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); // Call TestDelegate test = () => row.TailorMadeAssessmentProbability = value; @@ -492,7 +548,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; @@ -523,7 +579,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; @@ -554,7 +610,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator; @@ -585,7 +641,7 @@ using (new AssemblyToolCalculatorFactoryConfig()) { var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, - new MacroStabilityOutwardsSectionResultRow.ConstructionProperties()); + ConstructionProperties); var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; FailureMechanismSectionAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismSectionAssemblyCalculator;