public void Menu_item_should_be_enabled_if_command_can_execute()
        {
            var menuCommand = new MenuCommand { CanExecute = new Observable<bool>(true) };

            var menuItem = new CommandToolStripMenuItem(menuCommand);

            Assert.IsTrue(menuItem.Enabled);
        }
        public void Menu_item_text_should_match_command()
        {
            var menuCommand = new MenuCommand { Text = "someText" };

            var menuItem = new CommandToolStripMenuItem(menuCommand);

            Assert.AreEqual(menuItem.Text, menuCommand.Text);
        }
        public void Menu_item_should_run_command_when_clicked()
        {
            var command = MockRepository.GenerateStub<ICommand>();
            var menuCommand = new MenuCommand { Command = command };
            var menuItem = new CommandToolStripMenuItem(menuCommand);

            menuItem.PerformClick();

            command.AssertWasCalled(c => c.Execute(Arg<IProgressMonitor>.Is.Anything));
        }
        public void Menu_item_should_become_enabled_if_command_can_execute()
        {
            var canExecute = new Observable<bool>();
            var menuCommand = new MenuCommand { CanExecute = canExecute };
            var menuItem = new CommandToolStripMenuItem(menuCommand);
            Assert.IsFalse(menuItem.Enabled);

            canExecute.Value = true;

            Assert.IsTrue(menuItem.Enabled);
        }
        public void Menu_item_image_should_come_from_command()
        {
            var menuCommand = new MenuCommand();
            var menuItem = new CommandToolStripMenuItem(menuCommand);
            Assert.IsNull(menuItem.Image);

            var image = new Bitmap(1, 1);
            menuCommand.Image = image;
            menuItem = new CommandToolStripMenuItem(menuCommand);

            Assert.AreEqual(image, menuItem.Image);
        }
Esempio n. 6
0
 public void Add(MenuCommand menuCommand)
 {
     var menuItem = new CommandToolStripMenuItem(menuCommand);
     item.DropDownItems.Add(menuItem);
 }
        public void Menu_item_should_run_command_with_task_manager_if_provided_when_clicked()
        {
            var command = MockRepository.GenerateStub<ICommand>();
            var menuCommand = new MenuCommand { Command = command };
            var taskManager = MockRepository.GenerateStub<ITaskManager>();
            var menuItem = new CommandToolStripMenuItem(menuCommand, taskManager);

            menuItem.PerformClick();

            taskManager.AssertWasCalled(tm => tm.QueueTask(command));
        }