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