Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r047258c748dbf834052838e22715ee54d8c97150 -r3be9b3d3afa5f4dc4ed422f774405c127baaaf4e --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision 047258c748dbf834052838e22715ee54d8c97150) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationContextTreeNodeInfoTest.cs) (revision 3be9b3d3afa5f4dc4ed422f774405c127baaaf4e) @@ -341,30 +341,30 @@ } [Test] - public void GivenCalculationWithDikeProfileWithoutOutput_WhenDikeProfileUpdatedAndUpdateDikeProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() + public void GivenCalculationWithDikeProfileWithoutOutput_WhenDikeProfileUpdatedAndUpdateClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { - using (var treeViewControl = new TreeViewControl()) + // Given + var assessmentSection = mocks.Stub(); + var dikeProfile = new TestDikeProfile(); + var calculation = new GrassCoverErosionInwardsCalculation { - // Given - var assessmentSection = mocks.Stub(); - var dikeProfile = new TestDikeProfile(); - var calculation = new GrassCoverErosionInwardsCalculation + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - } - }; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + DikeProfile = dikeProfile + } + }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); - var inputObserver = mocks.StrictMock(); - inputObserver.Expect(obs => obs.UpdateObserver()); - calculation.InputParameters.Attach(inputObserver); + var inputObserver = mocks.StrictMock(); + inputObserver.Expect(obs => obs.UpdateObserver()); + calculation.InputParameters.Attach(inputObserver); - var calculationObserver = mocks.StrictMock(); - calculation.Attach(calculationObserver); + var calculationObserver = mocks.StrictMock(); + calculation.Attach(calculationObserver); + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); var gui = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); @@ -398,54 +398,53 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasChangesInDerivedInputAndUpdateDikeProfileClickedAndCancelled_ThenOutputNotRemovedAndObserversNotNotified() + public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasChangesAndUpdateClickedAndCancelled_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() { - using (var treeViewControl = new TreeViewControl()) + // Given + var assessmentSection = mocks.Stub(); + var dikeProfile = new TestDikeProfile(); + var calculation = new GrassCoverErosionInwardsCalculation { - // Given - var assessmentSection = mocks.Stub(); - var dikeProfile = new TestDikeProfile(); - var calculation = new GrassCoverErosionInwardsCalculation + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; + DikeProfile = dikeProfile + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; - GrassCoverErosionInwardsInput calculationInput = calculation.InputParameters; - RoundedDouble expectedOrientation = calculationInput.Orientation; - RoundedDouble expectedDikeHeight = calculationInput.DikeHeight; - bool expectedUseBreakWater = calculationInput.UseBreakWater; - BreakWater expectedBreakWater = calculationInput.BreakWater; - bool expectedUseForeshore = calculationInput.UseForeshore; + GrassCoverErosionInwardsInput calculationInput = calculation.InputParameters; + RoundedDouble expectedOrientation = calculationInput.Orientation; + RoundedDouble expectedDikeHeight = calculationInput.DikeHeight; + bool expectedUseBreakWater = calculationInput.UseBreakWater; + BreakWater expectedBreakWater = calculationInput.BreakWater; + bool expectedUseForeshore = calculationInput.UseForeshore; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); - var inputObserver = mocks.StrictMock(); - calculationInput.Attach(inputObserver); + var inputObserver = mocks.StrictMock(); + calculationInput.Attach(inputObserver); - var calculationObserver = mocks.StrictMock(); - calculation.Attach(calculationObserver); + var calculationObserver = mocks.StrictMock(); + calculation.Attach(calculationObserver); + string textBoxMessage = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + textBoxMessage = helper.Text; + helper.ClickCancel(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); var gui = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); plugin.Gui = gui; - - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickCancel(); - }; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // When @@ -474,32 +473,41 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasChangesInDerivedInputAndUpdateDikeProfileClickedAndContinued_ThenOutputRemovedAndObserversNotified() + public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasChangesUpdateDikeProfileClickedAndContinued_ThenInquiryAndUpdatesCalculationAndObserversNotified() { - using (var treeViewControl = new TreeViewControl()) + // Given + var assessmentSection = mocks.Stub(); + + var dikeProfile = new TestDikeProfile(); + var calculation = new GrassCoverErosionInwardsCalculation { - // Given - var assessmentSection = mocks.Stub(); - var dikeProfile = new TestDikeProfile(); - var calculation = new GrassCoverErosionInwardsCalculation + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + DikeProfile = dikeProfile + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); - var inputObserver = mocks.StrictMock(); - inputObserver.Expect(obs => obs.UpdateObserver()); - calculation.InputParameters.Attach(inputObserver); + var inputObserver = mocks.StrictMock(); + inputObserver.Expect(obs => obs.UpdateObserver()); + calculation.InputParameters.Attach(inputObserver); - var calculationObserver = mocks.StrictMock(); - calculationObserver.Expect(obs => obs.UpdateObserver()); - calculation.Attach(calculationObserver); + var calculationObserver = mocks.StrictMock(); + calculationObserver.Expect(obs => obs.UpdateObserver()); + calculation.Attach(calculationObserver); + string textBoxMessage = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + textBoxMessage = helper.Text; + helper.ClickOk(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); var gui = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); @@ -508,14 +516,6 @@ plugin.Gui = gui; - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickOk(); - }; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // When @@ -546,54 +546,63 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasNoChangeInDerivedInputAndUpdateDikeProfileClicked_ThenOutputNotRemovedAndObserversNotNotified() + public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasNoChangeAndUpdateClickedAndContinued_ThenInquiryAndCalculationNotUpdatedAndObserversNotNotified() { - using (var treeViewControl = new TreeViewControl()) - { - // Given - var assessmentSection = mocks.Stub(); + // Given + var assessmentSection = mocks.Stub(); - var dikeProfile = new DikeProfile(new Point2D(0, 0), - new[] - { - new RoughnessPoint(new Point2D(1.1, 2.2), 3), - new RoughnessPoint(new Point2D(3.3, 4.4), 5) - }, - new[] - { - new Point2D(1.1, 2.2), - new Point2D(3.3, 4.4) - }, - new BreakWater(BreakWaterType.Caisson, 10), - new DikeProfile.ConstructionProperties - { - Id = "ID" - }); - const double orientation = 10; - const double dikeHeight = 10; - const bool useBreakWater = true; - const bool useForeshore = true; - var calculation = new GrassCoverErosionInwardsCalculation + var dikeProfile = new DikeProfile(new Point2D(0, 0), + new[] + { + new RoughnessPoint(new Point2D(1.1, 2.2), 3), + new RoughnessPoint(new Point2D(3.3, 4.4), 5) + }, + new[] + { + new Point2D(1.1, 2.2), + new Point2D(3.3, 4.4) + }, + new BreakWater(BreakWaterType.Caisson, 10), + new DikeProfile.ConstructionProperties + { + Id = "ID" + }); + const double orientation = 10; + const double dikeHeight = 10; + const bool useBreakWater = true; + const bool useForeshore = true; + var calculation = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) dikeHeight, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = useBreakWater - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + DikeProfile = dikeProfile, + DikeHeight = (RoundedDouble) dikeHeight, + Orientation = (RoundedDouble) orientation, + UseForeshore = useForeshore, + UseBreakWater = useBreakWater + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; - var inputObserver = mocks.StrictMock(); - calculation.InputParameters.Attach(inputObserver); + var inputObserver = mocks.StrictMock(); + calculation.InputParameters.Attach(inputObserver); - var calculationObserver = mocks.StrictMock(); - calculation.Attach(calculationObserver); + var calculationObserver = mocks.StrictMock(); + calculation.Attach(calculationObserver); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + + string textBoxMessage = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + textBoxMessage = helper.Text; + helper.ClickOk(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); var gui = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); @@ -602,14 +611,6 @@ plugin.Gui = gui; - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickOk(); - }; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // When @@ -640,54 +641,48 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasPartialChangeInDerivedInputAndUpdateDikeProfileClicked_ThenOutputRemovedAndObserversNotified() + public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfilePartiallyChangedAndUpdateClicked_ThenInquiryAndUpdatesCalculationAndNotifiesObserver() { - using (var treeViewControl = new TreeViewControl()) - { - // Given - var assessmentSection = mocks.Stub(); + // Given + var assessmentSection = mocks.Stub(); - var dikeProfile = new DikeProfile(new Point2D(0, 0), - new[] - { - new RoughnessPoint(new Point2D(1.1, 2.2), 3), - new RoughnessPoint(new Point2D(3.3, 4.4), 5) - }, - new[] - { - new Point2D(1.1, 2.2), - new Point2D(3.3, 4.4) - }, - new BreakWater(BreakWaterType.Caisson, 10), - new DikeProfile.ConstructionProperties - { - Id = "ID" - }); - const double orientation = 10; - const bool useForeshore = true; - var calculation = new GrassCoverErosionInwardsCalculation + var dikeProfile = new TestDikeProfile(); + const double orientation = 10; + const bool useForeshore = true; + var calculation = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) 30.0, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = false - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + DikeProfile = dikeProfile, + DikeHeight = (RoundedDouble) 30.0, + Orientation = (RoundedDouble) orientation, + UseForeshore = useForeshore, + UseBreakWater = false + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; - var inputObserver = mocks.StrictMock(); - inputObserver.Expect(obs => obs.UpdateObserver()); - calculation.InputParameters.Attach(inputObserver); + var inputObserver = mocks.StrictMock(); + inputObserver.Expect(obs => obs.UpdateObserver()); + calculation.InputParameters.Attach(inputObserver); - var calculationObserver = mocks.StrictMock(); - calculationObserver.Expect(obs => obs.UpdateObserver()); - calculation.Attach(calculationObserver); + var calculationObserver = mocks.StrictMock(); + calculationObserver.Expect(obs => obs.UpdateObserver()); + calculation.Attach(calculationObserver); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationContext(calculation, failureMechanism, assessmentSection); + + string textBoxMessage = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + textBoxMessage = helper.Text; + helper.ClickOk(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); var gui = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); @@ -696,14 +691,6 @@ plugin.Gui = gui; - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickOk(); - }; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl)) { // When Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -r047258c748dbf834052838e22715ee54d8c97150 -r3be9b3d3afa5f4dc4ed422f774405c127baaaf4e --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 047258c748dbf834052838e22715ee54d8c97150) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Plugin.Test/TreeNodeInfos/GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs (.../GrassCoverErosionInwardsCalculationGroupContextTreeNodeInfoTest.cs) (revision 3be9b3d3afa5f4dc4ed422f774405c127baaaf4e) @@ -566,53 +566,53 @@ [Test] public void GivenCalculationsWithDikeProfileWithoutOutput_WhenDikeProfileUpdatedAndUpdateDikeProfileClicked_ThenNoInquiryAndCalculationUpdatedAndInputObserverNotified() { - using (var treeViewControl = new TreeViewControl()) - { - // Given - var calculation1InputObserver = mocks.StrictMock(); - calculation1InputObserver.Expect(obs => obs.UpdateObserver()); - var calculation2InputObserver = mocks.StrictMock(); - calculation2InputObserver.Expect(obs => obs.UpdateObserver()); + // Given + var calculation1InputObserver = mocks.StrictMock(); + calculation1InputObserver.Expect(obs => obs.UpdateObserver()); + var calculation2InputObserver = mocks.StrictMock(); + calculation2InputObserver.Expect(obs => obs.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - var calculation2Observer = mocks.StrictMock(); + var calculation1Observer = mocks.StrictMock(); + var calculation2Observer = mocks.StrictMock(); - var dikeProfile = new TestDikeProfile(); - var calculation1 = new GrassCoverErosionInwardsCalculation + var dikeProfile = new TestDikeProfile(); + var calculation1 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - } - }; - calculation1.Attach(calculation1Observer); - calculation1.InputParameters.Attach(calculation1InputObserver); + DikeProfile = dikeProfile + } + }; + calculation1.Attach(calculation1Observer); + calculation1.InputParameters.Attach(calculation1InputObserver); - var calculation2 = new GrassCoverErosionInwardsCalculation + var calculation2 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - } - }; - calculation2.Attach(calculation2Observer); - calculation2.InputParameters.Attach(calculation2InputObserver); + DikeProfile = dikeProfile + } + }; + calculation2.Attach(calculation2Observer); + calculation2.InputParameters.Attach(calculation2InputObserver); - var childGroup = new CalculationGroup(); - childGroup.Children.Add(calculation1); + var childGroup = new CalculationGroup(); + childGroup.Children.Add(calculation1); - var emptyChildGroup = new CalculationGroup(); - var group = new CalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(calculation2); + var emptyChildGroup = new CalculationGroup(); + var group = new CalculationGroup(); + group.Children.Add(childGroup); + group.Children.Add(emptyChildGroup); + group.Children.Add(calculation2); - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, - failureMechanism, - assessmentSection); + var assessmentSection = mocks.Stub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); gui.Stub(g => g.MainWindow).Return(mainWindow); @@ -653,82 +653,82 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasChangesInDerivedInputAndUpdateDikeProfileClickedAndCancelled_ThenOutputNotRemovedAndObserversNotNotified() + public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasChangesAndUpdateDikeProfileClickedAndCancelled_ThenInquiresAndCalculationsNotUpdatedAndObserversNotNotified() { // Given - using (var treeViewControl = new TreeViewControl()) - { - var calculation1InputObserver = mocks.StrictMock(); - var calculation2InputObserver = mocks.StrictMock(); + var calculation1InputObserver = mocks.StrictMock(); + var calculation2InputObserver = mocks.StrictMock(); - var calculation1Observer = mocks.StrictMock(); - var calculation2Observer = mocks.StrictMock(); + var calculation1Observer = mocks.StrictMock(); + var calculation2Observer = mocks.StrictMock(); - var dikeProfile = new TestDikeProfile(); - var calculation1 = new GrassCoverErosionInwardsCalculation + var dikeProfile = new TestDikeProfile(); + var calculation1 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation1.Attach(calculation1Observer); - calculation1.InputParameters.Attach(calculation1InputObserver); - GrassCoverErosionInwardsInput calculationInput1 = calculation1.InputParameters; - RoundedDouble expectedOrientation1 = calculationInput1.Orientation; - RoundedDouble expectedDikeHeight1 = calculationInput1.DikeHeight; - bool expectedUseBreakWater1 = calculationInput1.UseBreakWater; - BreakWater expectedBreakWater1 = calculationInput1.BreakWater; - bool expectedUseForeshore1 = calculationInput1.UseForeshore; + DikeProfile = dikeProfile + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + calculation1.Attach(calculation1Observer); + calculation1.InputParameters.Attach(calculation1InputObserver); + GrassCoverErosionInwardsInput calculationInput1 = calculation1.InputParameters; + RoundedDouble expectedOrientation1 = calculationInput1.Orientation; + RoundedDouble expectedDikeHeight1 = calculationInput1.DikeHeight; + bool expectedUseBreakWater1 = calculationInput1.UseBreakWater; + BreakWater expectedBreakWater1 = calculationInput1.BreakWater; + bool expectedUseForeshore1 = calculationInput1.UseForeshore; - var calculation2 = new GrassCoverErosionInwardsCalculation + var calculation2 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation2.Attach(calculation2Observer); - calculation2.InputParameters.Attach(calculation2InputObserver); - GrassCoverErosionInwardsInput calculationInput2 = calculation2.InputParameters; - RoundedDouble expectedOrientation2 = calculationInput2.Orientation; - RoundedDouble expectedDikeHeight2 = calculationInput2.DikeHeight; - bool expectedUseBreakWater2 = calculationInput2.UseBreakWater; - BreakWater expectedBreakWater2 = calculationInput2.BreakWater; - bool expectedUseForeshore2 = calculationInput2.UseForeshore; + DikeProfile = dikeProfile + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + calculation2.Attach(calculation2Observer); + calculation2.InputParameters.Attach(calculation2InputObserver); + GrassCoverErosionInwardsInput calculationInput2 = calculation2.InputParameters; + RoundedDouble expectedOrientation2 = calculationInput2.Orientation; + RoundedDouble expectedDikeHeight2 = calculationInput2.DikeHeight; + bool expectedUseBreakWater2 = calculationInput2.UseBreakWater; + BreakWater expectedBreakWater2 = calculationInput2.BreakWater; + bool expectedUseForeshore2 = calculationInput2.UseForeshore; - var childGroup = new CalculationGroup(); - childGroup.Children.Add(calculation1); + var childGroup = new CalculationGroup(); + childGroup.Children.Add(calculation1); - var emptyChildGroup = new CalculationGroup(); - var group = new CalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(calculation2); + var emptyChildGroup = new CalculationGroup(); + var group = new CalculationGroup(); + group.Children.Add(childGroup); + group.Children.Add(emptyChildGroup); + group.Children.Add(calculation2); - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, - failureMechanism, - assessmentSection); + var assessmentSection = mocks.Stub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + string textBoxMessage = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + textBoxMessage = helper.Text; + helper.ClickCancel(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); plugin.Gui = gui; - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickCancel(); - }; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -765,74 +765,73 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasChangesInDerivedInputAndUpdateDikeProfileClickedAndContinued_ThenOutputRemovedAndObserversNotified() + public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasChangesAndUpdateDikeProfileClickedAndContinued_ThenInquiresAndCalculationsUpdatedAndObserversNotified() { - using (var treeViewControl = new TreeViewControl()) - { - // Given - var calculation1InputObserver = mocks.StrictMock(); - calculation1InputObserver.Expect(obs => obs.UpdateObserver()); - var calculation2InputObserver = mocks.StrictMock(); - calculation2InputObserver.Expect(obs => obs.UpdateObserver()); + // Given + var calculation1InputObserver = mocks.StrictMock(); + calculation1InputObserver.Expect(obs => obs.UpdateObserver()); + var calculation2InputObserver = mocks.StrictMock(); + calculation2InputObserver.Expect(obs => obs.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(obs => obs.UpdateObserver()); - var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(obs => obs.UpdateObserver()); + var calculation1Observer = mocks.StrictMock(); + calculation1Observer.Expect(obs => obs.UpdateObserver()); + var calculation2Observer = mocks.StrictMock(); + calculation2Observer.Expect(obs => obs.UpdateObserver()); - var dikeProfile = new TestDikeProfile(); - var calculation1 = new GrassCoverErosionInwardsCalculation + var dikeProfile = new TestDikeProfile(); + var calculation1 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation1.Attach(calculation1Observer); - calculation1.InputParameters.Attach(calculation1InputObserver); + DikeProfile = dikeProfile + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + calculation1.Attach(calculation1Observer); + calculation1.InputParameters.Attach(calculation1InputObserver); - var calculation2 = new GrassCoverErosionInwardsCalculation + var calculation2 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation2.Attach(calculation2Observer); - calculation2.InputParameters.Attach(calculation2InputObserver); + DikeProfile = dikeProfile + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + calculation2.Attach(calculation2Observer); + calculation2.InputParameters.Attach(calculation2InputObserver); - var childGroup = new CalculationGroup(); - childGroup.Children.Add(calculation1); + var childGroup = new CalculationGroup(); + childGroup.Children.Add(calculation1); - var emptyChildGroup = new CalculationGroup(); - var group = new CalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(calculation2); + var emptyChildGroup = new CalculationGroup(); + var group = new CalculationGroup(); + group.Children.Add(childGroup); + group.Children.Add(emptyChildGroup); + group.Children.Add(calculation2); - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, - failureMechanism, - assessmentSection); + var assessmentSection = mocks.Stub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + string textBoxMessage = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + textBoxMessage = helper.Text; + helper.ClickOk(); + }; + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); gui.Stub(g => g.MainWindow).Return(mainWindow); mocks.ReplayAll(); plugin.Gui = gui; - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickOk(); - }; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -871,87 +870,95 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasNoChangeInDerivedInputAndUpdateDikeProfileClicked_ThenOutputNotRemovedAndObserversNotNotified() + public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasNoChangeAndUpdateClicked_ThenInquiresAndCalculationsNotUpdatedAndObserversNotNotified() { - using (var treeViewControl = new TreeViewControl()) - { - // Given - var calculation1InputObserver = mocks.StrictMock(); - var calculation2InputObserver = mocks.StrictMock(); + // Given + var calculation1InputObserver = mocks.StrictMock(); + var calculation2InputObserver = mocks.StrictMock(); - var calculation1Observer = mocks.StrictMock(); - var calculation2Observer = mocks.StrictMock(); + var calculation1Observer = mocks.StrictMock(); + var calculation2Observer = mocks.StrictMock(); - var dikeProfile = new DikeProfile(new Point2D(0, 0), - new[] - { - new RoughnessPoint(new Point2D(1.1, 2.2), 3), - new RoughnessPoint(new Point2D(3.3, 4.4), 5) - }, - new[] - { - new Point2D(1.1, 2.2), - new Point2D(3.3, 4.4) - }, - new BreakWater(BreakWaterType.Caisson, 10), - new DikeProfile.ConstructionProperties - { - Id = "ID" - }); - const double orientation = 10; - const double dikeHeight = 10; - const bool useBreakWater = true; - const bool useForeshore = true; - var calculation1 = new GrassCoverErosionInwardsCalculation + var dikeProfile = new DikeProfile(new Point2D(0, 0), + new[] + { + new RoughnessPoint(new Point2D(1.1, 2.2), 3), + new RoughnessPoint(new Point2D(3.3, 4.4), 5) + }, + new[] + { + new Point2D(1.1, 2.2), + new Point2D(3.3, 4.4) + }, + new BreakWater(BreakWaterType.Caisson, 10), + new DikeProfile.ConstructionProperties + { + Id = "ID" + }); + const double orientation = 10; + const double dikeHeight = 10; + const bool useBreakWater = true; + const bool useForeshore = true; + var calculation1 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) dikeHeight, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = useBreakWater - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation1.Attach(calculation1Observer); - calculation1.InputParameters.Attach(calculation1InputObserver); + DikeProfile = dikeProfile, + DikeHeight = (RoundedDouble) dikeHeight, + Orientation = (RoundedDouble) orientation, + UseForeshore = useForeshore, + UseBreakWater = useBreakWater + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + calculation1.Attach(calculation1Observer); + calculation1.InputParameters.Attach(calculation1InputObserver); - var calculation2 = new GrassCoverErosionInwardsCalculation + var calculation2 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) dikeHeight, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = useBreakWater - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation2.Attach(calculation2Observer); - calculation2.InputParameters.Attach(calculation2InputObserver); + DikeProfile = dikeProfile, + DikeHeight = (RoundedDouble) dikeHeight, + Orientation = (RoundedDouble) orientation, + UseForeshore = useForeshore, + UseBreakWater = useBreakWater + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + calculation2.Attach(calculation2Observer); + calculation2.InputParameters.Attach(calculation2InputObserver); - var childGroup = new CalculationGroup(); - childGroup.Children.Add(calculation1); + var childGroup = new CalculationGroup(); + childGroup.Children.Add(calculation1); - var emptyChildGroup = new CalculationGroup(); - var group = new CalculationGroup(); - var parentGroup = new CalculationGroup(); + var emptyChildGroup = new CalculationGroup(); + var group = new CalculationGroup(); + var parentGroup = new CalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(calculation2); + group.Children.Add(childGroup); + group.Children.Add(emptyChildGroup); + group.Children.Add(calculation2); - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, - failureMechanism, - assessmentSection); - var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup, - failureMechanism, - assessmentSection); + var assessmentSection = mocks.Stub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup, + failureMechanism, + assessmentSection); + string textBoxMessage = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + textBoxMessage = helper.Text; + helper.ClickOk(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); gui.Stub(g => g.MainWindow).Return(mainWindow); @@ -960,14 +967,6 @@ plugin.Gui = gui; - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickOk(); - }; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // When @@ -1006,89 +1005,82 @@ } [Test] - public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasPartialChangeInDerivedInputAndUpdateDikeProfileClicked_ThenOutputRemovedAndObserversNotified() + public void GivenCalculationWithDikeProfileWithOutput_WhenDikeProfileHasPartialChangesAndUpdateDikeProfileClicked_ThenInquiresAndCalculationsUpdatedAndObserversNotified() { - using (var treeViewControl = new TreeViewControl()) - { - // Given - var calculation1InputObserver = mocks.StrictMock(); - calculation1InputObserver.Expect(obs => obs.UpdateObserver()); - var calculation2InputObserver = mocks.StrictMock(); - calculation2InputObserver.Expect(obs => obs.UpdateObserver()); + // Given + var calculation1InputObserver = mocks.StrictMock(); + calculation1InputObserver.Expect(obs => obs.UpdateObserver()); + var calculation2InputObserver = mocks.StrictMock(); + calculation2InputObserver.Expect(obs => obs.UpdateObserver()); - var calculation1Observer = mocks.StrictMock(); - calculation1Observer.Expect(obs => obs.UpdateObserver()); - var calculation2Observer = mocks.StrictMock(); - calculation2Observer.Expect(obs => obs.UpdateObserver()); + var calculation1Observer = mocks.StrictMock(); + calculation1Observer.Expect(obs => obs.UpdateObserver()); + var calculation2Observer = mocks.StrictMock(); + calculation2Observer.Expect(obs => obs.UpdateObserver()); - var dikeProfile = new DikeProfile(new Point2D(0, 0), - new[] - { - new RoughnessPoint(new Point2D(1.1, 2.2), 3), - new RoughnessPoint(new Point2D(3.3, 4.4), 5) - }, - new[] - { - new Point2D(1.1, 2.2), - new Point2D(3.3, 4.4) - }, - new BreakWater(BreakWaterType.Caisson, 10), - new DikeProfile.ConstructionProperties - { - Id = "ID" - }); - const double orientation = 10; - const bool useForeshore = true; - var calculation1 = new GrassCoverErosionInwardsCalculation + var dikeProfile = new TestDikeProfile(); + const double orientation = 10; + const bool useForeshore = true; + var calculation1 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) 30, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = false - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation1.Attach(calculation1Observer); - calculation1.InputParameters.Attach(calculation1InputObserver); + DikeProfile = dikeProfile, + DikeHeight = (RoundedDouble) 30, + Orientation = (RoundedDouble) orientation, + UseForeshore = useForeshore, + UseBreakWater = false + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + calculation1.Attach(calculation1Observer); + calculation1.InputParameters.Attach(calculation1InputObserver); - var calculation2 = new GrassCoverErosionInwardsCalculation + var calculation2 = new GrassCoverErosionInwardsCalculation + { + InputParameters = { - InputParameters = - { - DikeProfile = dikeProfile, - DikeHeight = (RoundedDouble) 30, - Orientation = (RoundedDouble) orientation, - UseForeshore = useForeshore, - UseBreakWater = false - }, - Output = new TestGrassCoverErosionInwardsOutput() - }; - calculation2.Attach(calculation2Observer); - calculation2.InputParameters.Attach(calculation2InputObserver); + DikeProfile = dikeProfile, + DikeHeight = (RoundedDouble) 30, + Orientation = (RoundedDouble) orientation, + UseForeshore = useForeshore, + UseBreakWater = false + }, + Output = new TestGrassCoverErosionInwardsOutput() + }; + calculation2.Attach(calculation2Observer); + calculation2.InputParameters.Attach(calculation2InputObserver); - var childGroup = new CalculationGroup(); - childGroup.Children.Add(calculation1); + var childGroup = new CalculationGroup(); + childGroup.Children.Add(calculation1); - var emptyChildGroup = new CalculationGroup(); - var group = new CalculationGroup(); - var parentGroup = new CalculationGroup(); + var emptyChildGroup = new CalculationGroup(); + var group = new CalculationGroup(); + var parentGroup = new CalculationGroup(); - group.Children.Add(childGroup); - group.Children.Add(emptyChildGroup); - group.Children.Add(calculation2); + group.Children.Add(childGroup); + group.Children.Add(emptyChildGroup); + group.Children.Add(calculation2); - var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, - failureMechanism, - assessmentSection); - var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup, - failureMechanism, - assessmentSection); + var assessmentSection = mocks.Stub(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(group, + failureMechanism, + assessmentSection); + var parentNodeData = new GrassCoverErosionInwardsCalculationGroupContext(parentGroup, + failureMechanism, + assessmentSection); + string textBoxMessage = null; + DialogBoxHandler = (name, wnd) => + { + var helper = new MessageBoxTester(wnd); + textBoxMessage = helper.Text; + helper.ClickOk(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var mainWindow = mocks.Stub(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); gui.Stub(g => g.MainWindow).Return(mainWindow); @@ -1097,14 +1089,6 @@ plugin.Gui = gui; - string textBoxMessage = null; - DialogBoxHandler = (name, wnd) => - { - var helper = new MessageBoxTester(wnd); - textBoxMessage = helper.Text; - helper.ClickOk(); - }; - using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, parentNodeData, treeViewControl)) { // When @@ -1809,39 +1793,49 @@ public void GivenCalculationsViewGenerateScenariosButtonClicked_WhenDikeProfileSelectedAndDialogClosed_ThenCalculationsAddedWithProfileAssigned() { // Given - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - DikeProfile dikeProfile1 = new TestDikeProfile("Dike profile 1", "id1"); - DikeProfile dikeProfile2 = new TestDikeProfile("Dike profile 2", "id2"); + var assessmentSection = mocks.Stub(); - var existingCalculationGroup = new CalculationGroup(); - var existingCalculation = new GrassCoverErosionInwardsCalculation(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + DikeProfile dikeProfile1 = new TestDikeProfile("Dike profile 1", "id1"); + DikeProfile dikeProfile2 = new TestDikeProfile("Dike profile 2", "id2"); + + var existingCalculationGroup = new CalculationGroup(); + var existingCalculation = new GrassCoverErosionInwardsCalculation(); + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + CalculationsGroup = { - CalculationsGroup = + Children = { - Children = - { - existingCalculationGroup, - existingCalculation - } + existingCalculationGroup, + existingCalculation } - }; - failureMechanism.DikeProfiles.AddRange(new[] - { - dikeProfile1, - dikeProfile2 - }, dikeProfileCollectionPath); + } + }; + failureMechanism.DikeProfiles.AddRange(new[] + { + dikeProfile1, + dikeProfile2 + }, dikeProfileCollectionPath); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(failureMechanism.CalculationsGroup, - failureMechanism, - assessmentSection); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + DialogBoxHandler = (name, wnd) => + { + var selectionDialog = (GrassCoverErosionInwardsDikeProfileSelectionDialog) new FormTester(name).TheObject; + var grid = (DataGridViewControl) new ControlTester("DataGridViewControl", selectionDialog).TheObject; + + grid.Rows[0].Cells[0].Value = true; + + new ButtonTester("DoForSelectedButton", selectionDialog).Click(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); - gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); gui.Stub(g => g.MainWindow).Return(mainWindow); gui.Stub(cmp => cmp.ViewCommands).Return(mocks.Stub()); @@ -1850,16 +1844,6 @@ plugin.Gui = gui; - DialogBoxHandler = (name, wnd) => - { - var selectionDialog = (GrassCoverErosionInwardsDikeProfileSelectionDialog) new FormTester(name).TheObject; - var grid = (DataGridViewControl) new ControlTester("DataGridViewControl", selectionDialog).TheObject; - - grid.Rows[0].Cells[0].Value = true; - - new ButtonTester("DoForSelectedButton", selectionDialog).Click(); - }; - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -1880,24 +1864,35 @@ public void GivenCalculationsViewGenerateScenariosButtonClicked_WhenCancelButtonClickedAndDialogClosed_ThenCalculationsNotUpdated() { // Given - using (var treeViewControl = new TreeViewControl()) + var assessmentSection = mocks.Stub(); + + DikeProfile dikeProfile1 = new TestDikeProfile("Dike profile 1", "id1"); + DikeProfile dikeProfile2 = new TestDikeProfile("Dike profile 2", "id2"); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + failureMechanism.DikeProfiles.AddRange(new[] { - var assessmentSection = mocks.Stub(); + dikeProfile1, + dikeProfile2 + }, dikeProfileCollectionPath); - DikeProfile dikeProfile1 = new TestDikeProfile("Dike profile 1", "id1"); - DikeProfile dikeProfile2 = new TestDikeProfile("Dike profile 2", "id2"); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - failureMechanism.DikeProfiles.AddRange(new[] - { - dikeProfile1, - dikeProfile2 - }, dikeProfileCollectionPath); + DialogBoxHandler = (name, wnd) => - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(failureMechanism.CalculationsGroup, - failureMechanism, - assessmentSection); + { + var selectionDialog = (GrassCoverErosionInwardsDikeProfileSelectionDialog) new FormTester(name).TheObject; + var grid = (DataGridViewControl) new ControlTester("DataGridViewControl", selectionDialog).TheObject; + grid.Rows[0].Cells[0].Value = true; + + new ButtonTester("CustomCancelButton", selectionDialog).Click(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -1909,16 +1904,6 @@ plugin.Gui = gui; - DialogBoxHandler = (name, wnd) => - { - var selectionDialog = (GrassCoverErosionInwardsDikeProfileSelectionDialog) new FormTester(name).TheObject; - var grid = (DataGridViewControl) new ControlTester("DataGridViewControl", selectionDialog).TheObject; - - grid.Rows[0].Cells[0].Value = true; - - new ButtonTester("CustomCancelButton", selectionDialog).Click(); - }; - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // When @@ -1934,35 +1919,46 @@ public void GivenScenariosWithExistingCalculationWithSameName_WhenOkButtonClickedAndDialogClosed_ThenCalculationWithUniqueNameAdded() { // Given - using (var treeViewControl = new TreeViewControl()) - { - var assessmentSection = mocks.Stub(); - const string existingCalculationName = "Dike profile"; - DikeProfile dikeProfile = new TestDikeProfile(existingCalculationName); + var assessmentSection = mocks.Stub(); - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + const string existingCalculationName = "Dike profile"; + DikeProfile dikeProfile = new TestDikeProfile(existingCalculationName); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism + { + CalculationsGroup = { - CalculationsGroup = + Children = { - Children = + new GrassCoverErosionInwardsCalculation { - new GrassCoverErosionInwardsCalculation - { - Name = existingCalculationName - } + Name = existingCalculationName } } - }; - failureMechanism.DikeProfiles.AddRange(new[] - { - dikeProfile - }, dikeProfileCollectionPath); + } + }; + failureMechanism.DikeProfiles.AddRange(new[] + { + dikeProfile + }, dikeProfileCollectionPath); - var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(failureMechanism.CalculationsGroup, - failureMechanism, - assessmentSection); + var nodeData = new GrassCoverErosionInwardsCalculationGroupContext(failureMechanism.CalculationsGroup, + failureMechanism, + assessmentSection); + DialogBoxHandler = (name, wnd) => + { + var selectionDialog = (GrassCoverErosionInwardsDikeProfileSelectionDialog) new FormTester(name).TheObject; + var grid = (DataGridViewControl) new ControlTester("DataGridViewControl", selectionDialog).TheObject; + + grid.Rows[0].Cells[0].Value = true; + + new ButtonTester("DoForSelectedButton", selectionDialog).Click(); + }; + + using (var treeViewControl = new TreeViewControl()) + { var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var mainWindow = mocks.Stub(); @@ -1974,16 +1970,6 @@ plugin.Gui = gui; - DialogBoxHandler = (name, wnd) => - { - var selectionDialog = (GrassCoverErosionInwardsDikeProfileSelectionDialog) new FormTester(name).TheObject; - var grid = (DataGridViewControl) new ControlTester("DataGridViewControl", selectionDialog).TheObject; - - grid.Rows[0].Cells[0].Value = true; - - new ButtonTester("DoForSelectedButton", selectionDialog).Click(); - }; - using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { string expectedNewName = NamingHelper.GetUniqueName(failureMechanism.CalculationsGroup.Children, existingCalculationName, c => c.Name);