Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.Designer.cs =================================================================== diff -u -r43028e39fdda46eb5dfb3785cc742809469836ce -rccae9df69627ec799cd3abafedb259f9a4e0fc2f --- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.Designer.cs (.../AssemblyResultTotalView.Designer.cs) (revision 43028e39fdda46eb5dfb3785cc742809469836ce) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.Designer.cs (.../AssemblyResultTotalView.Designer.cs) (revision ccae9df69627ec799cd3abafedb259f9a4e0fc2f) @@ -140,6 +140,7 @@ this.checkBox.TabIndex = 4; this.checkBox.Text = global::Riskeer.Integration.Forms.Properties.Resources.AssemblyResultTotalView_GrassCoverErosionInwards_and_HeightStructures_correlated; this.checkBox.UseVisualStyleBackColor = true; + this.checkBox.CheckedChanged += new System.EventHandler(this.checkBox_CheckedChanged); // // AssemblyResultTotalView // Index: Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs =================================================================== diff -u -r01c40dbdf75bccae38a7728556afe2f8968f55c0 -rccae9df69627ec799cd3abafedb259f9a4e0fc2f --- Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs (.../AssemblyResultTotalView.cs) (revision 01c40dbdf75bccae38a7728556afe2f8968f55c0) +++ Riskeer/Integration/src/Riskeer.Integration.Forms/Views/AssemblyResultTotalView.cs (.../AssemblyResultTotalView.cs) (revision ccae9df69627ec799cd3abafedb259f9a4e0fc2f) @@ -76,13 +76,21 @@ InitializeComponent(); - assessmentSectionObserver = new Observer(EnableRefreshButton) + assessmentSectionObserver = new Observer(() => { + EnableRefreshButton(); + UpdateFailureMechanismsCorrelatedCheckBox(); + }) + { Observable = assessmentSection }; - assessmentSectionResultObserver = new Observer(EnableRefreshButton) + assessmentSectionResultObserver = new Observer(() => { + EnableRefreshButton(); + UpdateFailureMechanismsCorrelatedCheckBox(); + }) + { Observable = new AssessmentSectionResultObserver(assessmentSection) }; } @@ -100,6 +108,7 @@ InitializeDataGridView(); UpdateAssemblyResultControls(); + UpdateFailureMechanismsCorrelatedCheckBox(); dataGridViewControl.CellFormatting += HandleCellStyling; } @@ -126,6 +135,12 @@ } } + private void UpdateFailureMechanismsCorrelatedCheckBox() + { + checkBox.Visible = AssessmentSectionAssemblyHelper.AllCorrelatedFailureMechanismsInAssembly(AssessmentSection); + checkBox.Checked = AssessmentSection.AreFailureMechanismsCorrelated; + } + private void InitializeDataGridView() { dataGridViewControl.AddTextBoxColumn(nameof(FailureMechanismAssemblyResultRow.Name), @@ -337,5 +352,11 @@ } #endregion + + private void checkBox_CheckedChanged(object sender, EventArgs e) + { + EnableRefreshButton(); + AssessmentSection.AreFailureMechanismsCorrelated = checkBox.Checked; + } } } \ No newline at end of file Index: Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyResultTotalViewTest.cs =================================================================== diff -u -r43028e39fdda46eb5dfb3785cc742809469836ce -rccae9df69627ec799cd3abafedb259f9a4e0fc2f --- Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyResultTotalViewTest.cs (.../AssemblyResultTotalViewTest.cs) (revision 43028e39fdda46eb5dfb3785cc742809469836ce) +++ Riskeer/Integration/test/Riskeer.Integration.Forms.Test/Views/AssemblyResultTotalViewTest.cs (.../AssemblyResultTotalViewTest.cs) (revision ccae9df69627ec799cd3abafedb259f9a4e0fc2f) @@ -47,6 +47,7 @@ using Riskeer.HeightStructures.Data; using Riskeer.HeightStructures.Data.TestUtil; using Riskeer.Integration.Data; +using Riskeer.Integration.Data.Assembly; using Riskeer.Integration.Data.StandAlone; using Riskeer.Integration.Forms.Controls; using Riskeer.Integration.Forms.Views; @@ -118,14 +119,15 @@ Assert.AreEqual(DockStyle.Top, tableLayoutPanel.Dock); Assert.AreEqual(2, tableLayoutPanel.ColumnCount); Assert.AreEqual(1, tableLayoutPanel.RowCount); - + var assemblyResultControl = (AssessmentSectionAssemblyResultControl) tableLayoutPanel.GetControlFromPosition(0, 0); Assert.AreEqual(DockStyle.Fill, assemblyResultControl.Dock); var checkBox = (CheckBox) tableLayoutPanel.GetControlFromPosition(1, 0); Assert.AreEqual("GEKB en HTKW gecorreleerd", checkBox.Text); + Assert.AreEqual(assessmentSection.AreFailureMechanismsCorrelated, checkBox.Checked); Assert.AreEqual(DockStyle.Bottom, checkBox.Dock); - + var label = (Label) new ControlTester("label").TheObject; Assert.AreEqual("Samenvatting resultaten per faalmechanisme:", label.Text); @@ -147,6 +149,118 @@ } [Test] + public void GivenFormWithAssemblyResultTotalViewAndAllCorrelatedFailureMechanismsInAssemblyTrue_ThenCheckboxVisible() + { + // Given + AssessmentSection assessmentSection = CreateAssessmentSection(); + assessmentSection.HeightStructures.InAssembly = true; + assessmentSection.GrassCoverErosionInwards.InAssembly = true; + + using (ShowAssemblyResultTotalView(assessmentSection)) + { + // Precondition + bool allCorrelatedFailureMechanismsInAssembly = AssessmentSectionAssemblyHelper.AllCorrelatedFailureMechanismsInAssembly(assessmentSection); + Assert.IsTrue(allCorrelatedFailureMechanismsInAssembly); + + // Then + CheckBox checkBox = GetCorrelatedFailureMechanismsCheckBox(); + Assert.IsTrue(checkBox.Visible); + } + } + + [Test] + public void GivenFormWithAssemblyResultTotalViewAndAllCorrelatedFailureMechanismsInAssemblyFalse_ThenCheckboxNotVisible() + { + // Given + AssessmentSection assessmentSection = CreateAssessmentSection(); + assessmentSection.HeightStructures.InAssembly = false; + + using (ShowAssemblyResultTotalView(assessmentSection)) + { + // Precondition + bool allCorrelatedFailureMechanismsInAssembly = AssessmentSectionAssemblyHelper.AllCorrelatedFailureMechanismsInAssembly(assessmentSection); + Assert.IsFalse(allCorrelatedFailureMechanismsInAssembly); + + // Then + CheckBox checkBox = GetCorrelatedFailureMechanismsCheckBox(); + Assert.IsFalse(checkBox.Visible); + } + } + + [Test] + public void GivenFormWithAssemblyResultTotalViewAndAllCorrelatedFailureMechanismsInAssemblyFalse_WhenAllCorrelatedFailureMechanismsInAssemblyTrueAndFailureMechanismNotifyObservers_ThenCheckboxVisible() + { + // Given + AssessmentSection assessmentSection = CreateAssessmentSection(); + assessmentSection.HeightStructures.InAssembly = false; + + using (ShowAssemblyResultTotalView(assessmentSection)) + { + // Precondition + CheckBox checkBox = GetCorrelatedFailureMechanismsCheckBox(); + Assert.IsFalse(checkBox.Visible); + + // When + assessmentSection.HeightStructures.InAssembly = true; + assessmentSection.HeightStructures.NotifyObservers(); + + // Then + Assert.IsTrue(checkBox.Visible); + } + } + + [Test] + public void GivenFormWithAssemblyResultTotalViewAndAllCorrelatedFailureMechanismsInAssemblyFalse_WhenAllCorrelatedFailureMechanismsInAssemblyTrueAndAssessmentSectionNotifyObservers_ThenCheckboxVisible() + { + // Given + AssessmentSection assessmentSection = CreateAssessmentSection(); + assessmentSection.HeightStructures.InAssembly = false; + + using (ShowAssemblyResultTotalView(assessmentSection)) + { + // Precondition + CheckBox checkBox = GetCorrelatedFailureMechanismsCheckBox(); + Assert.IsFalse(checkBox.Visible); + + // When + assessmentSection.HeightStructures.InAssembly = true; + assessmentSection.NotifyObservers(); + + // Then + Assert.IsTrue(checkBox.Visible); + } + } + + [Test] + public void GivenFormWithAssemblyResultTotalViewAndAllCorrelatedFailureMechanismsInAssemblyTrue_WhenCheckingCheckBox_ThenRefreshButtonEnabledWithWarningAndAreFailureMechanismsCorrelatedSet() + { + // Given + AssessmentSection assessmentSection = CreateAssessmentSection(); + assessmentSection.HeightStructures.InAssembly = true; + assessmentSection.GrassCoverErosionInwards.InAssembly = true; + + using (AssemblyResultTotalView view = ShowAssemblyResultTotalView(assessmentSection)) + { + // Precondition + ButtonTester buttonTester = GetRefreshAssemblyResultButtonTester(); + Button button = buttonTester.Properties; + Assert.IsFalse(button.Enabled); + ErrorProvider warningProvider = GetWarningProvider(view); + Assert.IsEmpty(warningProvider.GetError(button)); + + // When + CheckBox checkBox = GetCorrelatedFailureMechanismsCheckBox(); + checkBox.Checked = true; + + // Then + Assert.AreEqual(checkBox.Checked, assessmentSection.AreFailureMechanismsCorrelated); + + Assert.IsTrue(button.Enabled); + Assert.AreEqual(assemblyResultOutdatedWarning, warningProvider.GetError(button)); + } + } + + [Test] public void GivenFormWithAssemblyResultTotalView_ThenExpectedColumnsAreVisible() { // Given @@ -655,6 +769,11 @@ return TypeUtils.GetField(resultControl, "warningProvider"); } + private static CheckBox GetCorrelatedFailureMechanismsCheckBox() + { + return (CheckBox) new CheckBoxTester("checkBox").TheObject; + } + #endregion #region Asserts datagrid control