public void Show_FindWindowSucceededButReturnedNullToolWindow_NoException()
        {
            var serviceProviderMock = new Mock <IServiceProvider>();
            var uiShellMock         = new Mock <IVsUIShell>();

            SetupFindToolWindow(serviceProviderMock, uiShellMock, VSConstants.S_OK, ValidToolWindowId, toolWindowObject: null);

            var testSubject = new ToolWindowService(serviceProviderMock.Object);

            Action act = () => testSubject.Show(ValidToolWindowId);

            act.Should().NotThrow();
        }
        public void Show_FindWindowSucceededAndNonNullToolWindow_ToolWindowShown()
        {
            var serviceProviderMock = new Mock <IServiceProvider>();
            var uiShellMock         = new Mock <IVsUIShell>();
            var frameMock           = new Mock <IVsWindowFrame>();

            SetupFindToolWindow(serviceProviderMock, uiShellMock, VSConstants.S_OK, ValidToolWindowId, frameMock.Object);

            var testSubject = new ToolWindowService(serviceProviderMock.Object);

            // Act
            testSubject.Show(ValidToolWindowId);

            frameMock.Verify(x => x.Show(), Times.Once);
        }
        public void Show_FindWindowFailed_NoExceptionAndFrameNotShown()
        {
            var serviceProviderMock = new Mock <IServiceProvider>();
            var uiShellMock         = new Mock <IVsUIShell>();
            var frameMock           = new Mock <IVsWindowFrame>();

            SetupFindToolWindow(serviceProviderMock, uiShellMock, VSConstants.E_OUTOFMEMORY, ValidToolWindowId, frameMock.Object);

            var testSubject = new ToolWindowService(serviceProviderMock.Object);

            // Act
            using (new AssertIgnoreScope())
            {
                testSubject.Show(ValidToolWindowId);
            }

            // Non-success HResult so shouldn't have attempted to show the frame
            frameMock.Invocations.Should().BeEmpty();
        }
        public void EnsureToolWindowExists_VsServiceCalled(int vsServiceResult)
        {
            var serviceProviderMock = new Mock <IServiceProvider>();
            var uiShellMock         = new Mock <IVsUIShell>();
            var frameMock           = new Mock <IVsWindowFrame>();

            SetupFindToolWindow(serviceProviderMock, uiShellMock, vsServiceResult, ValidToolWindowId, frameMock.Object);

            var testSubject = new ToolWindowService(serviceProviderMock.Object);

            // Act
            using (new AssertIgnoreScope())
            {
                testSubject.EnsureToolWindowExists(ValidToolWindowId);
            }

            uiShellMock.VerifyAll();

            // Should never attempt to show the frame
            frameMock.Invocations.Should().BeEmpty();
        }