public void OnApplyTest()
        {
            SccProviderOptions target = new SccProviderOptions();

            // Create a basic service provider
            using (OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices())
            {
                // Mock the UIShell service to answer Cancel to the dialog invocation
                BaseMock mockUIShell = MockUiShellProvider.GetShowMessageBoxCancel();
                serviceProvider.AddService(typeof(IVsUIShell), mockUIShell, true);

                // Create an ISite wrapper over the service provider
                SiteWrappedServiceProvider wrappedProvider = new SiteWrappedServiceProvider(serviceProvider);
                target.Site = wrappedProvider;

                Assembly shell = typeof(Microsoft.VisualStudio.Shell.DialogPage).Assembly;
                Type argtype = shell.GetType("Microsoft.VisualStudio.Shell.DialogPage+PageApplyEventArgs", true);

                MethodInfo method = typeof(SccProviderOptions).GetMethod("OnApply", BindingFlags.NonPublic | BindingFlags.Instance);
                object eventargs = shell.CreateInstance(argtype.FullName);

                method.Invoke(target, new object[] { eventargs });
            }
        }
Esempio n. 2
0
        public void OnApplyTest()
        {
            SccProviderOptions target = new SccProviderOptions();

            // Create a basic service provider
            using (OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices())
            {
                // Mock the UIShell service to answer Cancel to the dialog invocation
                BaseMock mockUIShell = MockUiShellProvider.GetShowMessageBoxCancel();
                serviceProvider.AddService(typeof(IVsUIShell), mockUIShell, true);

                // Create an ISite wrapper over the service provider
                SiteWrappedServiceProvider wrappedProvider = new SiteWrappedServiceProvider(serviceProvider);
                target.Site = wrappedProvider;

                Assembly shell   = typeof(Microsoft.VisualStudio.Shell.DialogPage).Assembly;
                Type     argtype = shell.GetType("Microsoft.VisualStudio.Shell.DialogPage+PageApplyEventArgs", true);

                MethodInfo method    = typeof(SccProviderOptions).GetMethod("OnApply", BindingFlags.NonPublic | BindingFlags.Instance);
                object     eventargs = shell.CreateInstance(argtype.FullName);

                method.Invoke(target, new object[] { eventargs });
            }
        }