private void ContextMenuBranchSpecific(ContextMenuStrip contextMenu)
        {
            if (contextMenu != menuBranch)
            {
                return;
            }

            var node = (contextMenu.SourceControl as TreeView)?.SelectedNode?.Tag as LocalBranchNode;

            if (node is null)
            {
                return;
            }

            var isNotActiveBranch = !node.IsActive;

            _localBranchMenuItems.GetInactiveBranchItems().ForEach(t => t.Item.Visible = isNotActiveBranch);

            _menuBranchCopyContextMenuItems.ForEach(x => x.Visible = node.Visible);

            if (node.Visible)
            {
                contextMenu.AddUserScripts(runScriptToolStripMenuItem, _scriptRunner.Execute);
            }
            else
            {
                contextMenu.RemoveUserScripts(runScriptToolStripMenuItem);
            }
        }
Beispiel #2
0
        private void ContextMenuBranchSpecific(ContextMenuStrip contextMenu)
        {
            if (contextMenu != menuBranch)
            {
                return;
            }

            var node = (contextMenu.SourceControl as TreeView)?.SelectedNode;

            if (node is null)
            {
                return;
            }

            var isNotActiveBranch = !((node.Tag as LocalBranchNode)?.IsActive ?? false);

            _localBranchMenuItems.GetInactiveBranchItems().ForEach(t => t.Item.Visible = isNotActiveBranch);
        }
        public void WithActiveBranch_HasFilteredItems()
        {
            // Arrange
            var generator = new LocalBranchMenuItems <TestBranchNode>(_factory);

            // Act
            const int notFiltered      = 2; // create branch, rename
            int       expectedFiltered = expectedTotal - notFiltered;
            var       menuItems        = generator.GetInactiveBranchItems().ToArray();

            Assert.AreEqual(menuItems.Count(), expectedFiltered);
            int testIndex = 0;

            AssertItem(menuItems[testIndex++], nameof(TestBranchNode.Checkout));
            AssertItem(menuItems[testIndex++], nameof(TestBranchNode.Merge));
            AssertItem(menuItems[testIndex++], nameof(TestBranchNode.Rebase));
            AssertItem(menuItems[testIndex++], nameof(TestBranchNode.Reset));
            Assert.IsInstanceOf <ToolStripSeparator>(menuItems[testIndex++].Item);
            AssertItem(menuItems[testIndex++], nameof(TestBranchNode.Delete));
        }