コード例 #1
0
ファイル: PackageTest.cs プロジェクト: v2m/FSharpVSPowerTools
        public void SetSite()
        {
            // Create the package
            var package = new PowerToolsCommandsPackage() as IVsPackage;
            Assert.IsNotNull(package, "The object does not implement IVsPackage");

            // Create a basic service provider
            var serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            var activityLogMock =
                new GenericMockFactory(
                    "MockVsActivityLog",
                    new[] { typeof(Microsoft.VisualStudio.Shell.Interop.IVsActivityLog) }
                    ).GetInstance();

            serviceProvider.AddService(
                typeof(Microsoft.VisualStudio.Shell.Interop.SVsActivityLog),
                activityLogMock,
                true);

            // Site the package
            //Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK");

            // Unsite the package
            Assert.AreEqual(0, package.SetSite(null), "SetSite(null) did not return S_OK");
        }
コード例 #2
0
        public void InitializeMenuCommand()
        {
            // Create the package
            IVsPackage package = new PowerToolsCommandsPackage() as IVsPackage;
            Assert.IsNotNull(package, "The object does not implement IVsPackage");

            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Site the package
            // Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK");

            // Verify that the menu command can be found
            CommandID menuCommandID = new CommandID(FSharpVSPowerTools.Refactoring.PkgCmdIDList.GuidBuiltinCmdSet,
                                        (int)FSharpVSPowerTools.Refactoring.PkgCmdIDList.CmdidBuiltinRenameCommand);
            System.Reflection.MethodInfo info = typeof(Package).GetMethod("GetService", BindingFlags.Instance | BindingFlags.NonPublic);
            Assert.IsNotNull(info);
            //OleMenuCommandService mcs = info.Invoke(package, new object[] { (typeof(IMenuCommandService)) }) as OleMenuCommandService;
            //Assert.IsNotNull(mcs.FindCommand(menuCommandID));
        }
コード例 #3
0
        public void MenuItemCallback()
        {
            // Create the package
            var package = new PowerToolsCommandsPackage() as IVsPackage;
            Assert.IsNotNull(package, "The object does not implement IVsPackage");

            // Create a basic service provider
            var serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Create a UIShell service mock and proffer the service so that it can called from the MenuItemCallback method
            var uishellMock = UIShellServiceMock.GetUiShellInstance();
            serviceProvider.AddService(typeof(SVsUIShell), uishellMock, true);

            // Site the package
            // Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK");

            //Invoke private method on package class and observe that the method does not throw
            var info = package.GetType().GetMethod("SetupMenu", BindingFlags.Instance | BindingFlags.NonPublic);
            Assert.IsNotNull(info, "Failed to get the protected method SetupMenu through reflection");
            info.Invoke(package, null);

            //Clean up services
            serviceProvider.RemoveService(typeof(SVsUIShell));
        }
コード例 #4
0
        public void InitializeMenuCommand()
        {
            // Create the package
            var package = new PowerToolsCommandsPackage() as IVsPackage;
            Assert.IsNotNull(package, "The object does not implement IVsPackage");

            var methodInfo = package.GetType().GetMethod("SetupMenu", BindingFlags.Instance | BindingFlags.NonPublic);
            Assert.IsNotNull(methodInfo, "Failed to get the protected method SetupMenu through reflection");
            methodInfo.Invoke(package, null);

            // Create a basic service provider
            var serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Site the package
            // Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK");

            // Verify that the menu command can be found
            var menuCommandID = new CommandID(FSharpVSPowerTools.Folders.PkgCmdConst.guidNewFolderCmdSet,
                                              (int)FSharpVSPowerTools.Folders.PkgCmdConst.cmdNewFolder);
            var info = typeof(Package).GetMethod("GetService", BindingFlags.Instance | BindingFlags.NonPublic);
            Assert.IsNotNull(info);
            var mcs = info.Invoke(package, new object[] { (typeof(IMenuCommandService)) }) as OleMenuCommandService;
            Assert.IsNotNull(mcs.FindCommand(menuCommandID));
        }
コード例 #5
0
ファイル: PackageTest.cs プロジェクト: v2m/FSharpVSPowerTools
 public void IsIVsPackage()
 {
     var package = new PowerToolsCommandsPackage();
     Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage");
 }
コード例 #6
0
ファイル: PackageTest.cs プロジェクト: v2m/FSharpVSPowerTools
 public void CreateInstance()
 {
     var package = new PowerToolsCommandsPackage();
 }
コード例 #7
0
 public PowerToolsCommandsPackage()
 {
     _instance = this;
 }
コード例 #8
0
 public PowerToolsCommandsPackage()
 {
     _instance = this;
 }