SimulateButtonClickEvent() public method

public SimulateButtonClickEvent ( ) : void
return void
Ejemplo n.º 1
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasConnectedActiveSection_NotBusy()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            int              bindExecuted         = 0;
            bool             canExecute           = false;
            ProjectViewModel project              = null;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(args =>
            {
                bindExecuted++;
                args.ProjectKey.Should().Be(project.Key);
                args.ProjectName.Should().Be(project.ProjectName);
            }, args => canExecute);

            this.ConfigureActiveSectionWithRefreshCommand(c =>
            {
                FluentAssertions.Execution.Execute.Assertion.FailWith("Refresh is not expected to be called");
            });
            this.ConfigureActiveSectionWithDisconnectCommand(() =>
            {
                FluentAssertions.Execution.Execute.Assertion.FailWith("Disconnect is not expected to be called");
            });
            project = this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (command disabled)
            infoBar.SimulateButtonClickEvent();

            // Assert
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(1);
            bindExecuted.Should().Be(0, "Update was not expected to be executed");
            this.outputWindowPane.AssertOutputStrings(1);

            // Act (command enabled)
            canExecute = true;
            infoBar.SimulateButtonClickEvent();

            // Assert
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(2);
            bindExecuted.Should().Be(1, "Update was expected to be executed");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
            this.outputWindowPane.AssertOutputStrings(1);
        }
Ejemplo n.º 2
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasConnectedActiveSection_NotBusy()
        {
            // Setup
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            int              bindExecuted         = 0;
            bool             canExecute           = false;
            ProjectViewModel project              = null;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(vm =>
            {
                bindExecuted++;
                Assert.AreSame(project, vm);
            }, vm => canExecute);

            this.ConfigureActiveSectionWithRefreshCommand(c =>
            {
                Assert.Fail("Refresh is not expected to be called");
            });
            this.ConfigureActiveSectionWithDisconnectCommand(() =>
            {
                Assert.Fail("Disconnect is not expected to be called");
            });
            project = this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (command disabled)
            infoBar.SimulateButtonClickEvent();

            // Verify
            this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(1);
            Assert.AreEqual(0, bindExecuted, "Update was not expected to be executed");
            this.outputWindowPane.AssertOutputStrings(1);

            // Act (command enabled)
            canExecute = true;
            infoBar.SimulateButtonClickEvent();

            // Verify
            this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(2);
            Assert.AreEqual(1, bindExecuted, "Update was expected to be executed");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
            this.outputWindowPane.AssertOutputStrings(1);
        }
Ejemplo n.º 3
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_SolutionBindingAreDifferentThatTheOnesUsedForTheInfoBar_NoOp()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            this.host.SetActiveSection(ConfigurableSectionController.CreateDefault());
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Change binding
            this.configProvider.ProjectToReturn = new BoundSonarQubeProject(new Uri("http://server"), "SomeOtherProjectKey", "projectName");

            // Act
            infoBar.SimulateButtonClickEvent();

            // Assert
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(0);
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            this.outputWindowPane.AssertOutputStrings(1);
        }
Ejemplo n.º 4
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_NoLongerInConnected_NoOp()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            this.host.SetActiveSection(ConfigurableSectionController.CreateDefault());
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Change binding
            this.SetBindingMode(SonarLintMode.Standalone);

            // Act
            infoBar.SimulateButtonClickEvent();

            // Assert
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(0);
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            this.outputWindowPane.AssertOutputStrings(1);
        }
Ejemplo n.º 5
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_SolutionBindingAreDifferentThatTheOnesUsedForTheInfoBar()
        {
            // Arrange
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            this.host.SetActiveSection(ConfigurableSectionController.CreateDefault());
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Change binding
            this.solutionBindingSerializer.CurrentBinding = new Persistence.BoundSonarQubeProject(new Uri("http://server"), "SomeOtherProjectKey");

            // Act
            infoBar.SimulateButtonClickEvent();

            // Assert
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(0);
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            this.outputWindowPane.AssertOutputStrings(1);
        }
Ejemplo n.º 6
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_NoLongerInLegacyConnected_NoOp()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.solutionBindingInformationProvider);

            this.ConfigureLoadedSolution();
            this.host.SetActiveSection(ConfigurableSectionController.CreateDefault());
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Change binding
            // Note: in practice we can't switch from legacy to new connected mode, but the important
            // thing for this test is that the solution isn't in legacy mode
            this.SetBindingMode(SonarLintMode.Connected);

            // Act
            infoBar.SimulateButtonClickEvent();

            // Assert
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(0);
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            this.outputWindowPane.AssertOutputStrings(1);
        }
Ejemplo n.º 7
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_ConnectedToADifferentServer()
        {
            // Setup
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            int refreshCalled = 0;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithRefreshCommand(c =>
            {
                Assert.AreEqual(this.solutionBindingSerializer.CurrentBinding.ServerUri, c.ServerUri);
                refreshCalled++;
            });
            int disconnectCalled = 0;

            this.ConfigureActiveSectionWithDisconnectCommand(() =>
            {
                disconnectCalled++;
            });
            int bindCalled = 0;

            this.ConfigureActiveSectionWithBindCommand(vm =>
            {
                Assert.AreEqual(this.solutionBindingSerializer.CurrentBinding.ProjectKey, vm.Key);
                bindCalled++;
            });

            this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);
            this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(0);

            // Connect to a different server
            this.ConfigureProjectViewModel(section, new Uri("http://SomeOtherServer"), "someOtherProjectKey");

            // Act
            infoBar.SimulateButtonClickEvent();

            // Verify
            Assert.AreEqual(1, disconnectCalled, "Should have been disconnected");
            Assert.AreEqual(1, refreshCalled, "Also expected to connect to the right server");
            Assert.AreEqual(0, bindCalled, "Busy, should not be executed");

            // Simulate that connected to the project that is bound to
            this.ConfigureProjectViewModel(section);

            // Act
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Verify
            Assert.AreEqual(1, bindCalled, "Should be bound");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
        }
Ejemplo n.º 8
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_ConnectedToADifferentServer()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            int refreshCalled = 0;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithRefreshCommand(c =>
            {
                c.ServerUri.Should().Be(this.configProvider.ProjectToReturn.ServerUri);
                refreshCalled++;
            });
            int disconnectCalled = 0;

            this.ConfigureActiveSectionWithDisconnectCommand(() =>
            {
                disconnectCalled++;
            });
            int bindCalled = 0;

            this.ConfigureActiveSectionWithBindCommand(args =>
            {
                args.ProjectKey.Should().Be(this.configProvider.ProjectToReturn.ProjectKey);
                bindCalled++;
            });

            this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(0);

            // Connect to a different server
            this.ConfigureProjectViewModel(section, new Uri("http://SomeOtherServer"), "someOtherProjectKey");

            // Act
            infoBar.SimulateButtonClickEvent();

            // Assert
            disconnectCalled.Should().Be(1, "Should have been disconnected");
            refreshCalled.Should().Be(1, "Also expected to connect to the right server");
            bindCalled.Should().Be(0, "Busy, should not be executed");

            // Simulate that connected to the project that is bound to
            this.ConfigureProjectViewModel(section);

            // Act
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Assert
            bindCalled.Should().Be(1, "Should be bound");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
        }
Ejemplo n.º 9
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_MoreThanOnce()
        {
            // Setup
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            int bindCommandExecuted = 0;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(vm => { bindCommandExecuted++; });

            this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();
            this.stateManager.SetAndInvokeBusyChanged(true);

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);
            this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(0);

            // Act (command enabled)
            infoBar.SimulateButtonClickEvent();

            // Verify
            this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(1);

            // Act (click again)
            infoBar.SimulateButtonClickEvent();

            // Verify
            this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(1);
            this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsRegistered(); // Should be usable

            // Act (not busy anymore)
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Verify
            this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(1);
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
            Assert.AreEqual(1, bindCommandExecuted, "Expecting the command to be executed only once");
        }
Ejemplo n.º 10
0
        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");
        }
Ejemplo n.º 11
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasDisconnectedActiveSection()
        {
            // Arrange
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            int bindingCalled = 0;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(args =>
            {
                bindingCalled++;
                args.ProjectKey.Should().Be(this.configProvider.ProjectToReturn.ProjectKey);
            });
            int refreshCalled = 0;

            this.ConfigureActiveSectionWithRefreshCommand(connection =>
            {
                refreshCalled++;
                connection.ServerUri.Should().Be(this.configProvider.ProjectToReturn.ServerUri);
            });
            int disconnectCalled = 0;

            this.ConfigureActiveSectionWithDisconnectCommand(() =>
            {
                disconnectCalled++;
            });
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (kick off connection)
            infoBar.SimulateButtonClickEvent();

            // Assert
            refreshCalled.Should().Be(1, "Expected to connect once");
            disconnectCalled.Should().Be(0, "Not expected to disconnect");
            bindingCalled.Should().Be(0, "Not expected to bind yet");

            // Act (connected)
            this.ConfigureProjectViewModel(section);
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Assert
            refreshCalled.Should().Be(1, "Expected to connect once");
            bindingCalled.Should().Be(1, "Expected to bind once");
            disconnectCalled.Should().Be(0, "Not expected to disconnect");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
            this.outputWindowPane.AssertOutputStrings(0);
        }
Ejemplo n.º 12
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasDisconnectedActiveSection()
        {
            // Setup
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            int bindingCalled = 0;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(vm =>
            {
                bindingCalled++;
                Assert.AreEqual(this.solutionBindingSerializer.CurrentBinding.ProjectKey, vm.Key);
            });
            int refreshCalled = 0;

            this.ConfigureActiveSectionWithRefreshCommand(connection =>
            {
                refreshCalled++;
                Assert.AreEqual(this.solutionBindingSerializer.CurrentBinding.ServerUri, connection.ServerUri);
            });
            int disconnectCalled = 0;

            this.ConfigureActiveSectionWithDisconnectCommand(() =>
            {
                disconnectCalled++;
            });
            this.IsActiveSolutionBound = true;
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (kick off connection)
            infoBar.SimulateButtonClickEvent();

            // Verify
            Assert.AreEqual(1, refreshCalled, "Expected to connect once");
            Assert.AreEqual(0, disconnectCalled, "Not expected to disconnect");
            Assert.AreEqual(0, bindingCalled, "Not expected to bind yet");

            // Act (connected)
            this.ConfigureProjectViewModel(section);
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Verify
            Assert.AreEqual(1, refreshCalled, "Expected to connect once");
            Assert.AreEqual(1, bindingCalled, "Expected to bind once");
            Assert.AreEqual(0, disconnectCalled, "Not expected to disconnect");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
            this.outputWindowPane.AssertOutputStrings(0);
        }
Ejemplo n.º 13
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasActiveSection_WasBusyAndSectionClosed()
        {
            // Arrange
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            int executed             = 0;
            ProjectViewModel project = null;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(vm =>
            {
                executed++;
                vm.Should().Be(project);
            });

            project = 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
            executed.Should().Be(0, "Busy, should not be executed");

            // Act (close the current section)
            this.host.ClearActiveSection();
            this.stateManager.SetAndInvokeBusyChanged(false);
            RunAsyncAction();

            // Assert
            executed.Should().Be(0, "Update was not expected to be executed since there is not ActiveSection");
            this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsRegistered(); // Should be usable
        }
Ejemplo n.º 14
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasActiveSection_WasBusyAndInfoBarClosed()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            int executed             = 0;
            ProjectViewModel project = null;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(args =>
            {
                executed++;
                args.ProjectKey.Should().Be(project.Key);
                args.ProjectName.Should().Be(project.ProjectName);
            });

            project = this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();
            this.stateManager.SetAndInvokeBusyChanged(true);

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (command enabled)
            infoBar.SimulateButtonClickEvent();

            // Assert
            executed.Should().Be(0, "Busy, should not be executed");

            // Act (close the current info bar)
            testSubject.Reset();
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Assert
            executed.Should().Be(1, "Once started, the process can only be canceled from team explorer, closing the info bar should not impact the running update execution");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
        }
Ejemplo n.º 15
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasDisconnectedActiveSection_ConnectCommandIsBusy()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            int bindingCalled        = 0;
            ProjectViewModel project = null;

            this.ConfigureActiveSectionWithBindCommand(args =>
            {
                bindingCalled++;
                args.ProjectKey.Should().Be(project.Key);
                args.ProjectName.Should().Be(project.ProjectName);
            });
            int refreshCalled = 0;

            this.ConfigureActiveSectionWithRefreshCommand(connection =>
            {
                refreshCalled++;
            }, connection => false);
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (kick off connection)
            infoBar.SimulateButtonClickEvent();

            // Assert
            refreshCalled.Should().Be(0, "Expected to connect once");
            bindingCalled.Should().Be(0, "Not expected to bind yet");
            this.outputWindowPane.AssertOutputStrings(1);
            infoBar.VerifyAllEventsRegistered();
            this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
        }
Ejemplo n.º 16
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_NoActiveSection_NavigatesToSection()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            testSubject.Refresh();
            RunAsyncAction();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act
            infoBar.SimulateButtonClickEvent();

            // Assert
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(1);
        }
Ejemplo n.º 17
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_NoActiveSection_NavigatesToSection()
        {
            // Setup
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            testSubject.Refresh();
            RunAsyncAction();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act
            infoBar.SimulateButtonClickEvent();

            // Verify
            this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(1);
        }
Ejemplo n.º 18
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasDisconnectedActiveSection_ConnectCommandIsBusy()
        {
            // Setup
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            int bindingCalled        = 0;
            ProjectViewModel project = null;

            this.ConfigureActiveSectionWithBindCommand(vm =>
            {
                bindingCalled++;
                Assert.AreSame(project, vm);
            });
            int refreshCalled = 0;

            this.ConfigureActiveSectionWithRefreshCommand(connection =>
            {
                refreshCalled++;
            }, connection => false);
            testSubject.Refresh();
            RunAsyncAction();
            this.outputWindowPane.Reset();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (kick off connection)
            infoBar.SimulateButtonClickEvent();

            // Verify
            Assert.AreEqual(0, refreshCalled, "Expected to connect once");
            Assert.AreEqual(0, bindingCalled, "Not expected to bind yet");
            this.outputWindowPane.AssertOutputStrings(1);
            infoBar.VerifyAllEventsRegistered();
            this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
        }
Ejemplo n.º 19
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasActiveSection_WasBusyAndInfoBarClosed()
        {
            // Setup
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            int executed             = 0;
            ProjectViewModel project = null;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(vm =>
            {
                executed++;
                Assert.AreSame(project, vm);
            });

            project = this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();
            this.stateManager.SetAndInvokeBusyChanged(true);

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (command enabled)
            infoBar.SimulateButtonClickEvent();

            // Verify
            Assert.AreEqual(0, executed, "Busy, should not be executed");

            // Act (close the current info bar)
            testSubject.Reset();
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Verify
            Assert.AreEqual(1, executed, "Once started, the process can only be canceled from team explorer, closing the info bar should not impact the running update execution");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
        }
Ejemplo n.º 20
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasConnectedActiveSection_IsBusy()
        {
            // Arrange
            this.SetBindingMode(SonarLintMode.LegacyConnected);
            var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder);

            this.ConfigureLoadedSolution();
            int executed             = 0;
            ProjectViewModel project = null;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(args =>
            {
                executed++;
                args.ProjectKey.Should().Be(project.Key);
            });

            project = this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();
            this.stateManager.SetAndInvokeBusyChanged(true);

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (command enabled)
            infoBar.SimulateButtonClickEvent();

            // Assert
            executed.Should().Be(0, "Busy, should not be executed");

            // Act
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Assert
            executed.Should().Be(1, "Update was expected to be executed");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
        }
Ejemplo n.º 21
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasConnectedActiveSection_IsBusy()
        {
            // Setup
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            int executed             = 0;
            ProjectViewModel project = null;
            ConfigurableSectionController section = this.ConfigureActiveSectionWithBindCommand(vm =>
            {
                executed++;
                Assert.AreSame(project, vm);
            });

            project = this.ConfigureProjectViewModel(section);
            testSubject.Refresh();
            RunAsyncAction();
            this.stateManager.SetAndInvokeBusyChanged(true);

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act (command enabled)
            infoBar.SimulateButtonClickEvent();

            // Verify
            Assert.AreEqual(0, executed, "Busy, should not be executed");

            // Act
            this.stateManager.SetAndInvokeBusyChanged(false);

            // Verify
            Assert.AreEqual(1, executed, "Update was expected to be executed");
            this.infoBarManager.AssertHasNoAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);
            infoBar.VerifyAllEventsUnregistered();
        }
Ejemplo n.º 22
0
        public void ErrorListInfoBarController_InfoBar_ClickButton_HasActiveSection_NavigatesToSection()
        {
            // Arrange
            this.IsActiveSolutionBound = true;
            var testSubject = new ErrorListInfoBarController(this.host);

            this.ConfigureLoadedSolution();
            this.host.SetActiveSection(ConfigurableSectionController.CreateDefault());
            testSubject.Refresh();
            RunAsyncAction();

            // Sanity
            ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid);

            VerifyInfoBar(infoBar);

            // Act
            infoBar.SimulateButtonClickEvent();

            // Assert
            this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(1);
        }