Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismResultView.cs =================================================================== diff -u -r17f4a44cd541127f016ee7653cec93f7d9310cbc -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismResultView.cs (.../ClosingStructuresFailureMechanismResultView.cs) (revision 17f4a44cd541127f016ee7653cec93f7d9310cbc) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismResultView.cs (.../ClosingStructuresFailureMechanismResultView.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -181,5 +181,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(ClosingStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection)); } + + protected override bool HasManualAssemblyResults() + { + return ClosingStructuresFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj =================================================================== diff -u -rf660bc78862427ea73890eefda1cc10d8e514b59 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision f660bc78862427ea73890eefda1cc10d8e514b59) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Ringtoets.ClosingStructures.Forms.Test.csproj (.../Ringtoets.ClosingStructures.Forms.Test.csproj) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -62,6 +62,10 @@ {30E4C2AE-719E-4D70-9FA9-668A9767FBFA} Core.Common.Gui + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Util + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -r88a54829a0338f02115f9c6a6728c101c3244624 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision 88a54829a0338f02115f9c6a6728c101c3244624) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -20,8 +20,11 @@ // All rights reserved. using System; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -203,6 +206,52 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new ClosingStructuresFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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 ClosingStructuresFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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.UseManualAssemblyProbability = false); + failureMechanism.NotifyObservers(); + + // Assert + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class ClosingStructuresFailureMechanismAssemblyControlTest : FailureMechanismAssemblyResultWithProbabilityControlTestFixture< ClosingStructuresFailureMechanismResultView, @@ -235,5 +284,27 @@ return failureMechanismResultView; } + + private ClosingStructuresFailureMechanismResultView ShowFailureMechanismResultsView(ClosingStructuresFailureMechanism failureMechanism) + { + var failureMechanismResultView = new ClosingStructuresFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism, + new AssessmentSectionStub()); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static FailureMechanismAssemblyControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs =================================================================== diff -u -r17f4a44cd541127f016ee7653cec93f7d9310cbc -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision 17f4a44cd541127f016ee7653cec93f7d9310cbc) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismResultView.cs (.../GrassCoverErosionInwardsFailureMechanismResultView.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -181,5 +181,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(GrassCoverErosionInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection)); } + + protected override bool HasManualAssemblyResults() + { + return GrassCoverErosionInwardsFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs =================================================================== diff -u -r88a54829a0338f02115f9c6a6728c101c3244624 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismResultViewTest.cs) (revision 88a54829a0338f02115f9c6a6728c101c3244624) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismResultViewTest.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -20,8 +20,11 @@ // All rights reserved. using System; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -202,6 +205,52 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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 GrassCoverErosionInwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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.UseManualAssemblyProbability = false); + failureMechanism.NotifyObservers(); + + // Assert + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class GrassCoverErosionInwardsFailureMechanismAssemblyControlTest : FailureMechanismAssemblyResultWithProbabilityControlTestFixture< GrassCoverErosionInwardsFailureMechanismResultView, @@ -234,5 +283,27 @@ return failureMechanismResultView; } + + private GrassCoverErosionInwardsFailureMechanismResultView ShowFailureMechanismResultsView(GrassCoverErosionInwardsFailureMechanism failureMechanism) + { + var failureMechanismResultView = new GrassCoverErosionInwardsFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism, + new AssessmentSectionStub()); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static FailureMechanismAssemblyControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs =================================================================== diff -u -r17f4a44cd541127f016ee7653cec93f7d9310cbc -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs (.../HeightStructuresFailureMechanismResultView.cs) (revision 17f4a44cd541127f016ee7653cec93f7d9310cbc) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismResultView.cs (.../HeightStructuresFailureMechanismResultView.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -183,5 +183,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(HeightStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection)); } + + protected override bool HasManualAssemblyResults() + { + return HeightStructuresFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj =================================================================== diff -u -r495994fbb603e99db4438adb9bd0a7609404f139 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision 495994fbb603e99db4438adb9bd0a7609404f139) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Ringtoets.HeightStructures.Forms.Test.csproj (.../Ringtoets.HeightStructures.Forms.Test.csproj) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -62,6 +62,10 @@ {30e4c2ae-719e-4d70-9fa9-668a9767fbfa} Core.Common.Gui + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Util + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -r88a54829a0338f02115f9c6a6728c101c3244624 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs (.../HeightStructuresFailureMechanismResultViewTest.cs) (revision 88a54829a0338f02115f9c6a6728c101c3244624) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs (.../HeightStructuresFailureMechanismResultViewTest.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -20,8 +20,11 @@ // All rights reserved. using System; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -204,6 +207,52 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new HeightStructuresFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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 HeightStructuresFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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.UseManualAssemblyProbability = false); + failureMechanism.NotifyObservers(); + + // Assert + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class HeightStructuresFailureMechanismAssemblyControlTest : FailureMechanismAssemblyResultWithProbabilityControlTestFixture< HeightStructuresFailureMechanismResultView, @@ -236,5 +285,27 @@ return failureMechanismResultView; } + + private HeightStructuresFailureMechanismResultView ShowFailureMechanismResultsView(HeightStructuresFailureMechanism failureMechanism) + { + var failureMechanismResultView = new HeightStructuresFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism, + new AssessmentSectionStub()); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static FailureMechanismAssemblyControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismResultView.cs =================================================================== diff -u -r17f4a44cd541127f016ee7653cec93f7d9310cbc -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismResultView.cs (.../MacroStabilityInwardsFailureMechanismResultView.cs) (revision 17f4a44cd541127f016ee7653cec93f7d9310cbc) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismResultView.cs (.../MacroStabilityInwardsFailureMechanismResultView.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -181,5 +181,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(MacroStabilityInwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection)); } + + protected override bool HasManualAssemblyResults() + { + return MacroStabilityInwardsFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs =================================================================== diff -u -r88a54829a0338f02115f9c6a6728c101c3244624 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs (.../MacroStabilityInwardsFailureMechanismResultViewTest.cs) (revision 88a54829a0338f02115f9c6a6728c101c3244624) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs (.../MacroStabilityInwardsFailureMechanismResultViewTest.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -20,8 +20,11 @@ // All rights reserved. using System; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -205,6 +208,52 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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 MacroStabilityInwardsFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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.UseManualAssemblyProbability = false); + failureMechanism.NotifyObservers(); + + // Assert + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class MacroStabilityInwardsFailureMechanismAssemblyControlTest : FailureMechanismAssemblyResultWithProbabilityControlTestFixture< MacroStabilityInwardsFailureMechanismResultView, @@ -236,5 +285,27 @@ return failureMechanismResultView; } + + private MacroStabilityInwardsFailureMechanismResultView ShowFailureMechanismResultsView(MacroStabilityInwardsFailureMechanism failureMechanism) + { + var failureMechanismResultView = new MacroStabilityInwardsFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism, + new AssessmentSectionStub()); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static FailureMechanismAssemblyControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs =================================================================== diff -u -r17f4a44cd541127f016ee7653cec93f7d9310cbc -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision 17f4a44cd541127f016ee7653cec93f7d9310cbc) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismResultView.cs (.../PipingFailureMechanismResultView.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -180,5 +180,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(PipingFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection)); } + + protected override bool HasManualAssemblyResults() + { + return PipingFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs =================================================================== diff -u -r88a54829a0338f02115f9c6a6728c101c3244624 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs (.../PipingFailureMechanismResultViewTest.cs) (revision 88a54829a0338f02115f9c6a6728c101c3244624) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs (.../PipingFailureMechanismResultViewTest.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -20,8 +20,11 @@ // All rights reserved. using System; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -205,6 +208,52 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new PipingFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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 PipingFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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.UseManualAssemblyProbability = false); + failureMechanism.NotifyObservers(); + + // Assert + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class PipingFailureMechanismAssemblyControlTest : FailureMechanismAssemblyResultWithProbabilityControlTestFixture< PipingFailureMechanismResultView, @@ -236,5 +285,27 @@ return failureMechanismResultView; } + + private PipingFailureMechanismResultView ShowFailureMechanismResultsView(PipingFailureMechanism failureMechanism) + { + var failureMechanismResultView = new PipingFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism, + new AssessmentSectionStub()); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static FailureMechanismAssemblyControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs =================================================================== diff -u -r17f4a44cd541127f016ee7653cec93f7d9310cbc -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs (.../StabilityPointStructuresFailureMechanismResultView.cs) (revision 17f4a44cd541127f016ee7653cec93f7d9310cbc) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismResultView.cs (.../StabilityPointStructuresFailureMechanismResultView.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -183,5 +183,10 @@ { FailureMechanismAssemblyResultControl.SetAssemblyResult(StabilityPointStructuresFailureMechanismAssemblyFactory.AssembleFailureMechanism(FailureMechanism, assessmentSection)); } + + protected override bool HasManualAssemblyResults() + { + return StabilityPointStructuresFailureMechanismHelper.HasManualAssemblyResults(FailureMechanism); + } } } \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj =================================================================== diff -u -rcc86af18cc63f07d517312739393ea51c258bbb9 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj (.../Ringtoets.StabilityPointStructures.Forms.Test.csproj) (revision cc86af18cc63f07d517312739393ea51c258bbb9) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Ringtoets.StabilityPointStructures.Forms.Test.csproj (.../Ringtoets.StabilityPointStructures.Forms.Test.csproj) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -62,6 +62,10 @@ {30E4C2AE-719E-4D70-9FA9-668A9767FBFA} Core.Common.Gui + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Util + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -r88a54829a0338f02115f9c6a6728c101c3244624 -re2d3933efb7550b981eb917efa5e7ff68786138b --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs (.../StabilityPointStructuresFailureMechanismResultViewTest.cs) (revision 88a54829a0338f02115f9c6a6728c101c3244624) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs (.../StabilityPointStructuresFailureMechanismResultViewTest.cs) (revision e2d3933efb7550b981eb917efa5e7ff68786138b) @@ -20,8 +20,11 @@ // All rights reserved. using System; +using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Util.Extensions; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -206,6 +209,52 @@ } } + [Test] + public void FailureMechanismResultView_WithFailureMechanismWithManualSectionAssemblyResults_ThenWarningSet() + { + // Setup + var failureMechanism = new StabilityPointStructuresFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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 StabilityPointStructuresFailureMechanism(); + FailureMechanismTestHelper.AddSections(failureMechanism, 2); + failureMechanism.SectionResults.First().UseManualAssemblyProbability = true; + + using (ShowFailureMechanismResultsView(failureMechanism)) + { + FailureMechanismAssemblyControl 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.UseManualAssemblyProbability = false); + failureMechanism.NotifyObservers(); + + // Assert + Assert.IsEmpty(warningProvider.GetError(failureMechanismAssemblyControl)); + } + } + [TestFixture] public class StabilityPointStructuresFailureMechanismAssemblyControlTest : FailureMechanismAssemblyResultWithProbabilityControlTestFixture< StabilityPointStructuresFailureMechanismResultView, @@ -238,5 +287,27 @@ return failureMechanismResultView; } + + private StabilityPointStructuresFailureMechanismResultView ShowFailureMechanismResultsView(StabilityPointStructuresFailureMechanism failureMechanism) + { + var failureMechanismResultView = new StabilityPointStructuresFailureMechanismResultView(failureMechanism.SectionResults, + failureMechanism, + new AssessmentSectionStub()); + testForm.Controls.Add(failureMechanismResultView); + testForm.Show(); + + return failureMechanismResultView; + } + + private static FailureMechanismAssemblyControl GetFailureMechanismAssemblyControl() + { + var control = (FailureMechanismAssemblyControl) ((TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject).GetControlFromPosition(1, 0); + return control; + } + + private static ErrorProvider GetWarningProvider(FailureMechanismAssemblyControl control) + { + return TypeUtils.GetField(control, "warningProvider"); + } } } \ No newline at end of file