コード例 #1
0
        public void UseToolWindow()
        {
            // Create the package
            BasicSccProvider package = new BasicSccProvider();
            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Need to mock a service implementing IVsRegisterScciProvider, because the scc provider will register with it
            IVsRegisterScciProvider registerScciProvider = MockRegisterScciProvider.GetBaseRegisterScciProvider();
            serviceProvider.AddService(typeof(IVsRegisterScciProvider), registerScciProvider, true);

            // Add site support to create and enumerate tool windows
            BaseMock uiShell = MockUiShellProvider.GetWindowEnumerator0();
            serviceProvider.AddService(typeof(SVsUIShell), uiShell, false);

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

            // Test that toolwindow can be created
            MethodInfo method = typeof(BasicSccProvider).GetMethod("ViewToolWindow", BindingFlags.NonPublic | BindingFlags.Instance);
            object result = method.Invoke(package, new object[] { null, null });

            // Test that toolwindow toolbar's command can be executed
            method = typeof(BasicSccProvider).GetMethod("ToolWindowToolbarCommand", BindingFlags.NonPublic | BindingFlags.Instance);
            result = method.Invoke(package, new object[] { null, null });

            // Toggle the toolwindow color back
            method = typeof(BasicSccProvider).GetMethod("ToolWindowToolbarCommand", BindingFlags.NonPublic | BindingFlags.Instance);
            result = method.Invoke(package, new object[] { null, null });

            // Get the window and test the dispose function
            SccProviderToolWindow window = (SccProviderToolWindow)package.FindToolWindow(typeof(SccProviderToolWindow), 0, true);
            method = typeof(SccProviderToolWindow).GetMethod("Dispose", BindingFlags.NonPublic | BindingFlags.Instance);
            result = method.Invoke(window, new object[] { true });
        }
コード例 #2
0
        public void TestSccComand()
        {
            // Create the package
            BasicSccProvider package = new BasicSccProvider();
            // Create a basic service provider
            OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();

            // Need to mock a service implementing IVsRegisterScciProvider, because the scc provider will register with it
            IVsRegisterScciProvider registerScciProvider = MockRegisterScciProvider.GetBaseRegisterScciProvider();
            serviceProvider.AddService(typeof(IVsRegisterScciProvider), registerScciProvider, true);

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

            // Test the scc command by toggleing it twice
            MethodInfo method = typeof(BasicSccProvider).GetMethod("OnSccCommand", BindingFlags.NonPublic | BindingFlags.Instance);

            TestSccCommand commandWell = new TestSccCommand();
            CommandID cmdID = new CommandID(new System.Guid(), 0);
            MenuCommand command = new MenuCommand(new EventHandler(commandWell.OnSccCommand), cmdID);
            object result = method.Invoke(package, new object[] { command, null });
            Assert.AreEqual(true, command.Checked, "OnSccCommand did not execute correctly");

            result = method.Invoke(package, new object[] { command, null });
            Assert.AreEqual(false, command.Checked, "OnSccCommand did not execute correctly");
        }
コード例 #3
0
        public void SetSite()
        {
            // Create the package
            IVsPackage package = new BasicSccProvider() as IVsPackage;
            Assert.IsNotNull(package, "The object does not implement IVsPackage");

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

            // Need to mock a service implementing IVsRegisterScciProvider, because the scc provider will register with it
            IVsRegisterScciProvider registerScciProvider = MockRegisterScciProvider.GetBaseRegisterScciProvider();
            serviceProvider.AddService(typeof(IVsRegisterScciProvider), registerScciProvider, 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");

            // Remove the mock service
            serviceProvider.RemoveService(typeof(IVsRegisterScciProvider));
        }
コード例 #4
0
        public void ConstructorTest()
        {
            BasicSccProvider sccProvider = new BasicSccProvider();
            SccProviderService target = new SccProviderService(sccProvider);

            Assert.AreNotEqual(null, target, "Could not create provider service");
            Assert.IsNotNull(target as IVsSccProvider, "The object does not implement IVsPackage");
        }
コード例 #5
0
 public SccProviderService(BasicSccProvider sccProvider)
 {
     _sccProvider = sccProvider;
 }
コード例 #6
0
 public SccProviderService(BasicSccProvider sccProvider)
 {
     _sccProvider = sccProvider;
 }
コード例 #7
0
 public void IsIVsPackage()
 {
     BasicSccProvider package = new BasicSccProvider();
     Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage");
 }
コード例 #8
0
 public void CreateInstance()
 {
     BasicSccProvider package = new BasicSccProvider();
 }