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 }); }
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"); }
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)); }
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"); }
public SccProviderService(BasicSccProvider sccProvider) { _sccProvider = sccProvider; }
public void IsIVsPackage() { BasicSccProvider package = new BasicSccProvider(); Assert.IsNotNull(package as IVsPackage, "The object does not implement IVsPackage"); }
public void CreateInstance() { BasicSccProvider package = new BasicSccProvider(); }