public void ErrorListInfoBarController_InfoBar_ClickButton_MoreThanOnce()
{
// Arrange
this.SetBindingMode(SonarLintMode.LegacyConnected);
var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);
this.ConfigureLoadedSolution();
int bindCommandExecuted = 0;
ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(args => { bindCommandExecuted++; });
this.ConfigureProjectViewModel(section);
testSubject.Refresh();
RunAsyncAction();
this.stateManager.SetAndInvokeBusyChanged(true);
// Sanity
ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
VerifyInfoBar(infoBar);
this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(0);
// Act (command enabled)
infoBar.SimulateButtonClickEvent();
// Assert
this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(1);
// Act (click again)
infoBar.SimulateButtonClickEvent();
// Assert
this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(1);
this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
infoBar.VerifyAllEventsRegistered(); // Should be usable
// Act (not busy anymore)
this.stateManager.SetAndInvokeBusyChanged(false);
// Assert
this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(1);
this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
infoBar.VerifyAllEventsUnregistered();
bindCommandExecuted.Should().Be(1, "Expecting the command to be executed only once");
}