public async Task TestFindToolWindow_ReturnsExistingInstance() { Mock <IVsUIShell> uiShellMock = ServiceProviderMock.SetupService <SVsUIShell, IVsUIShell>(); Guid classId = Guid.Empty; Guid activate = Guid.Empty; Guid persistenceSlot = typeof(LogsViewerToolWindow).GUID; // ReSharper disable once RedundantAssignment IVsWindowFrame frame = VsWindowFrameMocks.GetMockedWindowFrame(); uiShellMock.Setup( shell => shell.CreateToolWindow( It.IsAny <uint>(), It.IsAny <uint>(), It.IsAny <object>(), ref classId, ref persistenceSlot, ref activate, It.IsAny <IServiceProvider>(), It.IsAny <string>(), It.IsAny <int[]>(), out frame)) .Returns(VSConstants.S_OK); await RunPackageInitializeAsync(); _objectUnderTest.AddService( typeof(SVsUIShell), (container, token, type) => Task.FromResult <object>(uiShellMock.Object)); var toolWindow = _objectUnderTest.FindToolWindow <LogsViewerToolWindow>(true); var existingWindow = _objectUnderTest.FindToolWindow <LogsViewerToolWindow>(false); Assert.AreEqual(toolWindow, existingWindow); }
public void TestFindToolWindow_ReturnsInstanceForCreateTrue() { Mock <IVsUIShell> uiShellMock = ServiceProviderMock.SetupService <SVsUIShell, IVsUIShell>(); Guid clsid = Guid.Empty; Guid activate = Guid.Empty; Guid persistenceSlot = typeof(LogsViewerToolWindow).GUID; // ReSharper disable once RedundantAssignment IVsWindowFrame frame = VsWindowFrameMocks.GetMockedWindowFrame(); uiShellMock.Setup( shell => shell.CreateToolWindow( It.IsAny <uint>(), It.IsAny <uint>(), It.IsAny <object>(), ref clsid, ref persistenceSlot, ref activate, It.IsAny <IServiceProvider>(), It.IsAny <string>(), It.IsAny <int[]>(), out frame)).Returns(VSConstants.S_OK); RunPackageInitalize(); var toolWindow = _objectUnderTest.FindToolWindow <LogsViewerToolWindow>(true); Assert.IsNotNull(toolWindow); }