public AssertInfoBars ( int expectedNumberOfInfoBars ) : void | ||
expectedNumberOfInfoBars | int | |
return | void |
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); }
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 }