Microsoft.VsSDK.IntegrationTestLibrary.TestUtils.ExecuteCommand C# (CSharp) Method

ExecuteCommand() public method

Executes a Command (menu item) in the given context
public ExecuteCommand ( CommandID cmd ) : void
cmd System.ComponentModel.Design.CommandID
return void
        public void ExecuteCommand(CommandID cmd)
        {
            object Customin = null;
            object Customout = null;
            string guidString = cmd.Guid.ToString("B").ToUpper();
            int cmdId = cmd.ID;
            DTE dte = VsIdeTestHostContext.Dte;
            dte.Commands.Raise(guidString, cmdId, ref Customin, ref Customout);
        }

Usage Example

        public void ShowToolWindow()
        {
            UIThreadInvoker.Invoke((ThreadInvoker)delegate()
            {
                CommandID toolWindowCmd = new CommandID(PacktPub.VSPackageSample.GuidList.guidVSPackageSampleCmdSet, (int)PacktPub.VSPackageSample.PkgCmdIDList.cmdidMyTool);

                TestUtils testUtils = new TestUtils();
                testUtils.ExecuteCommand(toolWindowCmd);

                Assert.IsTrue(testUtils.CanFindToolwindow(new Guid(PacktPub.VSPackageSample.GuidList.guidToolWindowPersistanceString)));

            });
        }
All Usage Examples Of Microsoft.VsSDK.IntegrationTestLibrary.TestUtils::ExecuteCommand