Exemplo n.º 1
0
        public void uses_screenObjectLocator_to_build_up_a_context_menu()
        {
            var hierarchy = new Hierarchy("some project");
            var node      = new TreeNode(hierarchy);

            view.ApplyProjectNode(node);


            var nodeActions = new IContextualAction[]
            {
                new StubContextualAction(),
                new StubContextualAction()
            };

            locator.Expect(x => x.BuildActions(node)).Return(nodeActions);

            var hierarchyActions = new IContextualAction[]
            {
                new StubContextualAction(),
                new StubContextualAction()
            };

            locator.Expect(x => x.BuildActions(hierarchy)).Return(hierarchyActions);


            node.InitializeContextMenu();
            node.ContextMenu.Items.Count.ShouldEqual(4);
            node.ContextMenu.Items[0].ShouldBeOfType <ActionMenuItem>().Action.ShouldBeTheSameAs(nodeActions[0]);
            node.ContextMenu.Items[1].ShouldBeOfType <ActionMenuItem>().Action.ShouldBeTheSameAs(nodeActions[1]);
            node.ContextMenu.Items[2].ShouldBeOfType <ActionMenuItem>().Action.ShouldBeTheSameAs(hierarchyActions[0]);
            node.ContextMenu.Items[3].ShouldBeOfType <ActionMenuItem>().Action.ShouldBeTheSameAs(hierarchyActions[1]);
        }
Exemplo n.º 2
0
 protected override void beforeEach()
 {
     base.beforeEach();
     _screenObjectLocator = MockFor <IScreenObjectLocator>();
     _theAction           = MockFor <IContextualAction>();
     _screenObjectLocator.Expect(x => x.CommandForSubject <RunTestCommand, Test>(_node.Subject)).Return(_theAction);
     _theAction.Expect(x => x.Execute());
     ClassUnderTest.RunNode(_node);
 }
Exemplo n.º 3
0
        //TODO -- make this be ICommand for the enabled
        public ActionMenuItem(IContextualAction action)
        {
            _action = action;

            Header = action.Description;
            this.SetIcon(action.Icon);

            Click += (s, e) => _action.Execute();
        }
Exemplo n.º 4
0
        //TODO -- make this be ICommand for the enabled
        public ActionMenuItem(IContextualAction action)
        {
            _action = action;

            Header = action.Description;
            this.SetIcon(action.Icon);

            Click += (s, e) => _action.Execute();
        }
        protected override void beforeEach()
        {
            _token    = null;
            theTarget = new ContextualObject();

            definition = MockFor <IContextualAction <ContextualObject> >();

            definition.Stub(x => x.Category).Return(theCategory);
            definition.Stub(x => x.Text()).Return(theTextOfTheMenuItem);
            definition.Stub(x => x.Key).Return(theKey);
        }
Exemplo n.º 6
0
        public MenuItemToken BuildMenuItem(T target, IContextualAction <T> definition)
        {
            var endpoint = definition.FindEndpoint(_endpoints, target);

            var menuItemState = determineAvailability(target, endpoint, definition);

            return(new MenuItemToken {
                Key = definition.Key,
                MenuItemState = menuItemState,
                Text = definition.Text(),
                Url = endpoint.Url
            });
        }
Exemplo n.º 7
0
        public void RunNode(TreeNode node)
        {
            IContextualAction action = null;

            //Something smells.  I can't quite make out what it is.  Oh wait, it's this LSP violation.
            if (node.Subject is Suite)
            {
                action = _screenObjects.CommandForSubject <RunSuiteCommand, Suite>(node.Subject);
            }
            else
            {
                action = _screenObjects.CommandForSubject <RunTestCommand, Test>(node.Subject);
            }
            if (action != null)
            {
                action.Execute();
            }
        }
Exemplo n.º 8
0
        private static MenuItemState determineAvailability(T target, Endpoint endpoint, IContextualAction <T> definition)
        {
            var authorized = endpoint.IsAuthorized ? MenuItemState.Available : definition.UnauthorizedState;
            var available  = definition.IsAvailable(target);

            return(MenuItemState.Least(authorized, available));
        }