public void BindingController_BindingFinished_Navigation() { // Arrange ServerViewModel serverVM = CreateServerViewModel(); serverVM.SetProjects(new[] { new ProjectInformation { Key = "key1" } }); ProjectViewModel projectVM = serverVM.Projects.First(); BindingController testSubject = this.PrepareCommandForExecution(); this.host.VisualStateManager.ManagedState.ConnectedServers.Add(serverVM); var progressEvents = new ConfigurableProgressEvents(); var teController = new ConfigurableTeamExplorerController(); var mefExports = MefTestHelpers.CreateExport <ITeamExplorerController>(teController); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); // Case 1: On non-successful binding no navigation will occur foreach (ProgressControllerResult nonSuccuess in new[] { ProgressControllerResult.Cancelled, ProgressControllerResult.Failed }) { // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(nonSuccuess); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(0); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse(); } // Case 2: Has conflicts (should navigate to team explorer page) this.conflictsController.HasConflicts = true; // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse(); // Case 3: Has no conflicts (should navigate to solution explorer) this.conflictsController.HasConflicts = false; // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeTrue(); }
public void BindingController_BindingFinished_Navigation() { // Arrange var bindingArgs = new BindCommandArgs("key2", "", new ConnectionInformation(new Uri("http://myUri"))); BindingController testSubject = this.PrepareCommandForExecution(); var progressEvents = new ConfigurableProgressEvents(); var teController = new ConfigurableTeamExplorerController(); var mefExports = MefTestHelpers.CreateExport <ITeamExplorerController>(teController); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExports); serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); // Case 1: On non-successful binding no navigation will occur foreach (ProgressControllerResult nonSuccuess in new[] { ProgressControllerResult.Cancelled, ProgressControllerResult.Failed }) { // Act testSubject.SetBindingInProgress(progressEvents, bindingArgs); progressEvents.SimulateFinished(nonSuccuess); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(0); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse(); } // Case 2: Has conflicts (should navigate to team explorer page) this.conflictsController.HasConflicts = true; // Act testSubject.SetBindingInProgress(progressEvents, bindingArgs); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse(); // Case 3: Has no conflicts (should navigate to solution explorer) this.conflictsController.HasConflicts = false; // Act testSubject.SetBindingInProgress(progressEvents, bindingArgs); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeTrue(); }
public void BindingController_BindingFinished() { // Arrange var bindingArgs = new BindCommandArgs("key1", "name1", new ConnectionInformation(new Uri("http://localhost"))); BindingController testSubject = this.PrepareCommandForExecution(); var progressEvents = new ConfigurableProgressEvents(); foreach (ProgressControllerResult result in Enum.GetValues(typeof(ProgressControllerResult)).OfType <ProgressControllerResult>()) { // Arrange testSubject.SetBindingInProgress(progressEvents, bindingArgs); testSubject.IsBindingInProgress.Should().BeTrue(); // Act progressEvents.SimulateFinished(result); // Assert testSubject.IsBindingInProgress.Should().BeFalse(); if (result == ProgressControllerResult.Succeeded) { this.host.TestStateManager.AssignedProjectKey.Should().Be("key1"); } else { this.host.TestStateManager.AssignedProjectKey.Should().BeNull(); } } }
public void BindingController_SetBindingInProgress() { // Arrange ProjectViewModel projectVM = CreateProjectViewModel(); BindingController testSubject = this.PrepareCommandForExecution(); var progressEvents = new ConfigurableProgressEvents(); foreach (var controllerResult in (ProgressControllerResult[])Enum.GetValues(typeof(ProgressControllerResult))) { this.dteMock.ToolWindows.SolutionExplorer.Window.Active = false; // Sanity testSubject.BindCommand.CanExecute(projectVM).Should().BeTrue(); // Act - disable testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); // Assert testSubject.BindCommand.CanExecute(projectVM).Should().BeFalse("Binding is in progress so should not be enabled"); // Act - finish progressEvents.SimulateFinished(controllerResult); // Assert testSubject.BindCommand.CanExecute(projectVM).Should().BeTrue("Binding is finished with result: {0}", controllerResult); if (controllerResult == ProgressControllerResult.Succeeded) { this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeTrue("SolutionExplorer window supposed to be activated"); } else { this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse("SolutionExplorer window is not supposed to be activated"); } } }
public void BindingController_BindingFinished() { // Arrange ServerViewModel serverVM = CreateServerViewModel(); serverVM.SetProjects(new[] { new SonarQubeProject("key1", "") }); ProjectViewModel projectVM = serverVM.Projects.First(); BindingController testSubject = this.PrepareCommandForExecution(); this.host.VisualStateManager.ManagedState.ConnectedServers.Add(serverVM); var progressEvents = new ConfigurableProgressEvents(); foreach (ProgressControllerResult result in Enum.GetValues(typeof(ProgressControllerResult)).OfType <ProgressControllerResult>()) { // Arrange testSubject.SetBindingInProgress(progressEvents, projectVM.Project); testSubject.IsBindingInProgress.Should().BeTrue(); // Act progressEvents.SimulateFinished(result); // Assert testSubject.IsBindingInProgress.Should().BeFalse(); if (result == ProgressControllerResult.Succeeded) { this.host.TestStateManager.BoundProject.Should().Be(projectVM.Project); } else { this.host.TestStateManager.BoundProject.Should().BeNull(); } } }
public void BindingController_SetBindingInProgress_Notifications() { // Arrange ServerViewModel serverVM = CreateServerViewModel(); serverVM.SetProjects(new[] { new ProjectInformation { Key = "key1" } }); ProjectViewModel projectVM = serverVM.Projects.ToArray()[0]; BindingController testSubject = this.PrepareCommandForExecution(); var section = ConfigurableSectionController.CreateDefault(); this.host.SetActiveSection(section); var progressEvents = new ConfigurableProgressEvents(); this.host.ActiveSection.UserNotifications.ShowNotificationError("Need to make sure that this is clear once started", NotificationIds.FailedToBindId, new RelayCommand(() => { })); ConfigurableUserNotification userNotifications = (ConfigurableUserNotification)section.UserNotifications; foreach (ProgressControllerResult result in Enum.GetValues(typeof(ProgressControllerResult)).OfType <ProgressControllerResult>()) { // Act - start testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); // Assert userNotifications.AssertNoNotification(NotificationIds.FailedToBindId); // Act - finish progressEvents.SimulateFinished(result); // Assert if (result == ProgressControllerResult.Succeeded) { userNotifications.AssertNoNotification(NotificationIds.FailedToBindId); } else { userNotifications.AssertNotification(NotificationIds.FailedToBindId, Strings.FailedToToBindSolution); } } }
public void BindingController_BindingFinished() { // Setup ServerViewModel serverVM = CreateServerViewModel(); serverVM.SetProjects(new[] { new ProjectInformation { Key = "key1" } }); ProjectViewModel projectVM = serverVM.Projects.First(); BindingController testSubject = this.PrepareCommandForExecution(); this.host.VisualStateManager.ManagedState.ConnectedServers.Add(serverVM); var progressEvents = new ConfigurableProgressEvents(); foreach (ProgressControllerResult result in Enum.GetValues(typeof(ProgressControllerResult)).OfType <ProgressControllerResult>()) { // Setup testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); Assert.IsTrue(testSubject.IsBindingInProgress); // Act progressEvents.SimulateFinished(result); // Verify Assert.IsFalse(testSubject.IsBindingInProgress); if (result == ProgressControllerResult.Succeeded) { this.host.TestStateManager.AssertBoundProject(projectVM.ProjectInformation); } else { this.host.TestStateManager.AssertNoBoundProject(); } } }
public void BindingController_SetBindingInProgress() { // Arrange BindCommandArgs bindingArgs = CreateBindingArguments("key1", "name1", "http://localhost"); ConnectionInformation otherConnection = new ConnectionInformation(new Uri("http://otherConnection")); BindCommandArgs bindingInProgressArgs = new BindCommandArgs("another.key", "another.name", otherConnection); BindingController testSubject = this.PrepareCommandForExecution(); var progressEvents = new ConfigurableProgressEvents(); foreach (var controllerResult in (ProgressControllerResult[])Enum.GetValues(typeof(ProgressControllerResult))) { this.dteMock.ToolWindows.SolutionExplorer.Window.Active = false; // Sanity testSubject.BindCommand.CanExecute(bindingArgs).Should().BeTrue(); // Act - disable testSubject.SetBindingInProgress(progressEvents, bindingInProgressArgs); // Assert testSubject.BindCommand.CanExecute(bindingArgs).Should().BeFalse("Binding is in progress so should not be enabled"); // Act - finish progressEvents.SimulateFinished(controllerResult); // Assert testSubject.BindCommand.CanExecute(bindingArgs).Should().BeTrue("Binding is finished with result: {0}", controllerResult); if (controllerResult == ProgressControllerResult.Succeeded) { this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeTrue("SolutionExplorer window supposed to be activated"); } else { this.dteMock.ToolWindows.SolutionExplorer.Window.Active.Should().BeFalse("SolutionExplorer window is not supposed to be activated"); } } }
public void BindingController_SetBindingInProgress_Notifications() { // Arrange var bindingArgs = new BindCommandArgs("key2", "", new ConnectionInformation(new Uri("http://myUri"))); BindingController testSubject = this.PrepareCommandForExecution(); var section = ConfigurableSectionController.CreateDefault(); this.host.SetActiveSection(section); var progressEvents = new ConfigurableProgressEvents(); this.host.ActiveSection.UserNotifications.ShowNotificationError("Need to make sure that this is clear once started", NotificationIds.FailedToBindId, new RelayCommand(() => { })); ConfigurableUserNotification userNotifications = (ConfigurableUserNotification)section.UserNotifications; foreach (ProgressControllerResult result in Enum.GetValues(typeof(ProgressControllerResult)).OfType <ProgressControllerResult>()) { // Act - start testSubject.SetBindingInProgress(progressEvents, bindingArgs); // Assert userNotifications.AssertNoNotification(NotificationIds.FailedToBindId); // Act - finish progressEvents.SimulateFinished(result); // Assert if (result == ProgressControllerResult.Succeeded) { userNotifications.AssertNoNotification(NotificationIds.FailedToBindId); } else { userNotifications.AssertNotification(NotificationIds.FailedToBindId, Strings.FailedToToBindSolution); } } }