Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationsContext.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationsContext.cs (revision 0) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsCalculationsContext.cs (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -0,0 +1,45 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.GrassCoverErosionInwards.Data; + +namespace Riskeer.GrassCoverErosionInwards.Forms.PresentationObjects +{ + /// + /// Presentation object for calculations of . + /// + public class GrassCoverErosionInwardsCalculationsContext : FailureMechanismContext + { + /// + /// Creates a new instance of . + /// + /// The + /// instance wrapped by this context object. + /// The assessment section which the failure mechanism belongs to. + /// Thrown when any parameter is null. + public GrassCoverErosionInwardsCalculationsContext(GrassCoverErosionInwardsFailureMechanism failureMechanism, + IAssessmentSection assessmentSection) + : base(failureMechanism, assessmentSection) {} + } +} \ No newline at end of file Fisheye: Tag 1a0ad304560f29f90c11f0f0a208cc68dc0feedd refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Forms/PresentationObjects/GrassCoverErosionInwardsFailureMechanismContext.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/src/Riskeer.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -69,7 +69,7 @@ { public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { CreateInstance = context => new GrassCoverErosionInwardsFailureMechanismProperties( context.WrappedData, @@ -175,7 +175,7 @@ public override IEnumerable GetViewInfos() { - yield return new ViewInfo + yield return new ViewInfo { GetViewName = (view, context) => context.WrappedData.Name, Image = RiskeerCommonFormsResources.FailureMechanismIcon, @@ -262,7 +262,7 @@ public override IEnumerable GetTreeNodeInfos() { - yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismContextTreeNodeInfo( + yield return RiskeerTreeNodeInfoFactory.CreateFailureMechanismContextTreeNodeInfo( FailureMechanismEnabledChildNodeObjects, FailureMechanismDisabledChildNodeObjects, FailureMechanismEnabledContextMenuStrip, @@ -401,7 +401,7 @@ { var failureMechanism = removedData as GrassCoverErosionInwardsFailureMechanism; - if (removedData is GrassCoverErosionInwardsFailureMechanismContext failureMechanismContext) + if (removedData is GrassCoverErosionInwardsCalculationsContext failureMechanismContext) { failureMechanism = failureMechanismContext.WrappedData; } @@ -454,7 +454,7 @@ var failureMechanism = o as GrassCoverErosionInwardsFailureMechanism; - if (o is GrassCoverErosionInwardsFailureMechanismContext failureMechanismContext) + if (o is GrassCoverErosionInwardsCalculationsContext failureMechanismContext) { failureMechanism = failureMechanismContext.WrappedData; } @@ -480,7 +480,7 @@ var assessmentSection = o as IAssessmentSection; var failureMechanism = o as GrassCoverErosionInwardsFailureMechanism; - if (o is GrassCoverErosionInwardsFailureMechanismContext failureMechanismContext) + if (o is GrassCoverErosionInwardsCalculationsContext failureMechanismContext) { failureMechanism = failureMechanismContext.WrappedData; } @@ -501,7 +501,7 @@ #region GrassCoverErosionInwardsFailureMechanismContext TreeNodeInfo - private static object[] FailureMechanismEnabledChildNodeObjects(GrassCoverErosionInwardsFailureMechanismContext context) + private static object[] FailureMechanismEnabledChildNodeObjects(GrassCoverErosionInwardsCalculationsContext context) { GrassCoverErosionInwardsFailureMechanism wrappedData = context.WrappedData; IAssessmentSection assessmentSection = context.Parent; @@ -514,11 +514,11 @@ }; } - private static object[] FailureMechanismDisabledChildNodeObjects(GrassCoverErosionInwardsFailureMechanismContext failureMechanismContext) + private static object[] FailureMechanismDisabledChildNodeObjects(GrassCoverErosionInwardsCalculationsContext context) { return new object[] { - failureMechanismContext.WrappedData.NotRelevantComments + context.WrappedData.NotRelevantComments }; } @@ -544,31 +544,31 @@ }; } - private ContextMenuStrip FailureMechanismEnabledContextMenuStrip(GrassCoverErosionInwardsFailureMechanismContext failureMechanismContext, + private ContextMenuStrip FailureMechanismEnabledContextMenuStrip(GrassCoverErosionInwardsCalculationsContext context, object parentData, TreeViewControl treeViewControl) { - IEnumerable calculations = failureMechanismContext.WrappedData - .Calculations - .Cast(); + IEnumerable calculations = context.WrappedData + .Calculations + .Cast(); IInquiryHelper inquiryHelper = GetInquiryHelper(); - var builder = new RiskeerContextMenuBuilder(Gui.Get(failureMechanismContext, treeViewControl)); + var builder = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl)); return builder .AddOpenItem() .AddSeparator() - .AddToggleRelevancyOfFailureMechanismItem(failureMechanismContext, RemoveAllViewsForItem) + .AddToggleRelevancyOfFailureMechanismItem(context, RemoveAllViewsForItem) .AddSeparator() .AddValidateAllCalculationsInFailureMechanismItem( - failureMechanismContext, + context, ValidateAllInFailureMechanism, EnableValidateAndCalculateMenuItemForFailureMechanism) .AddPerformAllCalculationsInFailureMechanismItem( - failureMechanismContext, + context, CalculateAllInFailureMechanism, EnableValidateAndCalculateMenuItemForFailureMechanism) .AddSeparator() - .AddClearAllCalculationOutputInFailureMechanismItem(failureMechanismContext.WrappedData) + .AddClearAllCalculationOutputInFailureMechanismItem(context.WrappedData) .AddClearIllustrationPointsOfCalculationsInFailureMechanismItem( () => GrassCoverErosionInwardsIllustrationPointsHelper.HasIllustrationPoints(calculations), CreateChangeHandler(inquiryHelper, calculations)) @@ -580,13 +580,13 @@ .Build(); } - private ContextMenuStrip FailureMechanismDisabledContextMenuStrip(GrassCoverErosionInwardsFailureMechanismContext failureMechanismContext, + private ContextMenuStrip FailureMechanismDisabledContextMenuStrip(GrassCoverErosionInwardsCalculationsContext context, object parentData, TreeViewControl treeViewControl) { - var builder = new RiskeerContextMenuBuilder(Gui.Get(failureMechanismContext, treeViewControl)); + var builder = new RiskeerContextMenuBuilder(Gui.Get(context, treeViewControl)); - return builder.AddToggleRelevancyOfFailureMechanismItem(failureMechanismContext, + return builder.AddToggleRelevancyOfFailureMechanismItem(context, RemoveAllViewsForItem) .AddSeparator() .AddCollapseAllItem() @@ -596,22 +596,22 @@ .Build(); } - private void RemoveAllViewsForItem(GrassCoverErosionInwardsFailureMechanismContext failureMechanismContext) + private void RemoveAllViewsForItem(GrassCoverErosionInwardsCalculationsContext context) { - Gui.ViewCommands.RemoveAllViewsForItem(failureMechanismContext); + Gui.ViewCommands.RemoveAllViewsForItem(context); } - private static string EnableValidateAndCalculateMenuItemForFailureMechanism(GrassCoverErosionInwardsFailureMechanismContext context) + private static string EnableValidateAndCalculateMenuItemForFailureMechanism(GrassCoverErosionInwardsCalculationsContext context) { return EnableValidateAndCalculateMenuItem(context.Parent); } - private static void ValidateAllInFailureMechanism(GrassCoverErosionInwardsFailureMechanismContext context) + private static void ValidateAllInFailureMechanism(GrassCoverErosionInwardsCalculationsContext context) { ValidateAll(context.WrappedData.Calculations.OfType(), context.WrappedData, context.Parent); } - private void CalculateAllInFailureMechanism(GrassCoverErosionInwardsFailureMechanismContext context) + private void CalculateAllInFailureMechanism(GrassCoverErosionInwardsCalculationsContext context) { ActivityProgressDialogRunner.Run( Gui.MainWindow, Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationsContextTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationsContextTest.cs (revision 0) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsCalculationsContextTest.cs (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -0,0 +1,54 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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 NUnit.Framework; +using Rhino.Mocks; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.GrassCoverErosionInwards.Data; +using Riskeer.GrassCoverErosionInwards.Forms.PresentationObjects; + +namespace Riskeer.GrassCoverErosionInwards.Forms.Test.PresentationObjects +{ + [TestFixture] + public class GrassCoverErosionInwardsCalculationsContextTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + // Call + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + // Assert + Assert.IsInstanceOf>(context); + Assert.AreSame(assessmentSection, context.Parent); + Assert.AreSame(failureMechanism, context.WrappedData); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Fisheye: Tag 1a0ad304560f29f90c11f0f0a208cc68dc0feedd refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PresentationObjects/GrassCoverErosionInwardsFailureMechanismContextTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs (.../GrassCoverErosionInwardsPluginTest.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/GrassCoverErosionInwardsPluginTest.cs (.../GrassCoverErosionInwardsPluginTest.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -66,7 +66,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, - typeof(GrassCoverErosionInwardsFailureMechanismContext), + typeof(GrassCoverErosionInwardsCalculationsContext), typeof(GrassCoverErosionInwardsFailureMechanismProperties)); PluginTestHelper.AssertPropertyInfoDefined( @@ -117,7 +117,7 @@ // Assert Assert.AreEqual(11, treeNodeInfos.Length); - Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionInwardsFailureMechanismContext))); + Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionInwardsCalculationsContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(DikeProfilesContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionInwardsCalculationGroupContext))); Assert.IsTrue(treeNodeInfos.Any(tni => tni.TagType == typeof(GrassCoverErosionInwardsCalculationScenarioContext))); @@ -145,7 +145,7 @@ PluginTestHelper.AssertViewInfoDefined( viewInfos, - typeof(GrassCoverErosionInwardsFailureMechanismContext), + typeof(GrassCoverErosionInwardsCalculationsContext), typeof(GrassCoverErosionInwardsFailureMechanismView)); PluginTestHelper.AssertViewInfoDefined( Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/PropertyInfos/GrassCoverErosionInwardsFailureMechanismPropertyInfoTest.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/PropertyInfos/GrassCoverErosionInwardsFailureMechanismPropertyInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismPropertyInfoTest.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/PropertyInfos/GrassCoverErosionInwardsFailureMechanismPropertyInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismPropertyInfoTest.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -54,7 +54,7 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(GrassCoverErosionInwardsFailureMechanismContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionInwardsCalculationsContext), info.DataType); Assert.AreEqual(typeof(GrassCoverErosionInwardsFailureMechanismProperties), info.PropertyObjectType); } @@ -67,7 +67,7 @@ mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var context = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); // Call IObjectProperties objectProperties = info.CreateInstance(context); Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationsContextTreeNodeInfoTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationsContextTreeNodeInfoTest.cs (revision 0) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationsContextTreeNodeInfoTest.cs (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -0,0 +1,1110 @@ +// Copyright (C) Stichting Deltares 2021. All rights reserved. +// +// This file is part of Riskeer. +// +// Riskeer 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; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Core.Common.Base; +using Core.Common.Controls.TreeView; +using Core.Common.TestUtil; +using Core.Gui; +using Core.Gui.Commands; +using Core.Gui.ContextMenu; +using Core.Gui.Forms.MainWindow; +using Core.Gui.TestUtil.ContextMenu; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Riskeer.AssemblyTool.KernelWrapper.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators; +using Riskeer.AssemblyTool.KernelWrapper.TestUtil.Calculators.Categories; +using Riskeer.Common.Data; +using Riskeer.Common.Data.AssessmentSection; +using Riskeer.Common.Data.Hydraulics; +using Riskeer.Common.Data.TestUtil; +using Riskeer.Common.Data.TestUtil.IllustrationPoints; +using Riskeer.Common.Forms.PresentationObjects; +using Riskeer.Common.Service.TestUtil; +using Riskeer.GrassCoverErosionInwards.Data; +using Riskeer.GrassCoverErosionInwards.Data.TestUtil; +using Riskeer.GrassCoverErosionInwards.Forms.PresentationObjects; +using Riskeer.HydraRing.Calculation.Calculator.Factory; +using Riskeer.HydraRing.Calculation.Data.Input; +using Riskeer.HydraRing.Calculation.TestUtil.Calculator; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionInwards.Plugin.Test.TreeNodeInfos +{ + [TestFixture] + public class GrassCoverErosionInwardsCalculationsContextTreeNodeInfoTest : NUnitFormTest + { + private const int contextMenuRelevancyIndexWhenRelevant = 2; + private const int contextMenuRelevancyIndexWhenNotRelevant = 0; + + private const int contextMenuValidateAllIndex = 4; + private const int contextMenuCalculateAllIndex = 5; + private const int contextMenuClearAllIndex = 7; + private const int contextMenuClearIllustrationPointsIndex = 8; + + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO, nameof(HydraulicBoundaryDatabase)); + + private MockRepository mocksRepository; + private GrassCoverErosionInwardsPlugin plugin; + private TreeNodeInfo info; + + [Test] + public void Initialized_Always_ExpectedPropertiesSet() + { + // Setup + mocksRepository.ReplayAll(); + + // Assert + Assert.IsNotNull(info.Text); + Assert.IsNotNull(info.ForeColor); + Assert.IsNotNull(info.Image); + Assert.IsNotNull(info.ContextMenuStrip); + Assert.IsNull(info.EnsureVisibleOnCreate); + Assert.IsNull(info.ExpandOnCreate); + Assert.IsNotNull(info.ChildNodeObjects); + Assert.IsNull(info.CanRename); + Assert.IsNull(info.OnNodeRenamed); + Assert.IsNull(info.CanRemove); + Assert.IsNull(info.OnNodeRemoved); + Assert.IsNull(info.CanCheck); + Assert.IsNull(info.CheckedState); + Assert.IsNull(info.OnNodeChecked); + Assert.IsNull(info.CanDrag); + Assert.IsNull(info.CanDrop); + Assert.IsNull(info.CanInsert); + Assert.IsNull(info.OnDrop); + } + + [Test] + public void ChildNodeObjects_FailureMechanismIsRelevant_ReturnChildDataNodes() + { + // Setup + var assessmentSection = new AssessmentSectionStub(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context).ToArray(); + + // Assert + Assert.AreEqual(3, children.Length); + + var inputsFolder = (CategoryTreeFolder) children[0]; + Assert.AreEqual("Invoer", inputsFolder.Name); + Assert.AreEqual(TreeFolderCategory.Input, inputsFolder.Category); + + Assert.AreEqual(3, inputsFolder.Contents.Count()); + var failureMechanismSectionsContext = (GrassCoverErosionInwardsFailureMechanismSectionsContext) inputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism, failureMechanismSectionsContext.WrappedData); + Assert.AreSame(assessmentSection, failureMechanismSectionsContext.AssessmentSection); + + var dikeProfilesContext = (DikeProfilesContext) inputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism.DikeProfiles, dikeProfilesContext.WrappedData); + Assert.AreSame(failureMechanism, dikeProfilesContext.ParentFailureMechanism); + Assert.AreSame(assessmentSection, dikeProfilesContext.ParentAssessmentSection); + + var inputComment = (Comment) inputsFolder.Contents.ElementAt(2); + Assert.AreSame(failureMechanism.InputComments, inputComment); + + var calculationsFolder = (GrassCoverErosionInwardsCalculationGroupContext) children[1]; + Assert.AreSame(failureMechanism.CalculationsGroup, calculationsFolder.WrappedData); + Assert.IsNull(calculationsFolder.Parent); + Assert.AreSame(failureMechanism, calculationsFolder.FailureMechanism); + + var outputsFolder = (CategoryTreeFolder) children[2]; + Assert.AreEqual("Oordeel", outputsFolder.Name); + Assert.AreEqual(TreeFolderCategory.Output, outputsFolder.Category); + + Assert.AreEqual(4, outputsFolder.Contents.Count()); + var failureMechanismAssemblyCategoriesContext = (FailureMechanismAssemblyCategoriesContext) outputsFolder.Contents.ElementAt(0); + Assert.AreSame(failureMechanism, failureMechanismAssemblyCategoriesContext.WrappedData); + Assert.AreSame(assessmentSection, failureMechanismAssemblyCategoriesContext.AssessmentSection); + + using (new AssemblyToolCalculatorFactoryConfig()) + { + var calculatorFactory = (TestAssemblyToolCalculatorFactory) AssemblyToolCalculatorFactory.Instance; + AssemblyCategoriesCalculatorStub calculator = calculatorFactory.LastCreatedAssemblyCategoriesCalculator; + + failureMechanismAssemblyCategoriesContext.GetFailureMechanismSectionAssemblyCategoriesFunc(); + Assert.AreEqual(failureMechanism.GeneralInput.N, calculator.AssemblyCategoriesInput.N); + } + + var scenariosContext = (GrassCoverErosionInwardsScenariosContext) outputsFolder.Contents.ElementAt(1); + Assert.AreSame(failureMechanism.CalculationsGroup, scenariosContext.WrappedData); + Assert.AreSame(failureMechanism, scenariosContext.ParentFailureMechanism); + + var failureMechanismResultsContext = (FailureMechanismSectionResultContext) outputsFolder.Contents.ElementAt(2); + Assert.AreSame(failureMechanism, failureMechanismResultsContext.FailureMechanism); + Assert.AreSame(failureMechanism.SectionResults, failureMechanismResultsContext.WrappedData); + + var outputComment = (Comment) outputsFolder.Contents.ElementAt(3); + Assert.AreSame(failureMechanism.OutputComments, outputComment); + } + + [Test] + public void ChildNodeObjects_FailureMechanismIsNotRelevant_ReturnOnlyFailureMechanismNotRelevantComments() + { + // Setup + var assessmentSection = mocksRepository.Stub(); + mocksRepository.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = false + }; + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + // Call + object[] children = info.ChildNodeObjects(context).ToArray(); + + // Assert + Assert.AreEqual(1, children.Length); + var comment = (Comment) children[0]; + Assert.AreSame(failureMechanism.NotRelevantComments, comment); + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsRelevant_CallsContextMenuBuilderMethods() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var assessmentSection = mocksRepository.Stub(); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + var menuBuilder = mocksRepository.StrictMock(); + using (mocksRepository.Ordered()) + { + menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + } + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + + // Assert + // Assert expectancies are called in TearDown() + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsNotRelevant_CallsContextMenuBuilderMethods() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = false + }; + var assessmentSection = mocksRepository.Stub(); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + var menuBuilder = mocksRepository.StrictMock(); + using (mocksRepository.Ordered()) + { + menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); + menuBuilder.Expect(mb => mb.Build()).Return(null); + } + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + info.ContextMenuStrip(context, null, treeViewControl); + } + + // Assert + // Assert expectancies are called in TearDown() + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsRelevant_AddCustomItems() + { + // Setup + using (var treeView = new TreeViewControl()) + { + var assessmentSection = mocksRepository.Stub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocksRepository.Stub(); + gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView)) + { + // Assert + Assert.AreEqual(14, menu.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenRelevant, + "I&s relevant", + "Geeft aan of dit toetsspoor relevant is of niet.", + RiskeerCommonFormsResources.Checkbox_ticked); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, + "Alles &valideren", + "Er zijn geen berekeningen om te valideren.", + RiskeerCommonFormsResources.ValidateAllIcon, + false); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Er zijn geen berekeningen om uit te voeren.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearAllIndex, + "&Wis alle uitvoer...", + "Er zijn geen berekeningen met uitvoer om te wissen.", + RiskeerCommonFormsResources.ClearIcon, + false); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearIllustrationPointsIndex, + "Wis alle illustratiepunten...", + "Er zijn geen berekeningen met illustratiepunten om te wissen.", + RiskeerCommonFormsResources.ClearIllustrationPointsIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsNotRelevant_AddCustomItems() + { + // Setup + using (var treeView = new TreeViewControl()) + { + var assessmentSection = mocksRepository.Stub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = false + }; + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var gui = mocksRepository.Stub(); + gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder); + gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); + gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView)) + { + // Assert + Assert.AreEqual(6, menu.Items.Count); + + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRelevancyIndexWhenNotRelevant, + "I&s relevant", + "Geeft aan of dit toetsspoor relevant is of niet.", + RiskeerCommonFormsResources.Checkbox_empty); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsRelevantAndClickOnIsRelevantItem_MakeFailureMechanismNotRelevantAndRemovesAllViewsForItem() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var assessmentSection = mocksRepository.Stub(); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var viewCommands = mocksRepository.StrictMock(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + viewCommands.Expect(vs => vs.RemoveAllViewsForItem(context)); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.ViewCommands).Return(viewCommands); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Call + contextMenu.Items[contextMenuRelevancyIndexWhenRelevant].PerformClick(); + + // Assert + Assert.IsFalse(failureMechanism.IsRelevant); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismIsNotRelevantAndClickOnIsRelevantItem_MakeFailureMechanismRelevantAndRemovesAllViewsForItem() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + IsRelevant = false + }; + var assessmentSection = mocksRepository.Stub(); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var viewCommands = mocksRepository.StrictMock(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + viewCommands.Expect(vs => vs.RemoveAllViewsForItem(context)); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.ViewCommands).Return(viewCommands); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Call + contextMenu.Items[contextMenuRelevancyIndexWhenNotRelevant].PerformClick(); + + // Assert + Assert.IsTrue(failureMechanism.IsRelevant); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + var nodeData = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Er is geen hydraulische belastingendatabase geïmporteerd.", + RiskeerCommonFormsResources.CalculateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); + + var nodeData = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuCalculateAllIndex]; + + Assert.AreEqual("Alles be&rekenen", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.CalculateAllIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled() + { + // Setup + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var nodeData = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, + "Alles be&rekenen", + "Voer alle berekeningen binnen dit toetsspoor uit.", + RiskeerCommonFormsResources.CalculateAllIcon); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemValidateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + + var nodeData = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuValidateAllIndex, + "Alles &valideren", + "Er is geen hydraulische belastingendatabase geïmporteerd.", + RiskeerCommonFormsResources.ValidateAllIcon, + false); + } + } + } + + [Test] + public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemValidateAllDisabledAndTooltipSet() + { + // Setup + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); + + var nodeData = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + ToolStripItem contextMenuItem = contextMenu.Items[contextMenuValidateAllIndex]; + + Assert.AreEqual("Alles &valideren", contextMenuItem.Text); + StringAssert.Contains("Herstellen van de verbinding met de hydraulische belastingendatabase is mislukt.", contextMenuItem.ToolTipText); + TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.ValidateAllIcon, contextMenuItem.Image); + Assert.IsFalse(contextMenuItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemValidateAllEnabled() + { + // Setup + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation()); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath, + Version = "1.0" + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var nodeData = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + // Call + using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // Assert + TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, + "Alles &valideren", + "Valideer alle berekeningen binnen dit toetsspoor.", + RiskeerCommonFormsResources.ValidateAllIcon); + } + } + } + + [Test] + public void ContextMenuStrip_ClickOnCalculateAllItem_ScheduleAllChildCalculations() + { + // Setup + var mainWindow = mocksRepository.Stub(); + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(), + DikeProfile = DikeProfileTestFactory.CreateDikeProfile() + } + }); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation + { + Name = "B", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(), + DikeProfile = DikeProfileTestFactory.CreateDikeProfile() + } + }); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = Path.Combine(testDataPath, "complete.sqlite") + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.Id).Return(string.Empty); + assessmentSection.Stub(a => a.FailureMechanismContribution) + .Return(FailureMechanismContributionTestFactory.CreateFailureMechanismContribution()); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mainWindow); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + + int nrOfCalculators = failureMechanism.Calculations.Count(); + var calculatorFactory = mocksRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(Arg.Is.NotNull)) + .WhenCalled(invocation => + { + HydraRingCalculationSettingsTestHelper.AssertHydraRingCalculationSettings( + HydraulicBoundaryCalculationSettingsFactory.CreateSettings(hydraulicBoundaryDatabase), + (HydraRingCalculationSettings) invocation.Arguments[0]); + }) + .Return(new TestOvertoppingCalculator()) + .Repeat + .Times(nrOfCalculators); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + DialogBoxHandler = (name, wnd) => + { + // Expect an activity dialog which is automatically closed + }; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + TestHelper.AssertLogMessages(() => contextMenu.Items[contextMenuCalculateAllIndex].PerformClick(), messages => + { + List messageList = messages.ToList(); + + // Assert + Assert.AreEqual(14, messageList.Count); + Assert.AreEqual("Uitvoeren van berekening 'A' is gestart.", messageList[0]); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[1]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[2]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messageList[3]); + StringAssert.StartsWith("De overloop en overslag berekening is uitgevoerd op de tijdelijke locatie", messageList[4]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messageList[5]); + Assert.AreEqual("Uitvoeren van berekening 'A' is gelukt.", messageList[6]); + + Assert.AreEqual("Uitvoeren van berekening 'B' is gestart.", messageList[7]); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[8]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[9]); + CalculationServiceTestHelper.AssertCalculationStartMessage(messageList[10]); + StringAssert.StartsWith("De overloop en overslag berekening is uitgevoerd op de tijdelijke locatie", messageList[11]); + CalculationServiceTestHelper.AssertCalculationEndMessage(messageList[12]); + Assert.AreEqual("Uitvoeren van berekening 'B' is gelukt.", messageList[13]); + }); + } + } + } + + [Test] + public void ContextMenuStrip_ClickOnValidateAllItem_ValidateAllChildCalculations() + { + // Setup + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + + var failureMechanism = new TestGrassCoverErosionInwardsFailureMechanism(); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation + { + Name = "A", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(), + DikeProfile = DikeProfileTestFactory.CreateDikeProfile() + } + }); + failureMechanism.CalculationsGroup.Children.Add(new GrassCoverErosionInwardsCalculation + { + Name = "B", + InputParameters = + { + HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(), + DikeProfile = DikeProfileTestFactory.CreateDikeProfile() + } + }); + + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + FilePath = validFilePath + }; + HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(hydraulicBoundaryDatabase); + + var assessmentSection = mocksRepository.Stub(); + assessmentSection.Stub(a => a.HydraulicBoundaryDatabase).Return(hydraulicBoundaryDatabase); + + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Call + TestHelper.AssertLogMessages(() => contextMenu.Items[contextMenuValidateAllIndex].PerformClick(), messages => + { + List messageList = messages.ToList(); + + // Assert + Assert.AreEqual(4, messageList.Count); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[0]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[1]); + CalculationServiceTestHelper.AssertValidationStartMessage(messageList[2]); + CalculationServiceTestHelper.AssertValidationEndMessage(messageList[3]); + }); + } + } + } + + [Test] + [TestCaseSource(nameof(GetCalculationConfigurationsWithIllustrationPoints))] + public void ContextMenuStrip_FailureMechanismWithCalculationsContainingIllustrationPoints_ContextMenuItemClearIllustrationPointsEnabled( + GrassCoverErosionInwardsCalculation calculation) + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + + var calculationWithOutput = new GrassCoverErosionInwardsCalculation + { + Output = new TestGrassCoverErosionInwardsOutput() + }; + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculation, + calculationWithOutput, + new GrassCoverErosionInwardsCalculation() + } + } + }; + + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Call + ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex]; + + // Assert + Assert.IsTrue(toolStripItem.Enabled); + } + } + } + + [Test] + public void ContextMenuStrip_FailureMechanismWithCalculationsWithoutIllustrationPoints_ContextMenuItemClearIllustrationPointsDisabled() + { + // Setup + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + + var calculationWithOutput = new GrassCoverErosionInwardsCalculation + { + Output = new TestGrassCoverErosionInwardsOutput() + }; + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculationWithOutput, + new GrassCoverErosionInwardsCalculation() + } + } + }; + + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, null, treeViewControl)) + { + // Call + ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex]; + + // Assert + Assert.IsFalse(toolStripItem.Enabled); + } + } + } + + [Test] + public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndAborted_ThenInquiryAndIllustrationPointsNotCleared() + { + // Given + var calculationWithIllustrationPoints = new GrassCoverErosionInwardsCalculation + { + Output = new TestGrassCoverErosionInwardsOutput(new TestGeneralResultFaultTreeIllustrationPoint()) + }; + + var calculationWithOutput = new GrassCoverErosionInwardsCalculation + { + Output = new TestGrassCoverErosionInwardsOutput() + }; + + var calculationObserver = mocksRepository.StrictMock(); + calculationWithIllustrationPoints.Attach(calculationObserver); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculationWithIllustrationPoints, + calculationWithOutput, + new GrassCoverErosionInwardsCalculation() + } + } + }; + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + + var nodeData = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + var messageBoxText = ""; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + messageBoxText = helper.Text; + + helper.ClickCancel(); + }; + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenuStrip.Items[contextMenuClearIllustrationPointsIndex].PerformClick(); + + // Then + Assert.AreEqual("Weet u zeker dat u alle illustratiepunten wilt wissen?", messageBoxText); + + Assert.IsTrue(calculationWithOutput.HasOutput); + + GrassCoverErosionInwardsOutput output = calculationWithIllustrationPoints.Output; + Assert.IsTrue(output.OvertoppingOutput.HasGeneralResult); + Assert.IsTrue(output.DikeHeightOutput.HasGeneralResult); + Assert.IsTrue(output.OvertoppingRateOutput.HasGeneralResult); + } + } + } + + [Test] + public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndContinued_ThenInquiryAndIllustrationPointsCleared() + { + // Given + var calculationWithIllustrationPoints = new GrassCoverErosionInwardsCalculation + { + Output = new TestGrassCoverErosionInwardsOutput(new TestGeneralResultFaultTreeIllustrationPoint()) + }; + + var calculationWithOutput = new GrassCoverErosionInwardsCalculation + { + Output = new TestGrassCoverErosionInwardsOutput() + }; + + var affectedCalculationObserver = mocksRepository.StrictMock(); + affectedCalculationObserver.Expect(o => o.UpdateObserver()); + calculationWithIllustrationPoints.Attach(affectedCalculationObserver); + + var unaffectedCalculationObserver = mocksRepository.StrictMock(); + calculationWithOutput.Attach(unaffectedCalculationObserver); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + CalculationsGroup = + { + Children = + { + calculationWithIllustrationPoints, + calculationWithOutput, + new GrassCoverErosionInwardsCalculation() + } + } + }; + + IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); + var nodeData = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); + + var messageBoxText = ""; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + messageBoxText = helper.Text; + + helper.ClickOk(); + }; + + using (var treeViewControl = new TreeViewControl()) + { + var gui = mocksRepository.Stub(); + gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); + gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub()); + mocksRepository.ReplayAll(); + + plugin.Gui = gui; + + using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(nodeData, null, treeViewControl)) + { + // When + contextMenuStrip.Items[contextMenuClearIllustrationPointsIndex].PerformClick(); + + // Then + Assert.AreEqual("Weet u zeker dat u alle illustratiepunten wilt wissen?", messageBoxText); + + Assert.IsTrue(calculationWithOutput.HasOutput); + + GrassCoverErosionInwardsOutput output = calculationWithIllustrationPoints.Output; + Assert.IsFalse(output.OvertoppingOutput.HasGeneralResult); + Assert.IsFalse(output.DikeHeightOutput.HasGeneralResult); + Assert.IsFalse(output.OvertoppingRateOutput.HasGeneralResult); + } + } + } + + public override void Setup() + { + mocksRepository = new MockRepository(); + plugin = new GrassCoverErosionInwardsPlugin(); + info = plugin.GetTreeNodeInfos().First(tni => tni.TagType == typeof(GrassCoverErosionInwardsCalculationsContext)); + } + + public override void TearDown() + { + plugin.Dispose(); + mocksRepository.VerifyAll(); + + base.TearDown(); + } + + private static IEnumerable GetCalculationConfigurationsWithIllustrationPoints() + { + var random = new Random(21); + var calculationWithOverToppingOutputWithIllustrationPoints = new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(new TestGeneralResultFaultTreeIllustrationPoint()), + null, + null) + }; + + var calculationWithDikeHeightRateWithIllustrationPoints = new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(random.NextDouble()), + new TestDikeHeightOutput(new TestGeneralResultFaultTreeIllustrationPoint()), + null) + }; + + var calculationWithOvertoppingRateWithIllustrationPoints = new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(new TestOvertoppingOutput(random.NextDouble()), + null, + new TestOvertoppingRateOutput(new TestGeneralResultFaultTreeIllustrationPoint())) + }; + + yield return new TestCaseData(calculationWithOverToppingOutputWithIllustrationPoints); + yield return new TestCaseData(calculationWithDikeHeightRateWithIllustrationPoints); + yield return new TestCaseData(calculationWithOvertoppingRateWithIllustrationPoints); + } + } +} \ No newline at end of file Fisheye: Tag 1a0ad304560f29f90c11f0f0a208cc68dc0feedd refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsFailureMechanismContextTreeNodeInfoTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismCalculationViewInfoTest.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismCalculationViewInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismCalculationViewInfoTest.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismCalculationViewInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismCalculationViewInfoTest.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -261,12 +261,12 @@ using (var calculationsView = new GrassCoverErosionInwardsCalculationsView(new CalculationGroup(), new GrassCoverErosionInwardsFailureMechanism(), assessmentSection)) { var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); calculationsView.Data = failureMechanism.CalculationsGroup; // Call - bool closeForData = info.CloseForData(calculationsView, failureMechanismContext); + bool closeForData = info.CloseForData(calculationsView, context); // Assert Assert.IsFalse(closeForData); @@ -282,12 +282,12 @@ using (var calculationsView = new GrassCoverErosionInwardsCalculationsView(new CalculationGroup(), new GrassCoverErosionInwardsFailureMechanism(), assessmentSection)) { var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); calculationsView.Data = failureMechanism.CalculationsGroup; // Call - bool closeForData = info.CloseForData(calculationsView, failureMechanismContext); + bool closeForData = info.CloseForData(calculationsView, context); // Assert Assert.IsTrue(closeForData); Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismResultViewInfoTest.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismResultViewInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismResultViewInfoTest.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismResultViewInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismResultViewInfoTest.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -227,12 +227,12 @@ mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); var view = new GrassCoverErosionInwardsFailureMechanismResultView(failureMechanism.SectionResults, failureMechanism, assessmentSection); // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); + bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); @@ -250,11 +250,11 @@ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var view = new GrassCoverErosionInwardsFailureMechanismResultView(failureMechanism.SectionResults, failureMechanism, assessmentSection); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(new GrassCoverErosionInwardsFailureMechanism(), - assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(new GrassCoverErosionInwardsFailureMechanism(), + assessmentSection); // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); + bool closeForData = info.CloseForData(view, context); // Assert Assert.IsFalse(closeForData); Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs (.../GrassCoverErosionInwardsFailureMechanismViewInfoTest.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -60,8 +60,8 @@ public void Initialized_Always_ExpectedPropertiesSet() { // Assert - Assert.AreEqual(typeof(GrassCoverErosionInwardsFailureMechanismContext), info.DataType); - Assert.AreEqual(typeof(GrassCoverErosionInwardsFailureMechanismContext), info.ViewDataType); + Assert.AreEqual(typeof(GrassCoverErosionInwardsCalculationsContext), info.DataType); + Assert.AreEqual(typeof(GrassCoverErosionInwardsCalculationsContext), info.ViewDataType); } [Test] @@ -72,10 +72,10 @@ mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var grassCoverErosionInwardsFailureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); // Call - string viewName = info.GetViewName(null, grassCoverErosionInwardsFailureMechanismContext); + string viewName = info.GetViewName(null, context); // Assert Assert.AreEqual(failureMechanism.Name, viewName); @@ -176,7 +176,7 @@ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var context = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); // Call bool result = info.AdditionalDataCheck(context); @@ -198,7 +198,7 @@ IsRelevant = false }; - var context = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); // Call bool result = info.AdditionalDataCheck(context); @@ -215,7 +215,7 @@ var assessmentSection = new AssessmentSectionStub(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var context = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); // Call IView view = info.CreateInstance(context); Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsInputViewInfoTest.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsInputViewInfoTest.cs (.../GrassCoverErosionInwardsInputViewInfoTest.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsInputViewInfoTest.cs (.../GrassCoverErosionInwardsInputViewInfoTest.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -281,15 +281,15 @@ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculation); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); using (var view = new GrassCoverErosionInwardsInputView { Data = calculation }) { // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); + bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); @@ -308,15 +308,15 @@ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculation); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); using (var view = new GrassCoverErosionInwardsInputView { Data = calculation }) { // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); + bool closeForData = info.CloseForData(view, context); // Assert Assert.IsFalse(closeForData); @@ -338,15 +338,15 @@ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculationGroup); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); using (var view = new GrassCoverErosionInwardsInputView { Data = calculation }) { // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); + bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); @@ -368,15 +368,15 @@ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); failureMechanism.CalculationsGroup.Children.Add(calculationGroup); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); using (var view = new GrassCoverErosionInwardsInputView { Data = calculation }) { // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); + bool closeForData = info.CloseForData(view, context); // Assert Assert.IsFalse(closeForData); Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsOutputViewInfoTestBase.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsOutputViewInfoTestBase.cs (.../GrassCoverErosionInwardsOutputViewInfoTestBase.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsOutputViewInfoTestBase.cs (.../GrassCoverErosionInwardsOutputViewInfoTestBase.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -155,7 +155,7 @@ protected override IFailureMechanismContext GetFailureMechanismContextWithCalculation() { - return new GrassCoverErosionInwardsFailureMechanismContext( + return new GrassCoverErosionInwardsCalculationsContext( new GrassCoverErosionInwardsFailureMechanism { CalculationsGroup = Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsScenariosViewInfoTest.cs =================================================================== diff -u -r1ba3eebbfe2ac3df531f67700f8f787302d8582c -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsScenariosViewInfoTest.cs (.../GrassCoverErosionInwardsScenariosViewInfoTest.cs) (revision 1ba3eebbfe2ac3df531f67700f8f787302d8582c) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Plugin.Test/ViewInfos/GrassCoverErosionInwardsScenariosViewInfoTest.cs (.../GrassCoverErosionInwardsScenariosViewInfoTest.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -232,12 +232,12 @@ mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(new GrassCoverErosionInwardsFailureMechanism(), assessmentSection); using (var view = new GrassCoverErosionInwardsScenariosView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection)) { // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); + bool closeForData = info.CloseForData(view, context); // Assert Assert.IsFalse(closeForData); @@ -255,12 +255,12 @@ mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var failureMechanismContext = new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSection); + var context = new GrassCoverErosionInwardsCalculationsContext(failureMechanism, assessmentSection); using (var view = new GrassCoverErosionInwardsScenariosView(failureMechanism.CalculationsGroup, failureMechanism, assessmentSection)) { // Call - bool closeForData = info.CloseForData(view, failureMechanismContext); + bool closeForData = info.CloseForData(view, context); // Assert Assert.IsTrue(closeForData); Index: Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs =================================================================== diff -u -r02952ce44b631f296213e2c133a0d4c72fc574b1 -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 02952ce44b631f296213e2c133a0d4c72fc574b1) +++ Riskeer/Integration/src/Riskeer.Integration.Plugin/RiskeerPlugin.cs (.../RiskeerPlugin.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -135,7 +135,7 @@ { new FailureMechanismContextAssociation( typeof(GrassCoverErosionInwardsFailureMechanism), - (mechanism, assessmentSection) => new GrassCoverErosionInwardsFailureMechanismContext( + (mechanism, assessmentSection) => new GrassCoverErosionInwardsCalculationsContext( (GrassCoverErosionInwardsFailureMechanism) mechanism, assessmentSection) ), Index: Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/CalculationsStateRootContextTreeNodeInfoTest.cs =================================================================== diff -u -r02952ce44b631f296213e2c133a0d4c72fc574b1 -r1a0ad304560f29f90c11f0f0a208cc68dc0feedd --- Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/CalculationsStateRootContextTreeNodeInfoTest.cs (.../CalculationsStateRootContextTreeNodeInfoTest.cs) (revision 02952ce44b631f296213e2c133a0d4c72fc574b1) +++ Riskeer/Integration/test/Riskeer.Integration.Plugin.Test/TreeNodeInfos/CalculationsStateRootContextTreeNodeInfoTest.cs (.../CalculationsStateRootContextTreeNodeInfoTest.cs) (revision 1a0ad304560f29f90c11f0f0a208cc68dc0feedd) @@ -178,9 +178,9 @@ Assert.AreSame(assessmentSection.Piping, pipingCalculationsContext.WrappedData); Assert.AreSame(assessmentSection, pipingCalculationsContext.Parent); - var grassCoverErosionInwardsFailureMechanismContext = (GrassCoverErosionInwardsFailureMechanismContext) objects[2]; - Assert.AreSame(assessmentSection.GrassCoverErosionInwards, grassCoverErosionInwardsFailureMechanismContext.WrappedData); - Assert.AreSame(assessmentSection, grassCoverErosionInwardsFailureMechanismContext.Parent); + var grassCoverErosionInwardsCalculationsContext = (GrassCoverErosionInwardsCalculationsContext) objects[2]; + Assert.AreSame(assessmentSection.GrassCoverErosionInwards, grassCoverErosionInwardsCalculationsContext.WrappedData); + Assert.AreSame(assessmentSection, grassCoverErosionInwardsCalculationsContext.Parent); var macroStabilityInwardsFailureMechanismContext = (MacroStabilityInwardsFailureMechanismContext) objects[3]; Assert.AreSame(assessmentSection.MacroStabilityInwards, macroStabilityInwardsFailureMechanismContext.WrappedData);