Example #1
0
        public void when_uicontext_is_not_active_then_query_status_is_not_called()
        {
            var command = new Mock <ICommandExtension>();

            var adapter = new VsCommandExtensionAdapter(TestCommandID, command.Object, new UIContextWrapper(false), true);

            command.Verify(x => x.QueryStatus(It.IsAny <IMenuCommand>()), Times.Never);
        }
Example #2
0
        public void when_uicontext_is_not_active_then_adapter_is_disabled_and_invisible()
        {
            var command = new Mock <ICommandExtension>();

            var adapter = new VsCommandExtensionAdapter(TestCommandID, command.Object, new UIContextWrapper(false), true);

            Assert.False(adapter.Enabled);
            Assert.False(adapter.Visible);
        }
Example #3
0
        public void when_uicontext_is_not_active_then_command_is_not_executed()
        {
            var command = new Mock <ICommandExtension>();

            var adapter = new VsCommandExtensionAdapter(TestCommandID, command.Object, new UIContextWrapper(false));

            adapter.Invoke();

            command.Verify(x => x.Execute(It.IsAny <IMenuCommand>()), Times.Never);
        }
Example #4
0
        public void when_command_is_not_enabled_then_command_is_not_executed()
        {
            var command = new Mock <ICommandExtension>();

            // Disable the command by implementing the QueryStatus
            command
            .Setup(x => x.QueryStatus(It.IsAny <IMenuCommand>()))
            .Callback <IMenuCommand>(x =>
            {
                x.Enabled = false;
                x.Visible = false;
            });

            var adapter = new VsCommandExtensionAdapter(TestCommandID, command.Object);

            adapter.Invoke();

            // Ensure the QueryStatus is executed when the command is executed
            command.Verify(x => x.QueryStatus(It.IsAny <IMenuCommand>()), Times.AtLeastOnce());
            // Ensure the command is not executed based on the QueryStatus disable logic
            command.Verify(x => x.Execute(It.IsAny <IMenuCommand>()), Times.Never);
        }