public void ContextMenuStrip_HydraulicBoundaryDatabaseNotLinked_ContextMenuItemCalculateAllDisabled()
        {
            // Setup
            using (var treeView = new TreeViewControl())
            {
                var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
                var context           = new HydraulicLoadsStateRootContext(assessmentSection);
                var menuBuilder       = new CustomItemsOnlyContextMenuBuilder();

                var  mocks = new MockRepository();
                IGui gui   = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip menu = GetInfo(plugin).ContextMenuStrip(context, null, treeView))
                    {
                        // Assert
                        Assert.AreEqual(10, menu.Items.Count);

                        TestHelper.AssertContextMenuStripContainsItem(
                            menu, contextMenuCalculateAllIndex,
                            "Alles be&rekenen",
                            "Er is geen hydraulische belastingendatabase geïmporteerd.",
                            RiskeerCommonFormsResources.CalculateAllIcon,
                            false);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void ContextMenuStrip_Always_CallsBuilder()
        {
            // Setup
            var mocks       = new MockRepository();
            var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();

            using (mocks.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.Build()).Return(null);
            }

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder);
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);
                    plugin.Gui = gui;

                    // Call
                    info.ContextMenuStrip(null, null, treeViewControl);
                }
            }

            // Assert
            mocks.VerifyAll();
        }
Ejemplo n.º 3
0
        public void GivenCalculationsWithIllustrationPoints_WhenClearIllustrationPointsClickedAndContinue_ThenInquiryAndIllustrationPointsCleared(
            Func <IAssessmentSection, HydraulicBoundaryLocationCalculation> getHydraulicLocationCalculationFunc)
        {
            // Given
            var random = new Random(21);
            IAssessmentSection assessmentSection             = GetConfiguredAssessmentSectionWithHydraulicBoundaryLocationCalculations();
            HydraulicBoundaryLocationCalculation calculation = getHydraulicLocationCalculationFunc(assessmentSection);

            calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble(), new TestGeneralResultSubMechanismIllustrationPoint());

            HydraulicBoundaryLocationCalculation[] calculationsWithOutput = GetAllWaterLevelCalculationsWithOutput(assessmentSection).ToArray();

            var messageBoxText = "";

            DialogBoxHandler = (name, wnd) =>
            {
                var helper = new MessageBoxTester(wnd);
                messageBoxText = helper.Text;

                helper.ClickOk();
            };

            var context = new WaterLevelCalculationsForNormTargetProbabilitiesGroupContext(new ObservableList <HydraulicBoundaryLocation>(), assessmentSection);

            var mockRepository = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                var calculationObserver = mockRepository.StrictMock <IObserver>();
                calculationObserver.Expect(o => o.UpdateObserver());

                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub <IMainWindow>());
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                mockRepository.ReplayAll();

                calculation.Attach(calculationObserver);

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);
                    plugin.Gui = gui;

                    using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
                    {
                        // When
                        contextMenuAdapter.Items[contextMenuClearIllustrationPointsIndex].PerformClick();

                        // Then
                        const string expectedMessage = "Weet u zeker dat u alle berekende illustratiepunten bij 'Waterstanden bij vaste doelkans' wilt wissen?";
                        Assert.AreEqual(expectedMessage, messageBoxText);

                        Assert.IsTrue(calculationsWithOutput.All(calc => calc.HasOutput));
                        Assert.IsFalse(calculation.Output.HasGeneralResult);
                    }
                }
            }

            mockRepository.VerifyAll();
        }
Ejemplo n.º 4
0
        public void ContextMenuStrip_WithSpecificAssessmentSectionConfiguration_CalculateAllMenuItemStateAsExpected(AssessmentSection assessmentSection, bool expectedEnabledState)
        {
            // Setup
            using (var treeView = new TreeViewControl())
            {
                var context     = new CalculationsStateRootContext(assessmentSection);
                var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

                var  mocks = new MockRepository();
                IGui gui   = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip menu = GetInfo(plugin).ContextMenuStrip(context, null, treeView))
                    {
                        // Assert
                        Assert.AreEqual(10, menu.Items.Count);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex,
                                                                      "Alles be&rekenen",
                                                                      expectedEnabledState
                                                                          ? "Voer alle berekeningen binnen dit traject uit."
                                                                          : "Er zijn geen berekeningen om uit te voeren.",
                                                                      RiskeerCommonFormsResources.CalculateAllIcon,
                                                                      expectedEnabledState);
                    }
                }
            }
        }
        public void ContextMenuStrip_Always_CallsBuilder()
        {
            // Setup
            var mocks       = new MockRepository();
            var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();

            menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder);
            menuBuilder.Expect(mb => mb.Build()).Return(null);

            IGui gui = StubFactory.CreateGuiStub(mocks);

            using (var treeViewControl = new TreeViewControl())
            {
                gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder);

                mocks.ReplayAll();

                using (var p = new RiskeerPlugin())
                {
                    p.Gui = gui;
                    TreeNodeInfo i = p.GetTreeNodeInfos().First(tni => tni.TagType == typeof(DikeProfile));

                    // Call
                    i.ContextMenuStrip(null, null, treeViewControl);
                }
            }

            // Assert
            mocks.VerifyAll();
        }
Ejemplo n.º 6
0
        public void ContextMenuStrip_Always_AddCustomItems()
        {
            // Setup
            var failureMechanisms = new ObservableList <SpecificFailureMechanism>();
            var assessmentSection = mocks.Stub <IAssessmentSection>();
            var context           = new SpecificFailureMechanismsContext(failureMechanisms, assessmentSection);

            var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

            using (var treeView = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
                mocks.ReplayAll();

                plugin.Gui = gui;

                // Call
                using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView))
                {
                    // Assert
                    Assert.AreEqual(6, menu.Items.Count);
                    TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCreateFailureMechanismIndex,
                                                                  "Faalmechanisme toevoegen",
                                                                  "Voeg een nieuw faalmechanisme toe aan deze map.",
                                                                  RiskeerCommonFormsResources.FailureMechanismIcon);
                }
            }
        }
Ejemplo n.º 7
0
        public void ContextMenuStrip_Always_CallsBuilder()
        {
            // Setup
            var mocks       = new MockRepository();
            var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();

            menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder);
            menuBuilder.Expect(mb => mb.Build()).Return(null);

            using (plugin)
                using (var treeViewControl = new TreeViewControl())
                {
                    IGui gui = StubFactory.CreateGuiStub(mocks);
                    gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder);

                    mocks.ReplayAll();

                    plugin.Gui = gui;

                    // Call
                    info.ContextMenuStrip(null, null, treeViewControl);
                }

            // Assert
            mocks.VerifyAll();
        }
Ejemplo n.º 8
0
        public void ContextMenuStrip_Always_AddCustomItems()
        {
            // Setup
            using (var treeView = new TreeViewControl())
            {
                var assessmentSection        = new AssessmentSection(AssessmentSectionComposition.Dike);
                var assessmentSectionContext = new AssessmentSectionStateRootContext(assessmentSection);
                var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

                var  mocks = new MockRepository();
                IGui gui   = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(assessmentSectionContext, treeView)).Return(menuBuilder);
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip menu = GetInfo(plugin).ContextMenuStrip(assessmentSectionContext, null, treeView))
                    {
                        // Assert
                        Assert.AreEqual(10, menu.Items.Count);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuImportAssessmentSectionIndex,
                                                                      "&Importeren...",
                                                                      "Importeer de gegevens vanuit een bestand.",
                                                                      CoreGuiResources.ImportIcon);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public void ContextMenuStrip_Always_ContextMenuItemSelectMapLayerEnabled()
        {
            // Setup
            var backgroundData = new BackgroundData(new TestBackgroundDataConfiguration());

            var mockRepository = new MockRepository();
            var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(new AssessmentSection(AssessmentSectionComposition.Dike));

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(g => g.Get(backgroundData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                mockRepository.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);
                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(backgroundData, assessmentSectionStateRootContext, treeViewControl))
                    {
                        const string expectedItemText    = "&Selecteren...";
                        const string expectedItemTooltip = "Selecteer een achtergrondkaart.";
                        TestHelper.AssertContextMenuStripContainsItem(contextMenu, selectContextMenuIndex,
                                                                      expectedItemText, expectedItemTooltip,
                                                                      RiskeerCommonFormsResources.MapsIcon);
                    }
                }
            }

            // Assert
            mockRepository.VerifyAll();
        }
Ejemplo n.º 10
0
        public void ContextMenuStrip_Always_ReturnsExpectedItem()
        {
            // Setup
            using (var treeView = new TreeViewControl())
            {
                var failureMechanisms = new ObservableList <SpecificFailureMechanism>();
                var assessmentSection = mocks.Stub <IAssessmentSection>();
                var context           = new SpecificFailureMechanismsContext(failureMechanisms, assessmentSection);

                var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();
                using (mocks.Ordered())
                {
                    menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                    menuBuilder.Expect(mb => mb.AddDeleteChildrenItem()).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.Build()).Return(null);
                }

                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
                mocks.ReplayAll();

                plugin.Gui = gui;

                // Call
                info.ContextMenuStrip(context, assessmentSection, treeView);

                // Assert
                // Assert expectancies are called in TearDown()
            }
        }
Ejemplo n.º 11
0
        public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
        {
            // Setup
            var menuBuilder = mocksRepository.StrictMock <IContextMenuBuilder>();

            using (mocksRepository.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddOpenItem()).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())
            {
                IGui gui = StubFactory.CreateGuiStub(mocksRepository);
                gui.Stub(cmp => cmp.Get(null, treeViewControl)).Return(menuBuilder);
                mocksRepository.ReplayAll();

                plugin.Gui = gui;

                // Call
                info.ContextMenuStrip(null, null, treeViewControl);
            }

            // Assert
            // Assert expectancies called in TearDown()
        }
Ejemplo n.º 12
0
        public void CreateInstance_WithContext_SetsFailureMechanismContributionAsData()
        {
            // Setup
            var  mocks             = new MockRepository();
            var  assessmentSection = mocks.Stub <IAssessmentSection>();
            var  viewCommands      = mocks.Stub <IViewCommands>();
            IGui gui = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.ViewCommands).Return(viewCommands);
            mocks.ReplayAll();

            using (var plugin = new RiskeerPlugin())
            {
                plugin.Gui = gui;

                FailureMechanismContribution failureMechanismContribution = FailureMechanismContributionTestFactory.CreateFailureMechanismContribution();
                var context = new NormContext(failureMechanismContribution, assessmentSection);

                PropertyInfo info = GetInfo(plugin);

                // Call
                IObjectProperties objectProperties = info.CreateInstance(context);

                // Assert
                Assert.IsInstanceOf <NormProperties>(objectProperties);
                Assert.AreSame(failureMechanismContribution, objectProperties.Data);
            }

            mocks.VerifyAll();
        }
Ejemplo n.º 13
0
        public void ContextMenuStrip_WaterLevelCalculationsWithoutIllustrationPoints_ContextMenuItemClearAllIllustrationPointsDisabled()
        {
            // Setup
            IAssessmentSection assessmentSection = GetConfiguredAssessmentSectionWithHydraulicBoundaryLocationCalculations();

            var nodeData = new WaterLevelCalculationsForNormTargetProbabilitiesGroupContext(new ObservableList <HydraulicBoundaryLocation>(), assessmentSection);

            var mockRepository = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub <IMainWindow>());
                mockRepository.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
                    {
                        // Assert
                        ToolStripItem contextMenuItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex];
                        Assert.IsFalse(contextMenuItem.Enabled);
                    }
                }
            }

            mockRepository.VerifyAll(); // Expect no calls on arguments
        }
        public void CreateInstance_WithContext_SetsData()
        {
            // Setup
            var  mocks             = new MockRepository();
            var  assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var  viewCommands      = mocks.Stub <IViewCommands>();
            IGui gui = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.ViewCommands).Return(viewCommands);
            mocks.ReplayAll();

            using (var plugin = new RiskeerPlugin())
            {
                plugin.Gui = gui;

                var context = new TestStateRootContext(assessmentSection);

                PropertyInfo info = GetInfo(plugin);

                // Call
                IObjectProperties objectProperties = info.CreateInstance(context);

                // Assert
                Assert.IsInstanceOf <AssessmentSectionProperties>(objectProperties);
                Assert.AreSame(assessmentSection, objectProperties.Data);
            }

            mocks.VerifyAll();
        }
Ejemplo n.º 15
0
        public void GivenMapDataSet_WhenSelectingMapDataFromContextMenuCancelled_ThenNoObserversNotified()
        {
            // Given
            var mockRepository            = new MockRepository();
            var assessmentSectionObserver = mockRepository.StrictMock <IObserver>();
            var backgroundDataObserver    = mockRepository.StrictMock <IObserver>();

            WmtsMapData    mapData        = WmtsMapDataTestHelper.CreateUnconnectedMapData();
            BackgroundData backgroundData = BackgroundDataConverter.ConvertTo(mapData);

            WmtsMapData    newMapData        = WmtsMapDataTestHelper.CreateDefaultPdokMapData();
            BackgroundData newBackgroundData = BackgroundDataConverter.ConvertTo(newMapData);

            using (new UseCustomSettingsHelper(new TestSettingsHelper
            {
                ApplicationLocalUserSettingsDirectory = TestHelper.GetTestDataPath(TestDataPath.Core.Components.Gis.IO, "noConfig")
            }))
                using (new UseCustomTileSourceFactoryConfig(newMapData))
                    using (var treeViewControl = new TreeViewControl())
                        using (var plugin = new RiskeerPlugin())
                        {
                            var viewCommands = mockRepository.Stub <IViewCommands>();
                            var mainWindow   = mockRepository.Stub <IMainWindow>();

                            IGui gui = StubFactory.CreateGuiStub(mockRepository);
                            gui.Stub(g => g.MainWindow).Return(mainWindow);
                            gui.Stub(g => g.ViewCommands).Return(viewCommands);
                            gui.Stub(cmp => cmp.Get(newBackgroundData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                            mockRepository.ReplayAll();

                            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
                            var assessmentSectionStateRootContext = new AssessmentSectionStateRootContext(assessmentSection);
                            assessmentSection.Attach(assessmentSectionObserver);
                            assessmentSection.BackgroundData.Attach(backgroundDataObserver);

                            SetBackgroundData(assessmentSection, mapData);

                            DialogBoxHandler = (name, wnd) =>
                            {
                                var tester = (BackgroundMapDataSelectionDialog) new FormTester(name).TheObject;
                                tester.DialogResult = DialogResult.Cancel;
                                tester.Close();
                            };

                            TreeNodeInfo info = GetInfo(plugin);
                            plugin.Gui = gui;

                            using (ContextMenuStrip contextMenuStrip = info.ContextMenuStrip(newBackgroundData, assessmentSectionStateRootContext, treeViewControl))
                            {
                                // When
                                contextMenuStrip.Items[selectContextMenuIndex].PerformClick();

                                // Then
                                BackgroundDataTestHelper.AssertBackgroundData(backgroundData, assessmentSection.BackgroundData);
                            }
                        }

            mockRepository.VerifyAll();
        }
Ejemplo n.º 16
0
        public void ContextMenuStrip_ClickOnAddTargetProbabilityItem_CalculationsForTargetProbabilityAddedAndObserversNotified()
        {
            // Given
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
            {
                HydraulicBoundaryDatabase =
                {
                    Locations =
                    {
                        new TestHydraulicBoundaryLocation("Location 1"),
                        new TestHydraulicBoundaryLocation("Location 2")
                    }
                }
            };

            var calculations = new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>();
            var context      = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculations, assessmentSection);

            var mockRepository       = new MockRepository();
            var calculationsObserver = mockRepository.StrictMock <IObserver>();

            calculationsObserver.Expect(o => o.UpdateObserver());
            calculations.Attach(calculationsObserver);

            using (var treeViewControl = new TreeViewControl())
            {
                IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mockRepository);

                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(g => g.MainWindow).Return(mainWindow);
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                gui.Stub(g => g.ProjectStore).Return(mockRepository.Stub <IStoreProject>());
                gui.Stub(g => g.DocumentViewController).Return(mockRepository.Stub <IDocumentViewController>());

                mockRepository.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);
                    plugin.Gui = gui;
                    plugin.Activate();

                    using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
                    {
                        // When
                        contextMenuAdapter.Items[contextMenuAddTargetProbabilityIndex].PerformClick();

                        // Then
                        Assert.AreEqual(1, calculations.Count);
                        Assert.AreEqual(0.01, calculations[0].TargetProbability);
                        Assert.AreEqual(2, calculations[0].HydraulicBoundaryLocationCalculations.Count);
                    }
                }
            }

            mockRepository.VerifyAll();
        }
Ejemplo n.º 17
0
        public void ContextMenuStrip_ClickOnAddTargetProbabilityItem_CalculationsForTargetProbabilityAddedAndObserversNotified()
        {
            // Given
            var failureMechanism = new DuneErosionFailureMechanism();

            failureMechanism.SetDuneLocations(new[]
            {
                new TestDuneLocation("Location 1"),
                new TestDuneLocation("Location 2")
            });

            var calculations = new ObservableList <DuneLocationCalculationsForTargetProbability>();
            var context      = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculations,
                                                                                                         failureMechanism,
                                                                                                         new AssessmentSectionStub());

            var mockRepository       = new MockRepository();
            var calculationsObserver = mockRepository.StrictMock <IObserver>();

            calculationsObserver.Expect(o => o.UpdateObserver());
            calculations.Attach(calculationsObserver);

            using (var treeViewControl = new TreeViewControl())
            {
                IMainWindow mainWindow = MainWindowTestHelper.CreateMainWindowStub(mockRepository);

                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(g => g.MainWindow).Return(mainWindow);
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());

                mockRepository.ReplayAll();

                using (var plugin = new DuneErosionPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);
                    plugin.Gui = gui;
                    plugin.Activate();

                    using (ContextMenuStrip contextMenuAdapter = info.ContextMenuStrip(context, null, treeViewControl))
                    {
                        // When
                        contextMenuAdapter.Items[contextMenuAddTargetProbabilityIndex].PerformClick();

                        // Then
                        Assert.AreEqual(1, calculations.Count);
                        Assert.AreEqual(0.01, calculations[0].TargetProbability);
                        Assert.AreEqual(2, calculations[0].DuneLocationCalculations.Count);
                    }
                }
            }

            mockRepository.VerifyAll();
        }
Ejemplo n.º 18
0
        public void ContextMenuStrip_Always_AddCustomItems()
        {
            // Setup
            IAssessmentSection assessmentSection = new AssessmentSectionStub();
            var menuBuilder = new CustomItemsOnlyContextMenuBuilder();
            var nodeData    = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>(),
                                                                                                      assessmentSection);

            var mockRepository = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
                gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub <IMainWindow>());
                mockRepository.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip menu = info.ContextMenuStrip(nodeData, assessmentSection, treeViewControl))
                    {
                        // Assert
                        Assert.AreEqual(11, menu.Items.Count);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuAddTargetProbabilityIndex,
                                                                      "Doelkans toevoegen",
                                                                      "Voeg een nieuwe doelkans toe aan deze map.",
                                                                      RiskeerCommonFormsResources.GenericInputOutputIcon);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuRunWaveHeightCalculationsIndex,
                                                                      "Alles be&rekenen",
                                                                      "Er is geen hydraulische belastingendatabase geïmporteerd.",
                                                                      RiskeerCommonFormsResources.CalculateAllIcon,
                                                                      false);

                        TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearIllustrationPointsIndex,
                                                                      "Wis alle illustratiepunten...",
                                                                      "Er zijn geen berekeningen met illustratiepunten om te wissen.",
                                                                      RiskeerCommonFormsResources.ClearIllustrationPointsIcon,
                                                                      false);
                    }
                }
            }

            // Assert
            mockRepository.VerifyAll();
        }
Ejemplo n.º 19
0
        public void ContextMenuStrip_Always_AddImportItem()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var context           = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase,
                                                                         assessmentSection);

            var applicationFeatureCommands = mocks.Stub <IApplicationFeatureCommands>();
            var importCommandHandler       = mocks.Stub <IImportCommandHandler>();

            importCommandHandler.Stub(ich => ich.GetSupportedImportInfos(null)).IgnoreArguments().Return(new[]
            {
                new ImportInfo()
            });
            var exportCommandHandler = mocks.Stub <IExportCommandHandler>();
            var updateCommandHandler = mocks.Stub <IUpdateCommandHandler>();
            var viewCommands         = mocks.Stub <IViewCommands>();

            using (var treeViewControl = new TreeViewControl())
            {
                var builder = new ContextMenuBuilder(applicationFeatureCommands,
                                                     importCommandHandler,
                                                     exportCommandHandler,
                                                     updateCommandHandler,
                                                     viewCommands,
                                                     context,
                                                     treeViewControl);

                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(g => g.Get(context, treeViewControl)).Return(builder);
                gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub <IMainWindow>());
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);
                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(context, assessmentSection, treeViewControl))
                    {
                        TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuImportHydraulicBoundaryDatabaseIndex,
                                                                      "&Koppel aan database...",
                                                                      "Koppel aan hydraulische belastingendatabase.",
                                                                      RiskeerCommonFormsResources.DatabaseIcon);
                    }
                }
            }

            // Assert
            mocks.VerifyAll();
        }
Ejemplo n.º 20
0
        public void ContextMenuStrip_HydraulicBoundaryLocationCalculationsWithIllustrationPoints_ContextMenuItemClearAllIllustrationPointsEnabledAndTooltipSet(
            Func <IAssessmentSection, HydraulicBoundaryLocationCalculation> getHydraulicBoundaryLocationCalculationFunc)
        {
            // Setup
            var random            = new Random(21);
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);

            SetHydraulicBoundaryLocationCalculationsForUserDefinedTargetProbabilities(assessmentSection);

            assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
            {
                new TestHydraulicBoundaryLocation()
            });

            HydraulicBoundaryLocationCalculation calculation = getHydraulicBoundaryLocationCalculationFunc(assessmentSection);

            calculation.Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble(), new TestGeneralResultSubMechanismIllustrationPoint());

            var nodeData = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection);

            var mockRepository = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub <IMainWindow>());
                mockRepository.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
                    {
                        // Assert
                        ToolStripItem contextMenuItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex];

                        Assert.AreEqual("Wis alle illustratiepunten...", contextMenuItem.Text);
                        Assert.AreEqual("Wis alle berekende illustratiepunten.", contextMenuItem.ToolTipText);
                        TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.ClearIllustrationPointsIcon, contextMenuItem.Image);
                        Assert.IsTrue(contextMenuItem.Enabled);
                    }
                }
            }

            mockRepository.VerifyAll(); // Expect no calls on arguments
        }
        public void SetUp()
        {
            mocks = new MockRepository();
            IGui gui = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.ViewCommands).Return(mocks.Stub <IViewCommands>());
            mocks.ReplayAll();

            plugin = new RiskeerPlugin
            {
                Gui = gui
            };
            importInfo = plugin.GetImportInfos().First(i => i.DataType == typeof(HydraulicBoundaryDatabaseContext));
        }
Ejemplo n.º 22
0
        public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllDisabledAndTooltipSet()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
            {
                HydraulicBoundaryDatabase =
                {
                    FilePath = "invalidFilePath"
                }
            };

            var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("locationName");

            assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
            {
                hydraulicBoundaryLocation
            });

            var nodeData = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase, assessmentSection);

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub <IMainWindow>());
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    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);
                    }
                }
            }

            mocks.VerifyAll(); // Expect no calls on arguments
        }
Ejemplo n.º 23
0
        public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
        {
            // Setup
            IAssessmentSection assessmentSection = new AssessmentSectionStub();

            var mockRepository = new MockRepository();
            var menuBuilder    = mockRepository.StrictMock <IContextMenuBuilder>();

            using (mockRepository.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddExportItem()).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.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddDeleteChildrenItem()).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.Build()).Return(null);
            }

            var nodeData = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>(),
                                                                                                   assessmentSection);

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder);
                gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub <IMainWindow>());
                mockRepository.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    plugin.Gui = gui;

                    // Call
                    info.ContextMenuStrip(nodeData, null, treeViewControl);
                }
            }

            // Assert
            mockRepository.VerifyAll();
        }
        public void ContextMenuStrip_HydraulicBoundaryDatabaseLinked_ContextMenuItemCalculateAllEnabled()
        {
            // Setup
            using (var treeView = new TreeViewControl())
            {
                string testDataPath      = TestHelper.GetTestDataPath(TestDataPath.Riskeer.Integration.Forms, "HydraulicBoundaryDatabase");
                string validFilePath     = Path.Combine(testDataPath, "HRD dutch coast south.sqlite");
                var    assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike)
                {
                    HydraulicBoundaryDatabase =
                    {
                        FilePath = validFilePath
                    }
                };
                assessmentSection.SetHydraulicBoundaryLocationCalculations(new[]
                {
                    new TestHydraulicBoundaryLocation()
                });
                HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(assessmentSection.HydraulicBoundaryDatabase);

                var context     = new HydraulicLoadsStateRootContext(assessmentSection);
                var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

                var  mocks = new MockRepository();
                IGui gui   = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip menu = GetInfo(plugin).ContextMenuStrip(context, null, treeView))
                    {
                        // Assert
                        Assert.AreEqual(10, menu.Items.Count);

                        TestHelper.AssertContextMenuStripContainsItem(
                            menu, contextMenuCalculateAllIndex,
                            "Alles be&rekenen",
                            "Alle hydraulische belastingen berekenen.",
                            RiskeerCommonFormsResources.CalculateAllIcon);
                    }
                }
            }
        }
Ejemplo n.º 25
0
        public void ContextMenuStrip_AllRequiredInputSet_ContextMenuItemCalculateAllEnabled()
        {
            // Setup
            IAssessmentSection assessmentSection = new AssessmentSectionStub();

            assessmentSection.HydraulicBoundaryDatabase.FilePath = Path.Combine(TestHelper.GetTestDataPath(TestDataPath.Riskeer.Common.IO,
                                                                                                           nameof(HydraulicBoundaryDatabase)),
                                                                                "complete.sqlite");
            HydraulicBoundaryDatabaseTestHelper.SetHydraulicBoundaryLocationConfigurationSettings(assessmentSection.HydraulicBoundaryDatabase);

            var calculationsForTargetProbabilities = new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>
            {
                new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1)
            };

            var nodeData = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculationsForTargetProbabilities, assessmentSection);

            var mockRepository = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub <IMainWindow>());
                mockRepository.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
                    {
                        // Assert
                        const string expectedItemText    = "Alles be&rekenen";
                        const string expectedItemTooltip = "Alle golfhoogten berekenen.";

                        TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuRunWaveHeightCalculationsIndex,
                                                                      expectedItemText, expectedItemTooltip, RiskeerCommonFormsResources.CalculateAllIcon);
                    }
                }
            }

            mockRepository.VerifyAll(); // Expect no calls on arguments
        }
Ejemplo n.º 26
0
        public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var context           = new HydraulicBoundaryDatabaseContext(assessmentSection.HydraulicBoundaryDatabase,
                                                                         assessmentSection);

            var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();

            using (mocks.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddImportItem(null, null, null)).IgnoreArguments().Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddExportItem()).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.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())
            {
                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder);
                gui.Stub(cmp => cmp.MainWindow).Return(mocks.Stub <IMainWindow>());
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    plugin.Gui = gui;

                    // Call
                    info.ContextMenuStrip(context, null, treeViewControl);
                }
            }

            // Assert
            mocks.VerifyAll();
        }
Ejemplo n.º 27
0
        public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllDisabledAndTooltipSet()
        {
            // Setup
            IAssessmentSection assessmentSection = new AssessmentSectionStub();

            assessmentSection.HydraulicBoundaryDatabase.FilePath = "invalidFilePath";

            var calculationsForTargetProbabilities = new ObservableList <HydraulicBoundaryLocationCalculationsForTargetProbability>
            {
                new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1)
            };

            var nodeData = new WaveHeightCalculationsForUserDefinedTargetProbabilitiesGroupContext(calculationsForTargetProbabilities, assessmentSection);

            var mockRepository = new MockRepository();

            using (var treeViewControl = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mockRepository);
                gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder());
                gui.Stub(cmp => cmp.MainWindow).Return(mockRepository.Stub <IMainWindow>());
                mockRepository.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);

                    plugin.Gui = gui;

                    // Call
                    using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl))
                    {
                        // Assert
                        ToolStripItem contextMenuItem = contextMenu.Items[contextMenuRunWaveHeightCalculationsIndex];

                        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);
                    }
                }
            }

            mockRepository.VerifyAll(); // Expect no calls on arguments
        }
Ejemplo n.º 28
0
        public void GivenSpecificFailureMechanismsContainsItems_WhenAddSpecificFailureMechanism_ThenItemAddedAndNotifyObservers()
        {
            // Given
            var observer = mocks.StrictMock <IObserver>();

            observer.Expect(o => o.UpdateObserver());

            var failureMechanisms = new ObservableList <SpecificFailureMechanism>
            {
                new SpecificFailureMechanism
                {
                    Name = "Nieuw faalmechanisme"
                }
            };
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var context = new SpecificFailureMechanismsContext(failureMechanisms, assessmentSection);

            context.Attach(observer);

            var menuBuilder = new CustomItemsOnlyContextMenuBuilder();

            using (var treeView = new TreeViewControl())
            {
                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder);
                mocks.ReplayAll();

                plugin.Gui = gui;

                using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView))
                {
                    // When
                    menu.Items[contextMenuCreateFailureMechanismIndex].PerformClick();

                    // Then
                    Assert.AreEqual(2, failureMechanisms.Count);
                    IFailureMechanism addedItem = failureMechanisms.Last();
                    Assert.IsInstanceOf <SpecificFailureMechanism>(addedItem);
                    Assert.AreEqual("Nieuw faalmechanisme (1)", addedItem.Name);
                }
            }
        }
        public void ContextMenuStrip_WithContext_CallsBuilder()
        {
            // Setup
            var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike);
            var context           = new HydraulicLoadsStateRootContext(assessmentSection);

            var mocks       = new MockRepository();
            var menuBuilder = mocks.StrictMock <IContextMenuBuilder>();

            using (mocks.Ordered())
            {
                menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder);
                menuBuilder.Expect(mb => mb.AddRenameItem()).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.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())
            {
                IGui gui = StubFactory.CreateGuiStub(mocks);
                gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder);
                mocks.ReplayAll();

                using (var plugin = new RiskeerPlugin())
                {
                    TreeNodeInfo info = GetInfo(plugin);
                    plugin.Gui = gui;

                    // Call
                    info.ContextMenuStrip(context, null, treeViewControl);
                }
            }

            // Assert
            mocks.VerifyAll();
        }
Ejemplo n.º 30
0
        public void VerifyUpdates_CalculationWithoutOutputs_ReturnsTrue()
        {
            // Setup
            var mocks             = new MockRepository();
            var assessmentSection = mocks.Stub <IAssessmentSection>();

            var  mainWindow = mocks.Stub <IMainWindow>();
            IGui gui        = StubFactory.CreateGuiStub(mocks);

            gui.Stub(g => g.MainWindow).Return(mainWindow);

            var calculationWithoutOutput = mocks.Stub <ICalculation>();

            calculationWithoutOutput.Stub(calc => calc.HasOutput).Return(false);

            var failureMechanism = mocks.Stub <ICalculatableFailureMechanism>();

            failureMechanism.Stub(fm => fm.Calculations).Return(new[]
            {
                calculationWithoutOutput
            });

            mocks.ReplayAll();

            var foreshoreProfiles = new ForeshoreProfileCollection();
            var context           = new ForeshoreProfilesContext(foreshoreProfiles, failureMechanism, assessmentSection);

            using (var plugin = new RiskeerPlugin())
            {
                plugin.Gui = gui;

                UpdateInfo updateInfo = GetUpdateInfo(plugin);

                // Call
                bool updatesVerified = updateInfo.VerifyUpdates(context);

                // Assert
                Assert.IsTrue(updatesVerified);
            }

            mocks.VerifyAll();
        }