public ConfigurableVsWindowFrame RegisterToolWindow(Guid toolWindowGuid) { ConfigurableVsWindowFrame frame = new ConfigurableVsWindowFrame(); this.toolwindowFrames[toolWindowGuid] = frame; return(frame); }
private static ConfigurableVsInfoBarHost RegisterFrameInfoBarHost(ConfigurableVsWindowFrame frame) { var host = new ConfigurableVsInfoBarHost(); frame.RegisterProperty((int)__VSFPROPID7.VSFPROPID_InfoBarHost, host); return(host); }
public void InfoBarManager_AttachInfoBar_Failures() { // Setup Guid windowGuid = new Guid(); ConfigurableVsWindowFrame frame = this.shell.RegisterToolWindow(windowGuid); var testSubject = new InfoBarManager(this.serviceProvider); // Case 1: No service this.serviceProvider.AssertOnUnexpectedServiceRequest = false; // Act + Verify Assert.IsNull(testSubject.AttachInfoBar(windowGuid, "Hello", "world", default(ImageMoniker))); frame.AssertShowNoActivateCalled(0); // Case 2: Service exists, no host for frame this.serviceProvider.RegisterService(typeof(SVsInfoBarUIFactory), new ConfigurableVsInfoBarUIFactory()); // Act + Verify Assert.IsNull(testSubject.AttachInfoBar(windowGuid, "Hello", "world", default(ImageMoniker))); frame.AssertShowNoActivateCalled(0); }
public void InfoBarManager_AttachInfoBar_Failures() { // Arrange Guid windowGuid = new Guid(); ConfigurableVsWindowFrame frame = this.shell.RegisterToolWindow(windowGuid); var testSubject = new InfoBarManager(this.serviceProvider); // Case 1: No service this.serviceProvider.AssertOnUnexpectedServiceRequest = false; // Act + Assert testSubject.AttachInfoBarWithButton(windowGuid, "Hello", "world", default).Should().BeNull(); frame.ShowNoActivateCalledCount.Should().Be(0); // Case 2: Service exists, no host for frame this.serviceProvider.RegisterService(typeof(SVsInfoBarUIFactory), new ConfigurableVsInfoBarUIFactory()); // Act + Assert testSubject.AttachInfoBarWithButton(windowGuid, "Hello", "world", default).Should().BeNull(); frame.ShowNoActivateCalledCount.Should().Be(0); }
public void InfoBarManager_DetachInfoBar() { // Setup Guid windowGuid = new Guid(); ConfigurableVsWindowFrame frame = this.shell.RegisterToolWindow(windowGuid); this.serviceProvider.RegisterService(typeof(SVsInfoBarUIFactory), new ConfigurableVsInfoBarUIFactory()); var testSubject = new InfoBarManager(this.serviceProvider); ConfigurableVsInfoBarHost host = RegisterFrameInfoBarHost(frame); IInfoBar infoBarWrapper = testSubject.AttachInfoBar(windowGuid, "Hello", "world", default(ImageMoniker)); bool closed = false; infoBarWrapper.Closed += (s, e) => closed = true; // Sanity host.AssertInfoBars(1); // Act testSubject.DetachInfoBar(infoBarWrapper); // Verify Assert.IsTrue(closed, "Expected to auto-close"); host.AssertInfoBars(0); }
private static ConfigurableVsInfoBarHost RegisterFrameInfoBarHost(ConfigurableVsWindowFrame frame) { var host = new ConfigurableVsInfoBarHost(); frame.RegisterProperty((int)__VSFPROPID7.VSFPROPID_InfoBarHost, host); return host; }
public ConfigurableVsWindowFrame RegisterToolWindow(Guid toolWindowGuid) { ConfigurableVsWindowFrame frame = new ConfigurableVsWindowFrame(); this.toolwindowFrames[toolWindowGuid] = frame; return frame; }
public void InfoBarManager_AttachInfoBar() { // Setup Guid windowGuid = new Guid(); ConfigurableVsWindowFrame frame = this.shell.RegisterToolWindow(windowGuid); this.serviceProvider.RegisterService(typeof(SVsInfoBarUIFactory), new ConfigurableVsInfoBarUIFactory()); var testSubject = new InfoBarManager(this.serviceProvider); ConfigurableVsInfoBarHost host = RegisterFrameInfoBarHost(frame); // Sanity host.AssertInfoBars(0); // Act IInfoBar infoBarWrapper = testSubject.AttachInfoBar(windowGuid, "Hello", "world", KnownMonikers.UserWarning); frame.AssertShowNoActivateCalled(1); bool actionClicked = false; bool closed = false; infoBarWrapper.ButtonClick += (s, e) => actionClicked = true; infoBarWrapper.Closed += (s, e) => closed = true; // Verify Assert.IsNotNull(infoBarWrapper); host.AssertInfoBars(1); var infoBarUI = host.MockedElements.Single(); Assert.AreEqual(1, infoBarUI.Model.TextSpans.Count); Assert.AreEqual("Hello", infoBarUI.Model.TextSpans.GetSpan(0).Text); Assert.AreEqual(1, infoBarUI.Model.ActionItems.Count); Assert.AreEqual("world", infoBarUI.Model.ActionItems.GetItem(0).Text); // Sanity Assert.IsFalse(actionClicked); Assert.IsFalse(closed); // Act (check if close event is fired) infoBarUI.SimulateClickEvent(); // Verify Assert.IsTrue(actionClicked); Assert.IsFalse(closed); // Act (check if close event is fired) infoBarUI.SimulateClosedEvent(); // Verify Assert.IsTrue(closed); // Act (check that events won't fire once closed) actionClicked = false; closed = false; infoBarUI.SimulateClickEvent(); infoBarWrapper.Close(); infoBarUI.SimulateClosedEvent(); // Verify Assert.IsFalse(actionClicked); Assert.IsFalse(closed); frame.AssertShowNoActivateCalled(1); // Should only be called once in all this flow }