public void MenuItemCallback()
        {
            // Create the package
            IVsPackage package = new SrcMLServicePackage() 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));
        }
        public void SetSiteSimple()
        {
            SrcMLServicePackage packageObject = new SrcMLServicePackage();
            IVsPackage          package       = (IVsPackage)packageObject;

            using (OleServiceProvider provider = OleServiceProvider.CreateOleServiceProviderWithBasicServices()) {
                int result = package.SetSite(provider);
                Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded(result), "SetSite failed.");
            }
            package.SetSite(null);
            package.Close();
        }
        public void SetSite()
        {
            // Create the package
            IVsPackage package = new SrcMLServicePackage() 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");
        }
        public void GetLocalServiceSimple()
        {
            SrcMLServicePackage packageObject = new SrcMLServicePackage();
            IVsPackage          package       = (IVsPackage)packageObject;

            using (OleServiceProvider provider = OleServiceProvider.CreateOleServiceProviderWithBasicServices()) {
                int result = package.SetSite(provider);
                Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded(result), "SetSite failed.");
                IServiceProvider serviceProvider = package as IServiceProvider;
                object           o = serviceProvider.GetService(typeof(SSrcMLLocalService));
                Assert.IsNotNull(o, "GetService returned null for the local service.");
                ISrcMLLocalService service = o as ISrcMLLocalService;
                Assert.IsNotNull(service, "The service SMyLocalService does not implements IMyLocalService.");
                service.LocalServiceFunction();
            }
            package.SetSite(null);
            package.Close();
        }
        public void InitializeMenuCommand()
        {
            // Create the package
            IVsPackage package = new SrcMLServicePackage() 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(GuidList.guidSrcMLServiceCmdSet, (int)PkgCmdIDList.SrcML);
            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));
        }
        public static void ClassInitialize(TestContext testContext)
        {
            // Create SrcMLServicePackage
            SrcMLServicePackage packageObject = new SrcMLServicePackage();

            package = (IVsPackage)packageObject;
            Assert.IsNotNull(package, "Get a null SrcMLServicePackage instance.");
            IServiceProvider serviceProvider = package as IServiceProvider;
            // Get SrcML Service
            object o = serviceProvider.GetService(typeof(SSrcMLGlobalService));

            Assert.IsNotNull(o, "GetService returned null for the global service.");
            srcMLService = o as ISrcMLGlobalService;
            Assert.IsNotNull(srcMLService, "The service SSrcMLGlobalService does not implements ISrcMLGlobalService.");

            // Register SrcML Service events
            srcMLService.SourceFileChanged += SourceFileChanged;
            srcMLService.IsReadyChanged    += IsReadyChanged;
            srcMLService.MonitoringStopped += MonitoringStopped;
        }
        public void IsIVsPackage()
        {
            SrcMLServicePackage package = new SrcMLServicePackage();

            Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage");
        }
 // TODO: remove?
 public void CreateInstance()
 {
     SrcMLServicePackage package = new SrcMLServicePackage();
 }