Index: Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismResultView.cs =================================================================== diff -u -r352b81d92f568dbe5e072a2c00b4e518ee1605d3 -r7adc47fc72205078d054034bb9d1028c32434e28 --- Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismResultView.cs (.../DuneErosionFailureMechanismResultView.cs) (revision 352b81d92f568dbe5e072a2c00b4e518ee1605d3) +++ Ringtoets/DuneErosion/src/Ringtoets.DuneErosion.Forms/Views/DuneErosionFailureMechanismResultView.cs (.../DuneErosionFailureMechanismResultView.cs) (revision 7adc47fc72205078d054034bb9d1028c32434e28) @@ -142,5 +142,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(DuneErosionFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism)); } + + protected override bool HasManualAssemblyResults() + { + return DuneErosionFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneErosionFailureMechanismResultViewTest.cs =================================================================== diff -u -r6b5b4d5c4433294d5fc53dab82afdcbcefd91d41 -r7adc47fc72205078d054034bb9d1028c32434e28 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneErosionFailureMechanismResultViewTest.cs (.../DuneErosionFailureMechanismResultViewTest.cs) (revision 6b5b4d5c4433294d5fc53dab82afdcbcefd91d41) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Views/DuneErosionFailureMechanismResultViewTest.cs (.../DuneErosionFailureMechanismResultViewTest.cs) (revision 7adc47fc72205078d054034bb9d1028c32434e28) @@ -19,7 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; using System.Windows.Forms; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.AssemblyTool.Forms; @@ -167,6 +170,62 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new DuneErosionFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyCategoryGroup = true; + + using (var form = new Form()) + using (var view = new DuneErosionFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism)) + { + form.Controls.Add(view); + form.Show(); + + FailureMechanismAssemblyCategoryGroupControl failureMechanismAssemblyControl = GetFailureMechanismAssemblyControl(); + ErrorProvider warningProvider = GetWarningProvider(failureMechanismAssemblyControl); + + // Call + string warningMessage = warningProvider.GetError(failureMechanismAssemblyControl); + + // Assert + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningMessage); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithWarnings_WhenFailureMechanismWithoutManualSectionAssemblyResultsAndFailureMechanismNotifiesObservers_ThenWarningCleared() + { + // Given + var failureMechanism = new DuneErosionFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyCategoryGroup = true; + + using (var form = new Form()) + using (var view = new DuneErosionFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism)) + { + form.Controls.Add(view); + form.Show(); + + FailureMechanismAssemblyCategoryGroupControl failureMechanismAssemblyControl = GetFailureMechanismAssemblyControl(); + ErrorProvider warningProvider = GetWarningProvider(failureMechanismAssemblyControl); + + // Precondition + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningProvider.GetError(failureMechanismAssemblyControl)); + + // When + failureMechanism.SectionResults.ForEachElementDo(sr => sr.UseManualAssemblyCategoryGroup = false); + failureMechanism.NotifyObservers(); + + // Then + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class DuneErosionFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< DuneErosionFailureMechanismResultView, @@ -180,5 +239,16 @@ failureMechanism); } } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs =================================================================== diff -u -r352b81d92f568dbe5e072a2c00b4e518ee1605d3 -r7adc47fc72205078d054034bb9d1028c32434e28 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs (.../GrassCoverErosionOutwardsFailureMechanismResultView.cs) (revision 352b81d92f568dbe5e072a2c00b4e518ee1605d3) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs (.../GrassCoverErosionOutwardsFailureMechanismResultView.cs) (revision 7adc47fc72205078d054034bb9d1028c32434e28) @@ -141,5 +141,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism)); } + + protected override bool HasManualAssemblyResults() + { + return GrassCoverErosionOutwardsFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs =================================================================== diff -u -r6b5b4d5c4433294d5fc53dab82afdcbcefd91d41 -r7adc47fc72205078d054034bb9d1028c32434e28 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs) (revision 6b5b4d5c4433294d5fc53dab82afdcbcefd91d41) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs) (revision 7adc47fc72205078d054034bb9d1028c32434e28) @@ -19,7 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; using System.Windows.Forms; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.AssemblyTool.Forms; @@ -168,6 +171,62 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyCategoryGroup = true; + + using (var form = new Form()) + using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism)) + { + form.Controls.Add(view); + form.Show(); + + FailureMechanismAssemblyCategoryGroupControl failureMechanismAssemblyControl = GetFailureMechanismAssemblyControl(); + ErrorProvider warningProvider = GetWarningProvider(failureMechanismAssemblyControl); + + // Call + string warningMessage = warningProvider.GetError(failureMechanismAssemblyControl); + + // Assert + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningMessage); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithWarnings_WhenFailureMechanismWithoutManualSectionAssemblyResultsAndFailureMechanismNotifiesObservers_ThenWarningCleared() + { + // Given + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyCategoryGroup = true; + + using (var form = new Form()) + using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism)) + { + form.Controls.Add(view); + form.Show(); + + FailureMechanismAssemblyCategoryGroupControl failureMechanismAssemblyControl = GetFailureMechanismAssemblyControl(); + ErrorProvider warningProvider = GetWarningProvider(failureMechanismAssemblyControl); + + // Precondition + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningProvider.GetError(failureMechanismAssemblyControl)); + + // When + failureMechanism.SectionResults.ForEachElementDo(sr => sr.UseManualAssemblyCategoryGroup = false); + failureMechanism.NotifyObservers(); + + // Assert + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class GrassCoverErosionOutwardsFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< GrassCoverErosionOutwardsFailureMechanismResultView, @@ -181,5 +240,16 @@ failureMechanism); } } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverResultView.cs =================================================================== diff -u -r352b81d92f568dbe5e072a2c00b4e518ee1605d3 -r7adc47fc72205078d054034bb9d1028c32434e28 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverResultView.cs (.../StabilityStoneCoverResultView.cs) (revision 352b81d92f568dbe5e072a2c00b4e518ee1605d3) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/Views/StabilityStoneCoverResultView.cs (.../StabilityStoneCoverResultView.cs) (revision 7adc47fc72205078d054034bb9d1028c32434e28) @@ -140,5 +140,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(StabilityStoneCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism)); } + + protected override bool HasManualAssemblyResults() + { + return StabilityStoneCoverFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverResultViewTest.cs =================================================================== diff -u -r6b5b4d5c4433294d5fc53dab82afdcbcefd91d41 -r7adc47fc72205078d054034bb9d1028c32434e28 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverResultViewTest.cs (.../StabilityStoneCoverResultViewTest.cs) (revision 6b5b4d5c4433294d5fc53dab82afdcbcefd91d41) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/Views/StabilityStoneCoverResultViewTest.cs (.../StabilityStoneCoverResultViewTest.cs) (revision 7adc47fc72205078d054034bb9d1028c32434e28) @@ -19,7 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; using System.Windows.Forms; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.AssemblyTool.Forms; @@ -168,6 +171,62 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyCategoryGroup = true; + + using (var form = new Form()) + using (var view = new StabilityStoneCoverResultView(failureMechanism.SectionResults, + failureMechanism)) + { + form.Controls.Add(view); + form.Show(); + + FailureMechanismAssemblyCategoryGroupControl failureMechanismAssemblyControl = GetFailureMechanismAssemblyControl(); + ErrorProvider warningProvider = GetWarningProvider(failureMechanismAssemblyControl); + + // Call + string warningMessage = warningProvider.GetError(failureMechanismAssemblyControl); + + // Assert + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningMessage); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithWarnings_WhenFailureMechanismWithoutManualSectionAssemblyResultsAndFailureMechanismNotifiesObservers_ThenWarningCleared() + { + // Given + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyCategoryGroup = true; + + using (var form = new Form()) + using (var view = new StabilityStoneCoverResultView(failureMechanism.SectionResults, + failureMechanism)) + { + form.Controls.Add(view); + form.Show(); + + FailureMechanismAssemblyCategoryGroupControl failureMechanismAssemblyControl = GetFailureMechanismAssemblyControl(); + ErrorProvider warningProvider = GetWarningProvider(failureMechanismAssemblyControl); + + // Precondition + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningProvider.GetError(failureMechanismAssemblyControl)); + + // When + failureMechanism.SectionResults.ForEachElementDo(sr => sr.UseManualAssemblyCategoryGroup = false); + failureMechanism.NotifyObservers(); + + // Then + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class StabilityStoneCoverFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< StabilityStoneCoverResultView, @@ -181,5 +240,16 @@ failureMechanism); } } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismResultView.cs =================================================================== diff -u -r352b81d92f568dbe5e072a2c00b4e518ee1605d3 -r7adc47fc72205078d054034bb9d1028c32434e28 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismResultView.cs (.../WaveImpactAsphaltCoverFailureMechanismResultView.cs) (revision 352b81d92f568dbe5e072a2c00b4e518ee1605d3) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/Views/WaveImpactAsphaltCoverFailureMechanismResultView.cs (.../WaveImpactAsphaltCoverFailureMechanismResultView.cs) (revision 7adc47fc72205078d054034bb9d1028c32434e28) @@ -141,5 +141,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(WaveImpactAsphaltCoverFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism)); } + + protected override bool HasManualAssemblyResults() + { + return WaveImpactAsphaltCoverFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismResultViewTest.cs =================================================================== diff -u -r6b5b4d5c4433294d5fc53dab82afdcbcefd91d41 -r7adc47fc72205078d054034bb9d1028c32434e28 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismResultViewTest.cs (.../WaveImpactAsphaltCoverFailureMechanismResultViewTest.cs) (revision 6b5b4d5c4433294d5fc53dab82afdcbcefd91d41) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Forms.Test/Views/WaveImpactAsphaltCoverFailureMechanismResultViewTest.cs (.../WaveImpactAsphaltCoverFailureMechanismResultViewTest.cs) (revision 7adc47fc72205078d054034bb9d1028c32434e28) @@ -19,7 +19,10 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Linq; using System.Windows.Forms; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.AssemblyTool.Forms; @@ -168,6 +171,62 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyCategoryGroup = true; + + using (var form = new Form()) + using (var view = new WaveImpactAsphaltCoverFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism)) + { + form.Controls.Add(view); + form.Show(); + + FailureMechanismAssemblyCategoryGroupControl failureMechanismAssemblyControl = GetFailureMechanismAssemblyControl(); + ErrorProvider warningProvider = GetWarningProvider(failureMechanismAssemblyControl); + + // Call + string warningMessage = warningProvider.GetError(failureMechanismAssemblyControl); + + // Assert + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningMessage); + } + } + + [Test] + public void GivenFailureMechanismResultsViewWithWarnings_WhenFailureMechanismWithoutManualSectionAssemblyResultsAndFailureMechanismNotifiesObservers_ThenWarningCleared() + { + // Given + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyCategoryGroup = true; + + using (var form = new Form()) + using (var view = new WaveImpactAsphaltCoverFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism)) + { + form.Controls.Add(view); + form.Show(); + + FailureMechanismAssemblyCategoryGroupControl failureMechanismAssemblyControl = GetFailureMechanismAssemblyControl(); + ErrorProvider warningProvider = GetWarningProvider(failureMechanismAssemblyControl); + + // Precondition + Assert.AreEqual("Toetsoordeel is (deels) gebaseerd op handmatig overschreven toetsoordelen.", warningProvider.GetError(failureMechanismAssemblyControl)); + + // When + failureMechanism.SectionResults.ForEachElementDo(sr => sr.UseManualAssemblyCategoryGroup = false); + failureMechanism.NotifyObservers(); + + // Then + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class WaveImpactAsphaltCoverFailureMechanismResultControlTest : FailureMechanismAssemblyCategoryGroupControlTestFixture< WaveImpactAsphaltCoverFailureMechanismResultView, @@ -181,5 +240,16 @@ failureMechanism); } } + + private static FailureMechanismAssemblyCategoryGroupControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyCategoryGroupControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyCategoryGroupControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file