public void WindowPaneImplementation() { using (OleServiceProvider provider = new OleServiceProvider()) { // Create a mock text buffer for the console. BaseMock textLinesMock = MockFactories.TextBufferFactory.GetInstance(); LocalRegistryMock mockLocalRegistry = new LocalRegistryMock(); mockLocalRegistry.AddClass(typeof(VsTextBufferClass), textLinesMock); BaseMock textViewMock = MockFactories.TextViewFactory.GetInstance(); mockLocalRegistry.AddClass(typeof(VsTextViewClass), textViewMock); provider.AddService(typeof(SLocalRegistry), mockLocalRegistry, false); // Create the tool window. using (IDisposable disposableObject = CommandWindowHelper.CreateConsoleWindow(provider) as IDisposable) { IVsWindowPane windowPane = disposableObject as IVsWindowPane; Assert.IsNotNull(windowPane); // Now call the IVsWindowPane's methods and check that they are redirect to // the implementation provided by the text view. IntPtr newHwnd; Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded( windowPane.CreatePaneWindow(IntPtr.Zero, 0, 0, 0, 0, out newHwnd))); Assert.IsTrue(1 == textViewMock.FunctionCalls(string.Format("{0}.{1}", typeof(IVsWindowPane).FullName, "CreatePaneWindow"))); Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded( windowPane.GetDefaultSize(null))); Assert.IsTrue(1 == textViewMock.FunctionCalls(string.Format("{0}.{1}", typeof(IVsWindowPane).FullName, "GetDefaultSize"))); Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded( windowPane.LoadViewState(null))); Assert.IsTrue(1 == textViewMock.FunctionCalls(string.Format("{0}.{1}", typeof(IVsWindowPane).FullName, "LoadViewState"))); Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded( windowPane.SaveViewState(null))); Assert.IsTrue(1 == textViewMock.FunctionCalls(string.Format("{0}.{1}", typeof(IVsWindowPane).FullName, "SaveViewState"))); Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded( windowPane.SetSite(null))); Assert.IsTrue(1 == textViewMock.FunctionCalls(string.Format("{0}.{1}", typeof(IVsWindowPane).FullName, "SetSite"))); Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded( windowPane.TranslateAccelerator(null))); Assert.IsTrue(1 == textViewMock.FunctionCalls(string.Format("{0}.{1}", typeof(IVsWindowPane).FullName, "TranslateAccelerator"))); Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded( windowPane.ClosePane())); Assert.IsTrue(1 == textViewMock.FunctionCalls(string.Format("{0}.{1}", typeof(IVsWindowPane).FullName, "ClosePane"))); } // Verify that the text view is closed after Dispose is called on the window pane. Assert.IsTrue(1 == textViewMock.FunctionCalls(string.Format("{0}.{1}", typeof(IVsTextView).FullName, "CloseView"))); } }
public int GetDefaultSize(Microsoft.VisualStudio.OLE.Interop.SIZE[] pSize) { return(codeWindow.GetDefaultSize(pSize)); }