public void OnNodeRenamed_WithData_SetProjectNameWithNotification() { // Setup var mocks = new MockRepository(); var observer = mocks.Stub <IObserver>(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); var context = new HydraulicLoadsStateRootContext(assessmentSection); context.Attach(observer); using (var plugin = new RiskeerPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call const string newName = "New Name"; info.OnNodeRenamed(context, newName); // Assert Assert.AreEqual(newName, assessmentSection.Name); } mocks.VerifyAll(); }
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); } } } }
public void CreateInstance_WithContext_ReturnsAssessmentSectionExtendedView() { // Setup var context = new HydraulicLoadsStateRootContext(new AssessmentSection(AssessmentSectionComposition.Dike)); // Call IView view = info.CreateInstance(context); // Assert Assert.IsInstanceOf <AssessmentSectionExtendedView>(view); }
public void Constructor_ExpectedValues() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); // Call var context = new HydraulicLoadsStateRootContext(assessmentSection); // Assert Assert.IsInstanceOf <StateRootContext>(context); Assert.AreSame(assessmentSection, context.WrappedData); }
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); } } } }
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(); }
public void Text_WithContext_ReturnsName() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) { Name = "ttt" }; var context = new HydraulicLoadsStateRootContext(assessmentSection); using (var plugin = new RiskeerPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call string text = info.Text(context); // Assert Assert.AreEqual(assessmentSection.Name, text); } }
public void ContextMenuStrip_HydraulicBoundaryDatabaseLinkedToInvalidFile_ContextMenuItemCalculateAllDisabled() { // Setup using (var treeView = new TreeViewControl()) { var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) { HydraulicBoundaryDatabase = { FilePath = "invalidFilePath" } }; 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); ToolStripItem contextMenuItem = menu.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); } } } }
public void ChildNodeObjects_WithContext_ReturnsChildrenOfData() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); var context = new HydraulicLoadsStateRootContext(assessmentSection); using (var plugin = new RiskeerPlugin()) { TreeNodeInfo info = GetInfo(plugin); // Call object[] objects = info.ChildNodeObjects(context).ToArray(); // Assert Assert.AreEqual(5, objects.Length); var hydraulicBoundaryDatabaseContext = (HydraulicBoundaryDatabaseContext)objects[0]; Assert.AreSame(assessmentSection.HydraulicBoundaryDatabase, hydraulicBoundaryDatabaseContext.WrappedData); Assert.AreSame(assessmentSection, hydraulicBoundaryDatabaseContext.AssessmentSection); var stabilityStoneCoverFailureMechanismContext = (StabilityStoneCoverFailureMechanismContext)objects[1]; Assert.AreSame(assessmentSection.StabilityStoneCover, stabilityStoneCoverFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, stabilityStoneCoverFailureMechanismContext.Parent); var waveImpactAsphaltCoverFailureMechanismContext = (WaveImpactAsphaltCoverFailureMechanismContext)objects[2]; Assert.AreSame(assessmentSection.WaveImpactAsphaltCover, waveImpactAsphaltCoverFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, waveImpactAsphaltCoverFailureMechanismContext.Parent); var grassCoverErosionOutwardsFailureMechanismContext = (GrassCoverErosionOutwardsFailureMechanismContext)objects[3]; Assert.AreSame(assessmentSection.GrassCoverErosionOutwards, grassCoverErosionOutwardsFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, grassCoverErosionOutwardsFailureMechanismContext.Parent); var duneErosionFailureMechanismContext = (DuneErosionFailureMechanismContext)objects[4]; Assert.AreSame(assessmentSection.DuneErosion, duneErosionFailureMechanismContext.WrappedData); Assert.AreSame(assessmentSection, duneErosionFailureMechanismContext.Parent); } }