Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/HeightStructuresScenariosContext.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r33b37f9cbd7e2b5664fc666dab41ddd424ed3818
--- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/HeightStructuresScenariosContext.cs (.../HeightStructuresScenariosContext.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Forms/PresentationObjects/HeightStructuresScenariosContext.cs (.../HeightStructuresScenariosContext.cs) (revision 33b37f9cbd7e2b5664fc666dab41ddd424ed3818)
@@ -21,6 +21,7 @@
using System;
using Core.Common.Controls.PresentationObjects;
+using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Calculation;
using Riskeer.HeightStructures.Data;
@@ -37,21 +38,34 @@
///
/// The wrapped .
/// A forming the context.
+ /// The the belongs to.
/// Thrown when any parameter is null.
- public HeightStructuresScenariosContext(CalculationGroup wrappedData, HeightStructuresFailureMechanism failureMechanism)
+ public HeightStructuresScenariosContext(CalculationGroup wrappedData, HeightStructuresFailureMechanism failureMechanism,
+ IAssessmentSection assessmentSection)
: base(wrappedData)
{
if (failureMechanism == null)
{
throw new ArgumentNullException(nameof(failureMechanism));
}
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
ParentFailureMechanism = failureMechanism;
+ AssessmentSection = assessmentSection;
}
///
/// The parent failure mechanism of the calculation group.
///
public HeightStructuresFailureMechanism ParentFailureMechanism { get; }
+
+ ///
+ /// Gets the of the calculation group.
+ ///
+ public IAssessmentSection AssessmentSection { get; }
}
}
\ No newline at end of file
Index: Riskeer/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs
===================================================================
diff -u -rd1c333df3a55ad8baba0d1cc0c4cff54c69668d7 -r33b37f9cbd7e2b5664fc666dab41ddd424ed3818
--- Riskeer/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision d1c333df3a55ad8baba0d1cc0c4cff54c69668d7)
+++ Riskeer/HeightStructures/src/Riskeer.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 33b37f9cbd7e2b5664fc666dab41ddd424ed3818)
@@ -359,7 +359,7 @@
return new object[]
{
new FailureMechanismAssemblyCategoriesContext(failureMechanism, assessmentSection, () => failureMechanism.GeneralInput.N),
- new HeightStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism),
+ new HeightStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection),
new ProbabilityFailureMechanismSectionResultContext(
failureMechanism.SectionResults, failureMechanism, assessmentSection),
failureMechanism.OutputComments
Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresScenariosContextTest.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r33b37f9cbd7e2b5664fc666dab41ddd424ed3818
--- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresScenariosContextTest.cs (.../HeightStructuresScenariosContextTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Forms.Test/PresentationObjects/HeightStructuresScenariosContextTest.cs (.../HeightStructuresScenariosContextTest.cs) (revision 33b37f9cbd7e2b5664fc666dab41ddd424ed3818)
@@ -22,6 +22,8 @@
using System;
using Core.Common.Controls.PresentationObjects;
using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.AssessmentSection;
using Riskeer.Common.Data.Calculation;
using Riskeer.HeightStructures.Data;
using Riskeer.HeightStructures.Forms.PresentationObjects;
@@ -35,30 +37,51 @@
public void Constructor_FailureMechanismNull_ThrowArgumentNullException()
{
// Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
var calculationGroup = new CalculationGroup();
// Call
- TestDelegate test = () => new HeightStructuresScenariosContext(calculationGroup, null);
+ void Call() => new HeightStructuresScenariosContext(calculationGroup, null, assessmentSection);
// Assert
- var exception = Assert.Throws(test);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("failureMechanism", exception.ParamName);
+ mocks.VerifyAll();
}
[Test]
+ public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => new HeightStructuresScenariosContext(new CalculationGroup(), new HeightStructuresFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
public void Constructor_ExpectedValues()
{
// Setup
+ var mocks = new MockRepository();
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
var calculationGroup = new CalculationGroup();
var failureMechanism = new HeightStructuresFailureMechanism();
// Call
- var context = new HeightStructuresScenariosContext(calculationGroup, failureMechanism);
+ var context = new HeightStructuresScenariosContext(calculationGroup, failureMechanism, assessmentSection);
// Assert
Assert.IsInstanceOf>(context);
Assert.AreSame(calculationGroup, context.WrappedData);
Assert.AreSame(failureMechanism, context.ParentFailureMechanism);
+ mocks.VerifyAll();
}
}
}
\ No newline at end of file
Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresScenariosContextTreeNodeInfoTest.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r33b37f9cbd7e2b5664fc666dab41ddd424ed3818
--- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresScenariosContextTreeNodeInfoTest.cs (.../HeightStructuresScenariosContextTreeNodeInfoTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/TreeNodeInfos/HeightStructuresScenariosContextTreeNodeInfoTest.cs (.../HeightStructuresScenariosContextTreeNodeInfoTest.cs) (revision 33b37f9cbd7e2b5664fc666dab41ddd424ed3818)
@@ -27,8 +27,6 @@
using Core.Common.TestUtil;
using NUnit.Framework;
using Rhino.Mocks;
-using Riskeer.Common.Data.Calculation;
-using Riskeer.HeightStructures.Data;
using Riskeer.HeightStructures.Forms.PresentationObjects;
using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
@@ -80,13 +78,8 @@
[Test]
public void Text_Always_ReturnScenarios()
{
- // Setup
- var group = new CalculationGroup();
- var failureMechanism = new HeightStructuresFailureMechanism();
- var context = new HeightStructuresScenariosContext(group, failureMechanism);
-
// Call
- string text = info.Text(context);
+ string text = info.Text(null);
// Assert
Assert.AreEqual("Scenario's", text);
@@ -95,13 +88,8 @@
[Test]
public void Image_Always_ReturnExpectedImage()
{
- // Setup
- var group = new CalculationGroup();
- var failureMechanism = new HeightStructuresFailureMechanism();
- var context = new HeightStructuresScenariosContext(group, failureMechanism);
-
// Call
- Image image = info.Image(context);
+ Image image = info.Image(null);
// Assert
TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.ScenariosIcon, image);
@@ -113,10 +101,6 @@
// Setup
using (var treeViewControl = new TreeViewControl())
{
- var group = new CalculationGroup();
- var failureMechanism = new HeightStructuresFailureMechanism();
- var context = new HeightStructuresScenariosContext(group, failureMechanism);
-
var mocks = new MockRepository();
var menuBuilder = mocks.StrictMock();
@@ -127,14 +111,14 @@
}
var gui = mocks.Stub();
- gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
+ gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder);
mocks.ReplayAll();
plugin.Gui = gui;
// Call
- info.ContextMenuStrip(context, null, treeViewControl);
+ info.ContextMenuStrip(null, null, treeViewControl);
// Assert
mocks.VerifyAll();
Index: Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresScenariosViewInfoTest.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r33b37f9cbd7e2b5664fc666dab41ddd424ed3818
--- Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresScenariosViewInfoTest.cs (.../HeightStructuresScenariosViewInfoTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/HeightStructures/test/Riskeer.HeightStructures.Plugin.Test/ViewInfos/HeightStructuresScenariosViewInfoTest.cs (.../HeightStructuresScenariosViewInfoTest.cs) (revision 33b37f9cbd7e2b5664fc666dab41ddd424ed3818)
@@ -78,15 +78,19 @@
public void GetViewData_Always_ReturnWrappedData()
{
// Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
var calculationGroup = new CalculationGroup();
var failureMechanism = new HeightStructuresFailureMechanism();
- var context = new HeightStructuresScenariosContext(calculationGroup, failureMechanism);
+ var context = new HeightStructuresScenariosContext(calculationGroup, failureMechanism, assessmentSection);
// Call
object viewData = info.GetViewData(context);
// Assert
Assert.AreSame(calculationGroup, viewData);
+ mocks.VerifyAll();
}
[Test]
@@ -366,18 +370,23 @@
public void AfterCreate_Always_SetsSpecificPropertiesToView()
{
// Setup
+ var assessmentSection = mocks.Stub();
+ mocks.ReplayAll();
+
using (var view = new HeightStructuresScenariosView())
{
var group = new CalculationGroup();
var failureMechanism = new HeightStructuresFailureMechanism();
- var context = new HeightStructuresScenariosContext(group, failureMechanism);
+ var context = new HeightStructuresScenariosContext(group, failureMechanism, assessmentSection);
// Call
info.AfterCreate(view, context);
// Assert
Assert.AreSame(failureMechanism, view.FailureMechanism);
}
+
+ mocks.VerifyAll();
}
}
}
\ No newline at end of file