Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs
===================================================================
diff -u -r15094551c745a25dca86ad12e8cc75ab5cdc8d73 -r5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da
--- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision 15094551c745a25dca86ad12e8cc75ab5cdc8d73)
+++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da)
@@ -202,7 +202,7 @@
}
[TestFixture]
- public class ClosingStructuresFailureMechanismResultWithProbabilityTest : FailureMechanismResultWithProbabilityTester<
+ public class ClosingStructuresFailureMechanismAssemblyResultWithProbabilityControlTest : FailureMechanismAssemblyResultWithProbabilityControlTester<
ClosingStructuresFailureMechanismResultView,
ClosingStructuresFailureMechanism,
ClosingStructuresFailureMechanismSectionResult,
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/FailureMechanismAssemblyResultWithProbabilityControlTester.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/FailureMechanismAssemblyResultWithProbabilityControlTester.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/FailureMechanismAssemblyResultWithProbabilityControlTester.cs (revision 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da)
@@ -0,0 +1,222 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System.Drawing;
+using System.Linq;
+using System.Windows.Forms;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Ringtoets.AssemblyTool.Data;
+using Ringtoets.AssemblyTool.KernelWrapper.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators;
+using Ringtoets.AssemblyTool.KernelWrapper.TestUtil.Calculators.Assembly;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.Controls;
+using Ringtoets.Common.Forms.Views;
+
+namespace Ringtoets.Common.Forms.TestUtil
+{
+ ///
+ /// Class for testing data and styling in a view with a .
+ ///
+ /// The type of the view to test.
+ /// The type of the failure mechanism the view belongs to.
+ /// The type of the section results shown in the view.
+ /// The type of the presentation objects used in the view.
+ /// The type of calculations to get the input from.
+ /// The type of the input of a calculation.
+ public abstract class FailureMechanismAssemblyResultWithProbabilityControlTester
+ where TView : FailureMechanismResultView
+ where TFailureMechanism : IFailureMechanism, IHasSectionResults, ICalculatableFailureMechanism, new()
+ where TSectionResult : FailureMechanismSectionResult
+ where TResultRow : FailureMechanismSectionResultRow
+ where TCalculation : ICalculation
+ where TCalculationInput : ICalculationInput
+ {
+ private Form testForm;
+
+ [SetUp]
+ public void Setup()
+ {
+ testForm = new Form();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ testForm.Dispose();
+ }
+
+ [Test]
+ public void FailureMechanismResultsView_Always_FailureMechanismResultControlCorrectlyInitialized()
+ {
+ // Setup
+ var failureMechanism = new TFailureMechanism();
+ failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ // Call
+ using (new AssemblyToolCalculatorFactoryConfig())
+ using (ShowFailureMechanismResultsView(failureMechanism))
+ {
+ // Assert
+ var assemblyResultPanel = (TableLayoutPanel) new ControlTester("TableLayoutPanel").TheObject;
+ var assemblyResultControl = (FailureMechanismAssemblyResultWithProbabilityControl) assemblyResultPanel.GetControlFromPosition(0, 0);
+
+ Assert.IsInstanceOf(assemblyResultControl);
+ Assert.AreEqual(DockStyle.Left, assemblyResultControl.Dock);
+ }
+ }
+
+ [Test]
+ public void GivenFailureMechanismResultsView_WhenResultChangedAndSectionResultNotified_FailureMechanismAssemblyResultUpdated()
+ {
+ // Given
+ var failureMechanism = new TFailureMechanism();
+ failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ using (ShowFailureMechanismResultsView(failureMechanism))
+ {
+ // Precondition
+ BoxedLabel assemblyGroupLabel = GetGroupLabel();
+ BoxedLabel assemblyProbabilityLabel = GetProbabilityLabelControl();
+ Assert.AreEqual("1/1", assemblyProbabilityLabel.Text);
+ Assert.AreEqual("IIIt", assemblyGroupLabel.Text);
+ Assert.AreEqual(Color.FromArgb(255, 255, 0), assemblyGroupLabel.BackColor);
+
+ // When
+ var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator;
+ calculator.FailureMechanismAssemblyOutput = new FailureMechanismAssembly(0.5, FailureMechanismAssemblyCategoryGroup.VIt);
+ failureMechanism.SectionResults.Single().NotifyObservers();
+
+ // Assert
+ Assert.AreEqual("1/2", assemblyProbabilityLabel.Text);
+ Assert.AreEqual("VIt", assemblyGroupLabel.Text);
+ Assert.AreEqual(Color.FromArgb(255, 0, 0), assemblyGroupLabel.BackColor);
+ }
+ }
+
+ [Test]
+ public void GivenFailureMechanismResultsView_WhenResultChangedAndCalculationNotified_FailureMechanismAssemblyResultUpdated()
+ {
+ // Given
+ var failureMechanism = new TFailureMechanism();
+ TCalculation calculation = CreateCalculation();
+ failureMechanism.CalculationsGroup.Children.Add(calculation);
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ using (ShowFailureMechanismResultsView(failureMechanism))
+ {
+ // Precondition
+ BoxedLabel assemblyGroupLabel = GetGroupLabel();
+ BoxedLabel assemblyProbabilityLabel = GetProbabilityLabelControl();
+ Assert.AreEqual("1/1", assemblyProbabilityLabel.Text);
+ Assert.AreEqual("IIIt", assemblyGroupLabel.Text);
+ Assert.AreEqual(Color.FromArgb(255, 255, 0), assemblyGroupLabel.BackColor);
+
+ // When
+ var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator;
+ calculator.FailureMechanismAssemblyOutput = new FailureMechanismAssembly(0.5, FailureMechanismAssemblyCategoryGroup.VIt);
+ calculation.NotifyObservers();
+
+ // Assert
+ Assert.AreEqual("1/2", assemblyProbabilityLabel.Text);
+ Assert.AreEqual("VIt", assemblyGroupLabel.Text);
+ Assert.AreEqual(Color.FromArgb(255, 0, 0), assemblyGroupLabel.BackColor);
+ }
+ }
+
+ [Test]
+ public void GivenFailureMechanismResultsView_WhenResultChangedAndCalculationInputNotified_FailureMechanismAssemblyResultUpdated()
+ {
+ // Given
+ var failureMechanism = new TFailureMechanism();
+ TCalculation calculation = CreateCalculation();
+ failureMechanism.CalculationsGroup.Children.Add(calculation);
+
+ using (new AssemblyToolCalculatorFactoryConfig())
+ using (ShowFailureMechanismResultsView(failureMechanism))
+ {
+ // Precondition
+ BoxedLabel assemblyGroupLabel = GetGroupLabel();
+ BoxedLabel assemblyProbabilityLabel = GetProbabilityLabelControl();
+ Assert.AreEqual("1/1", assemblyProbabilityLabel.Text);
+ Assert.AreEqual("IIIt", assemblyGroupLabel.Text);
+ Assert.AreEqual(Color.FromArgb(255, 255, 0), assemblyGroupLabel.BackColor);
+
+ // When
+ var calculatorfactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance;
+ FailureMechanismAssemblyCalculatorStub calculator = calculatorfactory.LastCreatedFailureMechanismAssemblyCalculator;
+ calculator.FailureMechanismAssemblyOutput = new FailureMechanismAssembly(0.5, FailureMechanismAssemblyCategoryGroup.VIt);
+ GetInput(failureMechanism.CalculationsGroup.Children.Cast().Single()).NotifyObservers();
+
+ // Assert
+ Assert.AreEqual("1/2", assemblyProbabilityLabel.Text);
+ Assert.AreEqual("VIt", assemblyGroupLabel.Text);
+ Assert.AreEqual(Color.FromArgb(255, 0, 0), assemblyGroupLabel.BackColor);
+ }
+ }
+
+ ///
+ /// Method for creating an instance of .
+ ///
+ /// The failure mechanism to create the view for.
+ /// A new .
+ protected abstract TView CreateResultView(TFailureMechanism failureMechanism);
+
+ ///
+ /// Method for creating an instance of .
+ ///
+ /// A new .
+ protected abstract TCalculation CreateCalculation();
+
+ ///
+ /// Method to get the from a
+ /// .
+ ///
+ /// The calculation to get the input from.
+ /// A new .
+ protected abstract TCalculationInput GetInput(TCalculation calculation);
+
+ private static BoxedLabel GetGroupLabel()
+ {
+ return (BoxedLabel) new ControlTester("GroupLabel").TheObject;
+ }
+
+ private static BoxedLabel GetProbabilityLabelControl()
+ {
+ return (BoxedLabel) new ControlTester("probabilityLabel").TheObject;
+ }
+
+ private TView ShowFailureMechanismResultsView(TFailureMechanism failureMechanism)
+ {
+ TView failureMechanismResultView = CreateResultView(failureMechanism);
+ testForm.Controls.Add(failureMechanismResultView);
+ testForm.Show();
+
+ return failureMechanismResultView;
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/FailureMechanismResultWithProbabilityTester.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj
===================================================================
diff -u -re60b406f9fd3650c932fd61be311b14692079544 -r5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da
--- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj (.../Ringtoets.Common.Forms.TestUtil.csproj) (revision e60b406f9fd3650c932fd61be311b14692079544)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj (.../Ringtoets.Common.Forms.TestUtil.csproj) (revision 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da)
@@ -23,7 +23,7 @@
-
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs
===================================================================
diff -u -re7ceed448d10fb5240f13fb8660778f7843c8117 -r5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismResultViewTest.cs) (revision e7ceed448d10fb5240f13fb8660778f7843c8117)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionInwardsFailureMechanismResultViewTest.cs) (revision 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da)
@@ -201,7 +201,7 @@
}
[TestFixture]
- public class GrassCoverErosionInwardsFailureMechanismResultWithProbabilityTest : FailureMechanismResultWithProbabilityTester<
+ public class GrassCoverErosionInwardsFailureMechanismAssemblyResultWithProbabilityControlTest : FailureMechanismAssemblyResultWithProbabilityControlTester<
GrassCoverErosionInwardsFailureMechanismResultView,
GrassCoverErosionInwardsFailureMechanism,
GrassCoverErosionInwardsFailureMechanismSectionResult,
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs
===================================================================
diff -u -r09f6885c51ffd238626cba61f0dca4f23fd8d643 -r5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs (.../HeightStructuresFailureMechanismResultViewTest.cs) (revision 09f6885c51ffd238626cba61f0dca4f23fd8d643)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismResultViewTest.cs (.../HeightStructuresFailureMechanismResultViewTest.cs) (revision 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da)
@@ -203,7 +203,7 @@
}
[TestFixture]
- public class HeightStructuresFailureMechanismResultWithProbabilityTest : FailureMechanismResultWithProbabilityTester<
+ public class HeightStructuresFailureMechanismAssemblyResultWithProbabilityControlTest : FailureMechanismAssemblyResultWithProbabilityControlTester<
HeightStructuresFailureMechanismResultView,
HeightStructuresFailureMechanism,
HeightStructuresFailureMechanismSectionResult,
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs
===================================================================
diff -u -re7ceed448d10fb5240f13fb8660778f7843c8117 -r5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs (.../MacroStabilityInwardsFailureMechanismResultViewTest.cs) (revision e7ceed448d10fb5240f13fb8660778f7843c8117)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismResultViewTest.cs (.../MacroStabilityInwardsFailureMechanismResultViewTest.cs) (revision 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da)
@@ -202,7 +202,7 @@
}
[TestFixture]
- public class MacroStabilityInwardsFailureMechanismResultWithProbabilityTest : FailureMechanismResultWithProbabilityTester<
+ public class MacroStabilityInwardsFailureMechanismAssemblyResultWithProbabilityControlTest : FailureMechanismAssemblyResultWithProbabilityControlTester<
MacroStabilityInwardsFailureMechanismResultView,
MacroStabilityInwardsFailureMechanism,
MacroStabilityInwardsFailureMechanismSectionResult,
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs
===================================================================
diff -u -re7ceed448d10fb5240f13fb8660778f7843c8117 -r5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs (.../PipingFailureMechanismResultViewTest.cs) (revision e7ceed448d10fb5240f13fb8660778f7843c8117)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismResultViewTest.cs (.../PipingFailureMechanismResultViewTest.cs) (revision 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da)
@@ -202,7 +202,7 @@
}
[TestFixture]
- public class PipingFailureMechanismResultWithProbabilityTest : FailureMechanismResultWithProbabilityTester<
+ public class PipingFailureMechanismAssemblyResultWithProbabilityControlTest : FailureMechanismAssemblyResultWithProbabilityControlTester<
PipingFailureMechanismResultView,
PipingFailureMechanism,
PipingFailureMechanismSectionResult,
Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs
===================================================================
diff -u -r27496391b1c1359901764bec06c687a778be0031 -r5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da
--- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs (.../StabilityPointStructuresFailureMechanismResultViewTest.cs) (revision 27496391b1c1359901764bec06c687a778be0031)
+++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs (.../StabilityPointStructuresFailureMechanismResultViewTest.cs) (revision 5e48139fe1e5e5a7b54530bc42fcb1e0c0a3b9da)
@@ -204,7 +204,7 @@
}
[TestFixture]
- public class StabilityPointStructuresFailureMechanismResultWithProbabilityTest : FailureMechanismResultWithProbabilityTester<
+ public class StabilityPointStructuresFailureMechanismAssemblyResultWithProbabilityControlTest : FailureMechanismAssemblyResultWithProbabilityControlTester<
StabilityPointStructuresFailureMechanismResultView,
StabilityPointStructuresFailureMechanism,
StabilityPointStructuresFailureMechanismSectionResult,