コード例 #1
0
ファイル: PackageTest.cs プロジェクト: SirkleZero/savant
        public void SetSite()
        {
            // Create the package
            IVsPackage package = new SavantPackage() 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");

            // Unsite the package
            Assert.AreEqual(0, package.SetSite(null), "SetSite(null) did not return S_OK");
        }
コード例 #2
0
ファイル: MenuItemCallback.cs プロジェクト: SirkleZero/savant
        public void InitializeMenuCommand()
        {
            // Create the package
            IVsPackage package = new SavantPackage() 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(Savant.GuidList.guidSavantPackageCmdSet, (int)Savant.PkgCmdIDList.generateDataAdaptersCommand);
            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
ファイル: MenuItemCallback.cs プロジェクト: SirkleZero/savant
        public void MenuItemCallback()
        {
            // Create the package
            IVsPackage package = new SavantPackage() as IVsPackage;
            Assert.IsNotNull(package, "The object does not implement IVsPackage");

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

            // Create a UIShell service mock and proffer the service so that it can called from the MenuItemCallback method
            BaseMock 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
            System.Reflection.MethodInfo info = package.GetType().GetMethod("MenuItemCallback", BindingFlags.Instance | BindingFlags.NonPublic);
            Assert.IsNotNull(info, "Failed to get the private method MenuItemCallback throug refplection");
            info.Invoke(package, new object[] { null, null });

            //Clean up services
            serviceProvider.RemoveService(typeof(SVsUIShell));
        }
コード例 #4
0
ファイル: PackageTest.cs プロジェクト: SirkleZero/savant
 public void IsIVsPackage()
 {
     SavantPackage package = new SavantPackage();
     Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage");
 }
コード例 #5
0
ファイル: PackageTest.cs プロジェクト: SirkleZero/savant
 public void CreateInstance()
 {
     SavantPackage package = new SavantPackage();
 }