Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresScenariosContext.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r5806d848c8b646e450f092324efed255053413c7 --- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresScenariosContext.cs (.../StabilityPointStructuresScenariosContext.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Forms/PresentationObjects/StabilityPointStructuresScenariosContext.cs (.../StabilityPointStructuresScenariosContext.cs) (revision 5806d848c8b646e450f092324efed255053413c7) @@ -21,6 +21,7 @@ using System; using Core.Common.Controls.PresentationObjects; +using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.Calculation; using Riskeer.StabilityPointStructures.Data; @@ -37,21 +38,34 @@ /// /// The wrapped . /// A forming the context. + /// The the belongs to. /// Thrown when any parameter is null. - public StabilityPointStructuresScenariosContext(CalculationGroup wrappedData, StabilityPointStructuresFailureMechanism failureMechanism) + public StabilityPointStructuresScenariosContext(CalculationGroup wrappedData, StabilityPointStructuresFailureMechanism 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 StabilityPointStructuresFailureMechanism ParentFailureMechanism { get; } + + /// + /// Gets the of the calculation group. + /// + public IAssessmentSection AssessmentSection { get; } } } \ No newline at end of file Index: Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -rb0021e52ef17e3101d6e7089e3052ceb4621f3fe -r5806d848c8b646e450f092324efed255053413c7 --- Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision b0021e52ef17e3101d6e7089e3052ceb4621f3fe) +++ Riskeer/StabilityPointStructures/src/Riskeer.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 5806d848c8b646e450f092324efed255053413c7) @@ -371,7 +371,7 @@ return new object[] { new FailureMechanismAssemblyCategoriesContext(failureMechanism, assessmentSection, () => failureMechanism.GeneralInput.N), - new StabilityPointStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), + new StabilityPointStructuresScenariosContext(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection), new ProbabilityFailureMechanismSectionResultContext( failureMechanism.SectionResults, failureMechanism, assessmentSection), failureMechanism.OutputComments Index: Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresScenariosContextTest.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r5806d848c8b646e450f092324efed255053413c7 --- Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresScenariosContextTest.cs (.../StabilityPointStructuresScenariosContextTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Forms.Test/PresentationObjects/StabilityPointStructuresScenariosContextTest.cs (.../StabilityPointStructuresScenariosContextTest.cs) (revision 5806d848c8b646e450f092324efed255053413c7) @@ -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.StabilityPointStructures.Data; using Riskeer.StabilityPointStructures.Forms.PresentationObjects; @@ -35,30 +37,52 @@ public void Constructor_FailureMechanismNull_ThrowArgumentNullException() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var calculationGroup = new CalculationGroup(); // Call - TestDelegate test = () => new StabilityPointStructuresScenariosContext(calculationGroup, null); + void Call() => new StabilityPointStructuresScenariosContext(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 StabilityPointStructuresScenariosContext(new CalculationGroup(), new StabilityPointStructuresFailureMechanism(), 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 StabilityPointStructuresFailureMechanism(); // Call - var context = new StabilityPointStructuresScenariosContext(calculationGroup, failureMechanism); + var context = new StabilityPointStructuresScenariosContext(calculationGroup, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf>(context); Assert.AreSame(calculationGroup, context.WrappedData); Assert.AreSame(failureMechanism, context.ParentFailureMechanism); + Assert.AreSame(assessmentSection, context.AssessmentSection); + mocks.VerifyAll(); } } } \ No newline at end of file Index: Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresScenariosViewInfoTest.cs =================================================================== diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -r5806d848c8b646e450f092324efed255053413c7 --- Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresScenariosViewInfoTest.cs (.../StabilityPointStructuresScenariosViewInfoTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea) +++ Riskeer/StabilityPointStructures/test/Riskeer.StabilityPointStructures.Plugin.Test/ViewInfos/StabilityPointStructuresScenariosViewInfoTest.cs (.../StabilityPointStructuresScenariosViewInfoTest.cs) (revision 5806d848c8b646e450f092324efed255053413c7) @@ -78,15 +78,19 @@ public void GetViewData_Always_ReturnWrappedData() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var calculationGroup = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var context = new StabilityPointStructuresScenariosContext(calculationGroup, failureMechanism); + var context = new StabilityPointStructuresScenariosContext(calculationGroup, failureMechanism, assessmentSection); // Call object viewData = info.GetViewData(context); // Assert Assert.AreSame(calculationGroup, viewData); + mocks.VerifyAll(); } [Test] @@ -103,18 +107,22 @@ public void AfterCreate_Always_SetsSpecificPropertiesToView() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + using (var view = new StabilityPointStructuresScenariosView()) { var group = new CalculationGroup(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); - var context = new StabilityPointStructuresScenariosContext(group, failureMechanism); + var context = new StabilityPointStructuresScenariosContext(group, failureMechanism, assessmentSection); // Call info.AfterCreate(view, context); // Assert Assert.AreSame(failureMechanism, view.FailureMechanism); } + mocks.VerifyAll(); } [Test]