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() } }
public void ContextMenuStrip_MacroStabilityInwardsCalculationWithoutOutput_ContextMenuItemClearOutputDisabledAndTooltipSet() { // Setup using (var treeViewControl = new TreeViewControl()) { var calculation = new MacroStabilityInwardsCalculationScenario(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); var assessmentSection = mocks.Stub <IAssessmentSection>(); var nodeData = new MacroStabilityInwardsCalculationScenarioContext(calculation, new CalculationGroup(), Enumerable.Empty <MacroStabilityInwardsSurfaceLine>(), Enumerable.Empty <MacroStabilityInwardsStochasticSoilModel>(), failureMechanism, assessmentSection); var gui = mocks.Stub <IGui>(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(new CustomItemsOnlyContextMenuBuilder()); mocks.ReplayAll(); plugin.Gui = gui; // Call using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Assert TestHelper.AssertContextMenuStripContainsItem(contextMenu, contextMenuClearIndex, "&Wis uitvoer...", "Deze berekening heeft geen uitvoer om te wissen.", RiskeerCommonFormsResources.ClearIcon, false); } } }
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(); }
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 (var treeViewControl = new TreeViewControl()) { var gui = mocks.Stub <IGui>(); gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder); gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); mocks.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(null, null, treeViewControl); } // Assert mocks.VerifyAll(); }
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(); }
public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup 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.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } using (var treeViewControl = new TreeViewControl()) { var gui = mocks.Stub <IGui>(); gui.Stub(cmp => cmp.Get(null, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(null, null, treeViewControl); } // Assert // Assert expectancies called in TearDown() }
public void ContextMenuStrip_Always_CallsBuilder() { // Setup using (var treeViewControl = new TreeViewControl()) { var context = new GrassCoverErosionInwardsScenariosContext(new CalculationGroup(), new GrassCoverErosionInwardsFailureMechanism()); var mocks = new MockRepository(); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.Get(context, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(context, null, treeViewControl); // Assert mocks.VerifyAll(); } }
public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var mocks = new MockRepository(); using (var treeViewControl = new TreeViewControl()) { 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.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } var gui = mocks.Stub <IGui>(); gui.Stub(cmp => cmp.Get(null, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); using (var plugin = new GrassCoverErosionOutwardsPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(null, null, treeViewControl); } } // Assert mocks.VerifyAll(); }
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(); }
public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var mocks = new MockRepository(); using (var treeViewControl = new TreeViewControl()) { var output = new EmptyWaveImpactAsphaltCoverOutput(); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); using (mocks.Ordered()) { menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } var gui = mocks.Stub <IGui>(); gui.Stub(cmp => cmp.Get(output, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); using (var plugin = new WaveImpactAsphaltCoverPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(output, null, treeViewControl); } } // Assert mocks.VerifyAll(); }
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(); }
public void ContextMenuStrip_Always_CallsBuilderMethods() { // Setup var mocksRepository = new MockRepository(); var menuBuilder = mocksRepository.StrictMock <IContextMenuBuilder>(); using (mocksRepository.Ordered()) { menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } using (var plugin = new StabilityPointStructuresPlugin()) using (var treeViewControl = new TreeViewControl()) { var gui = mocksRepository.Stub <IGui>(); gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder); mocksRepository.ReplayAll(); plugin.Gui = gui; TreeNodeInfo info = GetInfo(plugin); // Call info.ContextMenuStrip(null, null, treeViewControl); } // Assert mocksRepository.VerifyAll(); }
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 ContextMenuStrip_Always_CallsBuilder() { // Setup var mocks = new MockRepository(); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); using (mocks.Ordered()) { menuBuilder.Expect(mb => mb.AddImportItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddUpdateItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddCollapseAllItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddExpandAllItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } using (var treeViewControl = new TreeViewControl()) { var gui = mocks.Stub <IGui>(); gui.Stub(g => g.Get(null, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(null, null, treeViewControl); } // Assert mocks.VerifyAll(); }
public void ContextMenuStrip_Always_CallsBuilder() { // Setup MacroStabilityInwardsStochasticSoilModel model = MacroStabilityInwardsStochasticSoilModelTestFactory.CreateValidStochasticSoilModel(); 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.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } using (var treeViewControl = new TreeViewControl()) { var gui = mocks.Stub <IGui>(); gui.Stub(g => g.Get(model, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(model, null, treeViewControl); } // Assert mocks.VerifyAll(); }
public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var mocks = new MockRepository(); using (var treeViewControl = new TreeViewControl()) { GrassCoverErosionOutwardsWaveConditionsOutput output = GrassCoverErosionOutwardsWaveConditionsOutputTestFactory.Create(); var context = new GrassCoverErosionOutwardsWaveConditionsOutputContext(output, new GrassCoverErosionOutwardsWaveConditionsInput()); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); using (mocks.Ordered()) { menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } var gui = mocks.Stub <IGui>(); gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); using (var plugin = new GrassCoverErosionOutwardsPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(context, null, treeViewControl); } } // Assert mocks.VerifyAll(); }
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(); }
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(); }
public void ContextMenuStrip_Always_CallsBuilder() { // Setup var mapData = new MapDataCollection("test data"); MapDataCollectionContext context = GetContext(mapData); var builder = mocks.StrictMock <IContextMenuBuilder>(); using (mocks.Ordered()) { builder.Expect(mb => mb.AddImportItem(null, null, null)).IgnoreArguments().Return(builder); builder.Expect(mb => mb.AddSeparator()).Return(builder); builder.Expect(mb => mb.AddCustomItem(Arg <StrictContextMenuItem> .Is.NotNull)).Return(builder); builder.Expect(mb => mb.AddSeparator()).Return(builder); builder.Expect(mb => mb.AddPropertiesItem()).Return(builder); builder.Expect(mb => mb.Build()).Return(null); } contextMenuBuilderProvider.Expect(p => p.Get(context, null)).Return(builder); mocks.ReplayAll(); // Call info.ContextMenuStrip(context, null, null); // Assert // Assert expectancies are called in TearDown() }
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(); }
public void ContextMenuStrip_WithContext_AddCustomItems() { // Setup using (var plugin = new StabilityPointStructuresPlugin()) using (var treeView = new TreeViewControl()) { var assessmentSection = mocksRepository.Stub <IAssessmentSection>(); var failureMechanism = new StabilityPointStructuresFailureMechanism(); var context = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); var gui = mocksRepository.Stub <IGui>(); gui.Stub(cmp => cmp.Get(context, treeView)).Return(menuBuilder); gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub <IMainWindow>()); mocksRepository.ReplayAll(); plugin.Gui = gui; TreeNodeInfo info = GetInfo(plugin); // Call using (ContextMenuStrip menu = info.ContextMenuStrip(context, assessmentSection, treeView)) { // Assert Assert.AreEqual(12, menu.Items.Count); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuValidateAllIndex, "Alles &valideren", "Er zijn geen berekeningen om te valideren.", RiskeerCommonFormsResources.ValidateAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuCalculateAllIndex, "Alles be&rekenen", "Er zijn geen berekeningen om uit te voeren.", RiskeerCommonFormsResources.CalculateAllIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearAllIndex, "&Wis alle uitvoer...", "Er zijn geen berekeningen met uitvoer om te wissen.", RiskeerCommonFormsResources.ClearIcon, false); TestHelper.AssertContextMenuStripContainsItem(menu, contextMenuClearIllustrationPointsIndex, "Wis alle illustratiepunten...", "Er zijn geen berekeningen met illustratiepunten om te wissen.", RiskeerCommonFormsResources.ClearIllustrationPointsIcon, false); } } mocksRepository.VerifyAll(); }
public void ContextMenuStrip_WithContext_CallsContextMenuBuilderMethods() { // Setup var failureMechanism = new DuneErosionFailureMechanism(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mocksRepository); var context = new DuneErosionFailureMechanismContext(failureMechanism, assessmentSection); var orderMocksRepository = new MockRepository(); var menuBuilder = orderMocksRepository.StrictMock <IContextMenuBuilder>(); using (orderMocksRepository.Ordered()) { menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.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); } orderMocksRepository.ReplayAll(); using (var treeViewControl = new TreeViewControl()) { var gui = mocksRepository.Stub <IGui>(); gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); gui.Stub(g => g.ViewHost).Return(mocksRepository.Stub <IViewHost>()); mocksRepository.ReplayAll(); plugin.Gui = gui; // Call info.ContextMenuStrip(context, null, treeViewControl); } // Assert orderMocksRepository.VerifyAll(); }
public void ContextMenuStrip_Always_CallsContextMenuBuilderMethods() { // Setup var mockRepository = new MockRepository(); IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(mockRepository); var orderedMockRepository = new MockRepository(); var menuBuilder = orderedMockRepository.StrictMock <IContextMenuBuilder>(); using (orderedMockRepository.Ordered()) { menuBuilder.Expect(mb => mb.AddCustomItem(null)).IgnoreArguments().Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).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.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); } orderedMockRepository.ReplayAll(); var nodeData = new DuneLocationCalculationsForUserDefinedTargetProbabilitiesGroupContext( new ObservableList <DuneLocationCalculationsForTargetProbability>(), new DuneErosionFailureMechanism(), assessmentSection); using (var treeViewControl = new TreeViewControl()) { var gui = mockRepository.Stub <IGui>(); gui.Stub(cmp => cmp.Get(nodeData, treeViewControl)).Return(menuBuilder); gui.Stub(g => g.ViewHost).Return(mockRepository.Stub <IViewHost>()); mockRepository.ReplayAll(); using (var plugin = new DuneErosionPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(nodeData, null, treeViewControl); } } // Assert orderedMockRepository.VerifyAll(); mockRepository.VerifyAll(); }
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(); }
public void ContextMenuStrip_FailureMechanismWithCalculationsContainingIllustrationPoints_ContextMenuItemClearIllustrationPointsEnabled() { // Setup var calculationWithIllustrationPoints = new TestStabilityPointStructuresCalculationScenario { Output = new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()) }; var calculationWithOutput = new TestStabilityPointStructuresCalculationScenario { Output = new TestStructuresOutput() }; var failureMechanism = new StabilityPointStructuresFailureMechanism { CalculationsGroup = { Children = { calculationWithIllustrationPoints, calculationWithOutput, new TestStabilityPointStructuresCalculationScenario() } } }; IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(null, mocksRepository, "invalidFilePath"); var nodeData = new StabilityPointStructuresFailureMechanismContext(failureMechanism, assessmentSection); var menuBuilder = new CustomItemsOnlyContextMenuBuilder(); using (var plugin = new StabilityPointStructuresPlugin()) using (var treeViewControl = new TreeViewControl()) { var gui = mocksRepository.Stub <IGui>(); gui.Stub(g => g.Get(nodeData, treeViewControl)).Return(menuBuilder); gui.Stub(g => g.MainWindow).Return(mocksRepository.Stub <IMainWindow>()); mocksRepository.ReplayAll(); plugin.Gui = gui; TreeNodeInfo info = GetInfo(plugin); using (ContextMenuStrip contextMenu = info.ContextMenuStrip(nodeData, null, treeViewControl)) { // Call ToolStripItem toolStripItem = contextMenu.Items[contextMenuClearIllustrationPointsIndex]; // Assert Assert.IsTrue(toolStripItem.Enabled); } } }
public void ContextMenuStrip_WithChartDataCollection_CallsContextMenuBuilderMethods() { // Setup var chartDataCollection = new ChartDataCollection("test data"); using (var treeViewControl = new TreeViewControl()) { 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.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); } contextMenuBuilderProvider.Expect(cmbp => cmbp.Get(null, null)) .IgnoreArguments() .Return(menuBuilder); mocks.ReplayAll(); // Call info.ContextMenuStrip(chartDataCollection, null, treeViewControl); // Assert // Asserts done in TearDown } }
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(); }
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(); }
public void ContextMenuStrip_WithAddImportItem_CorrectImportInfosPassed() { // Setup var mocks = new MockRepository(); var mainWindow = mocks.Stub <IMainWindow>(); var gui = mocks.Stub <IGui>(); gui.Stub(g => g.MainWindow).Return(mainWindow); gui.Stub(g => g.ProjectOpened += null).IgnoreArguments(); gui.Stub(g => g.ProjectOpened -= null).IgnoreArguments(); var menuBuilder = mocks.StrictMock <IContextMenuBuilder>(); menuBuilder.Expect(mb => mb.AddOpenItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddImportItem()) .IgnoreArguments() .WhenCalled(invocation => { var importInfos = (ImportInfo[])invocation.Arguments[0]; Assert.AreEqual(1, importInfos.Length); Assert.IsTrue(importInfos.Any(i => i.DataType == typeof(PipingFailureMechanismSectionsContext))); }) .Return(menuBuilder); menuBuilder.Expect(mb => mb.AddUpdateItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddSeparator()).Return(menuBuilder); menuBuilder.Expect(mb => mb.AddPropertiesItem()).Return(menuBuilder); menuBuilder.Expect(mb => mb.Build()).Return(null); var assessmentSection = mocks.Stub <IAssessmentSection>(); var context = new PipingFailureMechanismSectionsContext(new PipingFailureMechanism(), assessmentSection); using (var treeViewControl = new TreeViewControl()) { gui.Stub(cmp => cmp.Get(context, treeViewControl)).Return(menuBuilder); mocks.ReplayAll(); using (var plugin = new PipingPlugin()) { TreeNodeInfo info = GetInfo(plugin); plugin.Gui = gui; // Call info.ContextMenuStrip(context, null, treeViewControl); } } // Assert mocks.VerifyAll(); }
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 }