Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PresentationObjects/MacroStabilityInwardsScenariosContext.cs =================================================================== diff -u -r566d36e29347b40381bff26e321334b5af07c367 -r5a67fdd92b4e69e1fde669dd27605d0eeaad734b --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PresentationObjects/MacroStabilityInwardsScenariosContext.cs (.../MacroStabilityInwardsScenariosContext.cs) (revision 566d36e29347b40381bff26e321334b5af07c367) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PresentationObjects/MacroStabilityInwardsScenariosContext.cs (.../MacroStabilityInwardsScenariosContext.cs) (revision 5a67fdd92b4e69e1fde669dd27605d0eeaad734b) @@ -21,6 +21,7 @@ using System; using Core.Common.Controls.PresentationObjects; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.MacroStabilityInwards.Data; @@ -35,21 +36,35 @@ /// Creates a new instance of . /// /// The wrapped . - /// A forming the context. + /// The failure mechanism that the calculation group belongs to. + /// The assessment section that the calculation group belongs to. /// Thrown when any parameter is null. - public MacroStabilityInwardsScenariosContext(CalculationGroup wrappedData, MacroStabilityInwardsFailureMechanism failureMechanism) + public MacroStabilityInwardsScenariosContext(CalculationGroup wrappedData, MacroStabilityInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) : base(wrappedData) { if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism)); } - ParentFailureMechanism = failureMechanism; + + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + FailureMechanism = failureMechanism; + AssessmentSection = assessmentSection; } /// /// Gets the parent failure mechanism of the calculation group. /// - public MacroStabilityInwardsFailureMechanism ParentFailureMechanism { get; } + public MacroStabilityInwardsFailureMechanism FailureMechanism { get; } + + /// + /// Gets the assessment section. + /// + public IAssessmentSection AssessmentSection { get; } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs =================================================================== diff -u -re38673ff639b5d86a2f55997e2d0d876ba4737f7 -r5a67fdd92b4e69e1fde669dd27605d0eeaad734b --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs (.../MacroStabilityInwardsScenariosView.cs) (revision e38673ff639b5d86a2f55997e2d0d876ba4737f7) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsScenariosView.cs (.../MacroStabilityInwardsScenariosView.cs) (revision 5a67fdd92b4e69e1fde669dd27605d0eeaad734b) @@ -26,6 +26,7 @@ using Core.Common.Base; using Core.Common.Base.Geometry; using Core.Common.Controls.Views; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.MacroStabilityInwards.Data; @@ -38,6 +39,7 @@ /// public partial class MacroStabilityInwardsScenariosView : UserControl, IView { + private readonly IAssessmentSection assessmentSection; private readonly RecursiveObserver inputObserver; private readonly RecursiveObserver calculationGroupObserver; private readonly RecursiveObserver calculationObserver; @@ -48,12 +50,22 @@ /// /// Creates a new instance of the class. /// - public MacroStabilityInwardsScenariosView() + /// The assessment section the scenarios belong to. + /// Thrown when + /// is null. + public MacroStabilityInwardsScenariosView(IAssessmentSection assessmentSection) { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + InitializeComponent(); InitializeDataGridView(); InitializeListBox(); + this.assessmentSection = assessmentSection; + failureMechanismObserver = new Observer(OnFailureMechanismUpdate); // The concat is needed to observe the input of calculations in child groups. @@ -169,7 +181,7 @@ List dataSource = calculations.Select(pc => new MacroStabilityInwardsScenarioRow( pc, MacroStabilityInwardsFailureMechanism, - null)).ToList(); + assessmentSection)).ToList(); dataGridViewControl.SetDataSource(dataSource); } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs =================================================================== diff -u -r0bc724e93170500800aa7e5d3bf641ab44eeeac7 -r5a67fdd92b4e69e1fde669dd27605d0eeaad734b --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 0bc724e93170500800aa7e5d3bf641ab44eeeac7) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 5a67fdd92b4e69e1fde669dd27605d0eeaad734b) @@ -249,9 +249,10 @@ GetViewData = context => context.WrappedData, GetViewName = (view, calculationGroup) => RingtoetsCommonFormsResources.Scenarios_DisplayName, Image = RingtoetsCommonFormsResources.ScenariosIcon, - AdditionalDataCheck = context => context.WrappedData == context.ParentFailureMechanism.CalculationsGroup, + AdditionalDataCheck = context => context.WrappedData == context.FailureMechanism.CalculationsGroup, CloseForData = CloseScenariosViewForData, - AfterCreate = (view, context) => { view.MacroStabilityInwardsFailureMechanism = context.ParentFailureMechanism; } + AfterCreate = (view, context) => { view.MacroStabilityInwardsFailureMechanism = context.FailureMechanism; }, + CreateInstance = context => new MacroStabilityInwardsScenariosView(context.AssessmentSection) }; yield return new ViewInfo @@ -686,7 +687,7 @@ { new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Inputs_DisplayName, GetInputs(wrappedData, macroStabilityInwardsFailureMechanismContext.Parent), TreeFolderCategory.Input), new MacroStabilityInwardsCalculationGroupContext(wrappedData.CalculationsGroup, null, wrappedData.SurfaceLines, wrappedData.StochasticSoilModels, wrappedData, macroStabilityInwardsFailureMechanismContext.Parent), - new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(wrappedData), TreeFolderCategory.Output) + new CategoryTreeFolder(RingtoetsCommonFormsResources.FailureMechanism_Outputs_DisplayName, GetOutputs(wrappedData, macroStabilityInwardsFailureMechanismContext.Parent), TreeFolderCategory.Output) }; } @@ -709,11 +710,11 @@ }; } - private static IEnumerable GetOutputs(MacroStabilityInwardsFailureMechanism failureMechanism) + private static IEnumerable GetOutputs(MacroStabilityInwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { return new object[] { - new MacroStabilityInwardsScenariosContext(failureMechanism.CalculationsGroup, failureMechanism), + new MacroStabilityInwardsScenariosContext(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection), new FailureMechanismSectionResultContext( failureMechanism.SectionResults, failureMechanism), failureMechanism.OutputComments Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PresentationObjects/MacroStabilityInwardsScenariosContextTest.cs =================================================================== diff -u -r5906f61fff270a7526253bea07dfecdf680898ed -r5a67fdd92b4e69e1fde669dd27605d0eeaad734b --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PresentationObjects/MacroStabilityInwardsScenariosContextTest.cs (.../MacroStabilityInwardsScenariosContextTest.cs) (revision 5906f61fff270a7526253bea07dfecdf680898ed) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PresentationObjects/MacroStabilityInwardsScenariosContextTest.cs (.../MacroStabilityInwardsScenariosContextTest.cs) (revision 5a67fdd92b4e69e1fde669dd27605d0eeaad734b) @@ -22,6 +22,8 @@ using System; using Core.Common.Controls.PresentationObjects; using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects; @@ -35,30 +37,56 @@ public void Constructor_ExpectedValues() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var calculationGroup = new CalculationGroup(); // Call - var context = new MacroStabilityInwardsScenariosContext(calculationGroup, failureMechanism); + var context = new MacroStabilityInwardsScenariosContext(calculationGroup, failureMechanism, assessmentSection); // Assert Assert.IsInstanceOf>(context); Assert.AreSame(calculationGroup, context.WrappedData); - Assert.AreSame(failureMechanism, context.ParentFailureMechanism); + Assert.AreSame(failureMechanism, context.FailureMechanism); + Assert.AreSame(assessmentSection, context.AssessmentSection); + mocks.VerifyAll(); } [Test] public void Constructor_FailuremechanismNull_ThrowArgumentNullException() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var calculationGroup = new CalculationGroup(); // Call - TestDelegate test = () => new MacroStabilityInwardsScenariosContext(calculationGroup, null); + TestDelegate test = () => new MacroStabilityInwardsScenariosContext(calculationGroup, null, assessmentSection); // Assert var exception = Assert.Throws(test); Assert.AreEqual("failureMechanism", exception.ParamName); + mocks.VerifyAll(); } + + [Test] + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Setup + var calculationGroup = new CalculationGroup(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + // Call + TestDelegate call = () => new MacroStabilityInwardsScenariosContext(calculationGroup, failureMechanism, null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsScenariosViewTest.cs =================================================================== diff -u -r49621ecdce5a2a8f7c8bb689e8cfd6759dfb8fc6 -r5a67fdd92b4e69e1fde669dd27605d0eeaad734b --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsScenariosViewTest.cs (.../MacroStabilityInwardsScenariosViewTest.cs) (revision 49621ecdce5a2a8f7c8bb689e8cfd6759dfb8fc6) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsScenariosViewTest.cs (.../MacroStabilityInwardsScenariosViewTest.cs) (revision 5a67fdd92b4e69e1fde669dd27605d0eeaad734b) @@ -31,10 +31,13 @@ using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.Helpers; using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Data.TestUtil; using Ringtoets.MacroStabilityInwards.Forms.Views; using Ringtoets.MacroStabilityInwards.Primitives; @@ -50,17 +53,34 @@ private Form testForm; [Test] - public void Constructor_DefaultValues() + public void Constructor_AssessmentSectionNull_ThrowsArgumentNullException() { // Call - using (var scenarioView = new MacroStabilityInwardsScenariosView()) + TestDelegate call = () => new MacroStabilityInwardsScenariosView(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(); + + // Call + using (var scenarioView = new MacroStabilityInwardsScenariosView(assessmentSection)) { // Assert Assert.IsInstanceOf(scenarioView); Assert.IsInstanceOf(scenarioView); Assert.IsNull(scenarioView.Data); Assert.IsNull(scenarioView.MacroStabilityInwardsFailureMechanism); } + mocks.VerifyAll(); } [Test] @@ -212,7 +232,7 @@ Assert.IsTrue(Convert.ToBoolean(cells[isRelevantColumnIndex].FormattedValue)); Assert.AreEqual(100.ToString(CultureInfo.CurrentCulture), cells[contributionColumnIndex].FormattedValue); Assert.AreEqual("Calculation 2", cells[nameColumnIndex].FormattedValue); - Assert.AreEqual(ProbabilityFormattingHelper.Format(1.5e-3), cells[failureProbabilityColumnIndex].FormattedValue); + Assert.AreEqual(ProbabilityFormattingHelper.Format(7.14e-2), cells[failureProbabilityColumnIndex].FormattedValue); } [Test] @@ -353,13 +373,7 @@ { SurfaceLine = surfaceLine2 }, - SemiProbabilisticOutput = new MacroStabilityInwardsSemiProbabilisticOutput( - double.NaN, - double.NaN, - double.NaN, - 1.5e-3, - double.NaN, - double.NaN) + Output = MacroStabilityInwardsOutputTestFactory.CreateRandomOutput() } } }; @@ -371,7 +385,7 @@ private MacroStabilityInwardsScenariosView ShowMacroStabilityInwardsScenarioView() { - var scenarioView = new MacroStabilityInwardsScenariosView(); + var scenarioView = new MacroStabilityInwardsScenariosView(new ObservableTestAssessmentSectionStub()); testForm.Controls.Add(scenarioView); testForm.Show(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest.cs =================================================================== diff -u -r6e4bf216d76f52ad3159a6cf1ab3ea38c2f17f28 -r5a67fdd92b4e69e1fde669dd27605d0eeaad734b --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 6e4bf216d76f52ad3159a6cf1ab3ea38c2f17f28) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest.cs (.../MacroStabilityInwardsFailureMechanismContextTreeNodeInfoTest.cs) (revision 5a67fdd92b4e69e1fde669dd27605d0eeaad734b) @@ -173,7 +173,7 @@ Assert.AreEqual(3, outputsFolder.Contents.Count()); var failureMechanismScenariosContext = (MacroStabilityInwardsScenariosContext) outputsFolder.Contents.ElementAt(0); - Assert.AreSame(failureMechanism, failureMechanismScenariosContext.ParentFailureMechanism); + Assert.AreSame(failureMechanism, failureMechanismScenariosContext.FailureMechanism); Assert.AreSame(failureMechanism.CalculationsGroup, failureMechanismScenariosContext.WrappedData); var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents.ElementAt(1); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsScenariosContextTreeNodeInfoTest.cs =================================================================== diff -u -r0d67fae590a8c774697ae6836565dc1a03cf451b -r5a67fdd92b4e69e1fde669dd27605d0eeaad734b --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsScenariosContextTreeNodeInfoTest.cs (.../MacroStabilityInwardsScenariosContextTreeNodeInfoTest.cs) (revision 0d67fae590a8c774697ae6836565dc1a03cf451b) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/TreeNodeInfos/MacroStabilityInwardsScenariosContextTreeNodeInfoTest.cs (.../MacroStabilityInwardsScenariosContextTreeNodeInfoTest.cs) (revision 5a67fdd92b4e69e1fde669dd27605d0eeaad734b) @@ -27,6 +27,7 @@ using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.Properties; using Ringtoets.MacroStabilityInwards.Data; @@ -81,48 +82,59 @@ public void Text_Always_ReturnScenarios() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var group = new CalculationGroup(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - var context = new MacroStabilityInwardsScenariosContext(group, failureMechanism); + var context = new MacroStabilityInwardsScenariosContext(group, failureMechanism, assessmentSection); // Call string text = info.Text(context); // Assert Assert.AreEqual("Scenario's", text); + mocks.VerifyAll(); } [Test] public void Image_Always_ReturnExpectedImage() { // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var group = new CalculationGroup(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - var context = new MacroStabilityInwardsScenariosContext(group, failureMechanism); + var context = new MacroStabilityInwardsScenariosContext(group, failureMechanism, assessmentSection); // Call Image image = info.Image(context); // Assert TestHelper.AssertImagesAreEqual(Resources.ScenariosIcon, image); + mocks.VerifyAll(); } [Test] public void ContextMenuStrip_Always_CallsBuilder() { // Setup - using (var treeViewControl = new TreeViewControl()) - { - var group = new CalculationGroup(); - var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - var context = new MacroStabilityInwardsScenariosContext(group, failureMechanism); + var mocks = new MockRepository(); - var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var menuBuilder = mocks.StrictMock(); + menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); - var menuBuilder = mocks.StrictMock(); - menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); - menuBuilder.Expect(mb => mb.Build()).Return(null); + var group = new CalculationGroup(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + var context = new MacroStabilityInwardsScenariosContext(group, failureMechanism, assessmentSection); + using (var treeViewControl = new TreeViewControl()) + { var gui = mocks.Stub(); gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/ViewInfos/MacroStabilityInwardsScenariosViewInfoTest.cs =================================================================== diff -u -r72855f408ad900220c30e399d15854ca7562d4f2 -r5a67fdd92b4e69e1fde669dd27605d0eeaad734b --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/ViewInfos/MacroStabilityInwardsScenariosViewInfoTest.cs (.../MacroStabilityInwardsScenariosViewInfoTest.cs) (revision 72855f408ad900220c30e399d15854ca7562d4f2) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Plugin.Test/ViewInfos/MacroStabilityInwardsScenariosViewInfoTest.cs (.../MacroStabilityInwardsScenariosViewInfoTest.cs) (revision 5a67fdd92b4e69e1fde669dd27605d0eeaad734b) @@ -20,6 +20,7 @@ // All rights reserved. using System.Linq; +using Core.Common.Controls.Views; using Core.Common.Gui.Plugin; using Core.Common.TestUtil; using NUnit.Framework; @@ -68,27 +69,34 @@ public void GetViewData_Always_ReturnsWrappedCalculationGroup() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var calculationsGroup = new CalculationGroup(); - var scenariosContext = new MacroStabilityInwardsScenariosContext(calculationsGroup, failureMechanism); + var scenariosContext = new MacroStabilityInwardsScenariosContext(calculationsGroup, failureMechanism, assessmentSection); // Call object viewData = info.GetViewData(scenariosContext); // Assert Assert.AreSame(calculationsGroup, viewData); + mocks.VerifyAll(); } [Test] public void GetViewName_Always_ReturnsScenarios() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var calculationsGroup = new CalculationGroup { Name = "Test" }; - using (var view = new MacroStabilityInwardsScenariosView()) + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection)) { // Call string viewName = info.GetViewName(view, calculationsGroup); @@ -102,8 +110,11 @@ public void AdditionalDataCheck_ScenariosContextWithFailureMechanismParent_ReturnsTrue() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - var scenariosContext = new MacroStabilityInwardsScenariosContext(failureMechanism.CalculationsGroup, failureMechanism); + var scenariosContext = new MacroStabilityInwardsScenariosContext(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection); // Call bool additionalDataCheck = info.AdditionalDataCheck(scenariosContext); @@ -116,9 +127,12 @@ public void AdditionalDataCheck_ScenariosContextWithoutFailureMechanismParent_ReturnsFalse() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var calculationsGroup = new CalculationGroup(); - var scenariosContext = new MacroStabilityInwardsScenariosContext(calculationsGroup, failureMechanism); + var scenariosContext = new MacroStabilityInwardsScenariosContext(calculationsGroup, failureMechanism, assessmentSection); // Call bool additionalDataCheck = info.AdditionalDataCheck(scenariosContext); @@ -138,7 +152,7 @@ mocks.ReplayAll(); - using (var view = new MacroStabilityInwardsScenariosView + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection) { Data = calculationsGroup }) @@ -149,6 +163,7 @@ // Assert Assert.IsFalse(closeForData); } + mocks.VerifyAll(); } @@ -167,7 +182,7 @@ mocks.ReplayAll(); - using (var view = new MacroStabilityInwardsScenariosView + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection) { Data = calculationsGroup }) @@ -178,6 +193,7 @@ // Assert Assert.IsFalse(closeForData); } + mocks.VerifyAll(); } @@ -195,7 +211,7 @@ mocks.ReplayAll(); - using (var view = new MacroStabilityInwardsScenariosView + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection) { Data = failureMechanism.CalculationsGroup }) @@ -206,14 +222,18 @@ // Assert Assert.IsTrue(closeForData); } + mocks.VerifyAll(); } [Test] public void CloseForData_ViewNotCorrespondingToRemovedFailureMechanism_ReturnsFalse() { // Setup - using (var view = new MacroStabilityInwardsScenariosView + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection) { Data = new CalculationGroup() }) @@ -226,15 +246,20 @@ // Assert Assert.IsFalse(closeForData); } + + mocks.VerifyAll(); } [Test] public void CloseForData_ViewCorrespondingToRemovedFailureMechanism_ReturnsTrue() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); - using (var view = new MacroStabilityInwardsScenariosView + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection) { Data = failureMechanism.CalculationsGroup }) @@ -245,6 +270,8 @@ // Assert Assert.IsTrue(closeForData); } + + mocks.VerifyAll(); } [Test] @@ -257,7 +284,7 @@ var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(new MacroStabilityInwardsFailureMechanism(), assessmentSection); - using (var view = new MacroStabilityInwardsScenariosView + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection) { Data = failureMechanism.CalculationsGroup }) @@ -268,6 +295,7 @@ // Assert Assert.IsFalse(closeForData); } + mocks.VerifyAll(); } @@ -281,7 +309,7 @@ var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var failureMechanismContext = new MacroStabilityInwardsFailureMechanismContext(failureMechanism, assessmentSection); - using (var view = new MacroStabilityInwardsScenariosView + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection) { Data = failureMechanism.CalculationsGroup }) @@ -292,25 +320,50 @@ // Assert Assert.IsTrue(closeForData); } + mocks.VerifyAll(); } [Test] public void AfterCreate_Always_SetsSpecificPropertiesToView() { // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var calculationsGroup = new CalculationGroup(); - var scenariosContext = new MacroStabilityInwardsScenariosContext(calculationsGroup, failureMechanism); + var scenariosContext = new MacroStabilityInwardsScenariosContext(calculationsGroup, failureMechanism, assessmentSection); - using (var view = new MacroStabilityInwardsScenariosView()) + using (var view = new MacroStabilityInwardsScenariosView(assessmentSection)) { // Call info.AfterCreate(view, scenariosContext); // Assert Assert.AreSame(failureMechanism, view.MacroStabilityInwardsFailureMechanism); } + + mocks.VerifyAll(); } + + [Test] + public void CreateInstance_Always_ReturnsView() + { + // Setup + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + var calculationsGroup = new CalculationGroup(); + var context = new MacroStabilityInwardsScenariosContext(calculationsGroup, failureMechanism, assessmentSection); + + // Call + IView view = info.CreateInstance(context); + + // Assert + Assert.IsInstanceOf(view); + mocks.VerifyAll(); + } } } \ No newline at end of file