Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs =================================================================== diff -u -r0212a34000a191d09b6c59274b26e7bfbfa01f4d -rb51d0436ee3fa6b8acb84d32be9a463a1411d4d9 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision 0212a34000a191d09b6c59274b26e7bfbfa01f4d) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision b51d0436ee3fa6b8acb84d32be9a463a1411d4d9) @@ -26,6 +26,7 @@ using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Exceptions; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; using Ringtoets.Common.Primitives; @@ -306,6 +307,12 @@ /// could not be created. private void Update() { + UpdateData(); + UpdateColumnDefinitionStates(); + } + + private void UpdateData() + { SimpleAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); DetailedAssemblyCategoryGroup = MacroStabilityOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssembly( @@ -324,6 +331,55 @@ assessmentSection); } + private void UpdateColumnDefinitionStates() + { + bool simpleAssessmentSufficient = GetSimpleAssessmentSufficient(); + + SetColumnState(detailedAssessmentResultIndex, simpleAssessmentSufficient); + SetColumnState(detailedAssessmentProbabilityIndex, simpleAssessmentSufficient); + SetColumnState(tailorMadeAssessmentResultIndex, simpleAssessmentSufficient); + SetColumnState(tailorMadeAssessmentProbabilityIndex, simpleAssessmentSufficient); + } + + private void SetColumnState(int columnIndex, bool shouldDisable) + { + if (shouldDisable) + { + DisableColumn(columnIndex); + } + else + { + EnableColumn(columnIndex); + } + } + + private void EnableColumn(int index) + { + ColumnStateDefinitions[index].ReadOnly = false; + ColumnStateDefinitions[index].Style = CellStyle.Enabled; + } + + private void DisableColumn(int index) + { + ColumnStateDefinitions[index].ReadOnly = true; + ColumnStateDefinitions[index].Style = CellStyle.Disabled; + } + + private bool GetSimpleAssessmentSufficient() + { + return FailureMechanismResultViewHelper.SimpleAssessmentIsSufficient(SimpleAssessmentResult); + } + + private bool GetDetailedAssessmentResultIsNotProbability() + { + return DetailedAssessmentResult != DetailedAssessmentResultType.Probability; + } + + private bool GetTailorMadeAssessmentResultIsNotProbability() + { + return TailorMadeAssessmentResult != TailorMadeAssessmentProbabilityAndDetailedCalculationResultType.Probability; + } + /// /// Class holding the various construction parameters for . /// Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs =================================================================== diff -u -r0212a34000a191d09b6c59274b26e7bfbfa01f4d -rb51d0436ee3fa6b8acb84d32be9a463a1411d4d9 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs (.../MacroStabilityOutwardsSectionResultRowTest.cs) (revision 0212a34000a191d09b6c59274b26e7bfbfa01f4d) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs (.../MacroStabilityOutwardsSectionResultRowTest.cs) (revision b51d0436ee3fa6b8acb84d32be9a463a1411d4d9) @@ -142,6 +142,27 @@ // Assert Assert.IsInstanceOf>(row); + + 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]); + } + + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.SimpleAssessmentResultIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.DetailedAssessmentResultIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentResultIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentProbabilityIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.SimpleAssemblyCategoryGroupIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.DetailedAssemblyCategoryGroupIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.TailorMadeAssemblyCategoryGroupIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.CombinedAssemblyCategoryGroupIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.ManualAssemblyCategoryGroupIndex]); + Assert.AreEqual(result.SimpleAssessmentResult, row.SimpleAssessmentResult); Assert.AreEqual(result.DetailedAssessmentResult, row.DetailedAssessmentResult); Assert.AreEqual(result.DetailedAssessmentProbability, row.DetailedAssessmentProbability); @@ -161,40 +182,6 @@ } [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 @@ -289,6 +276,62 @@ } } + [Test] + [TestCase(SimpleAssessmentResultType.ProbabilityNegligible)] + [TestCase(SimpleAssessmentResultType.NotApplicable)] + public void Constructor_WithSimpleAssessmentSufficient_ExpectedColumnStates(SimpleAssessmentResultType simpleAssessmentResult) + { + // 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) + { + SimpleAssessmentResult = simpleAssessmentResult + }; + + using (new AssemblyToolCalculatorFactoryConfig()) + { + // Call + var row = new MacroStabilityOutwardsSectionResultRow(result, failureMechanism, assessmentSection, + ConstructionProperties); + + // Assert + IDictionary columnStateDefinitions = row.ColumnStateDefinitions; + + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.SimpleAssessmentResultIndex]); + AssertColumnStateIsDisabled(columnStateDefinitions[ConstructionProperties.DetailedAssessmentResultIndex]); + AssertColumnStateIsDisabled(columnStateDefinitions[ConstructionProperties.DetailedAssessmentProbabilityIndex]); + AssertColumnStateIsDisabled(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentResultIndex]); + AssertColumnStateIsDisabled(columnStateDefinitions[ConstructionProperties.TailorMadeAssessmentProbabilityIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.SimpleAssemblyCategoryGroupIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.DetailedAssemblyCategoryGroupIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.TailorMadeAssemblyCategoryGroupIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.CombinedAssemblyCategoryGroupIndex]); + AssertColumnStateIsEnabled(columnStateDefinitions[ConstructionProperties.ManualAssemblyCategoryGroupIndex]); + + mocks.VerifyAll(); + } + } + + private static void AssertColumnStateIsDisabled(DataGridViewColumnStateDefinition columnStateDefinition) + { + Assert.AreEqual(CellStyle.Disabled, columnStateDefinition.Style); + Assert.IsTrue(columnStateDefinition.ReadOnly); + Assert.AreEqual(string.Empty, columnStateDefinition.ErrorText); + } + + private static void AssertColumnStateIsEnabled(DataGridViewColumnStateDefinition columnStateDefinition) + { + Assert.AreEqual(CellStyle.Enabled, columnStateDefinition.Style); + Assert.IsFalse(columnStateDefinition.ReadOnly); + Assert.AreEqual(string.Empty, columnStateDefinition.ErrorText); + } + #region Registration [Test]