public void ManageConnectionsCommand_Invoke() { // Setup OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand(); var teController = new ConfigurableTeamExplorerController(); var serviceProvider = CreateServiceProviderWithMefExports <ITeamExplorerController>(teController); var testSubject = new ManageConnectionsCommand(serviceProvider); // Test case 1: was disabled command.Enabled = false; // Act using (new AssertIgnoreScope()) // Invoked when disabled { testSubject.Invoke(command, null); } // Verify teController.AssertExpectedNumCallsShowConnectionsPage(0); // Test case 2: was enabled command.Enabled = true; // Act testSubject.Invoke(command, null); // Verify teController.AssertExpectedNumCallsShowConnectionsPage(1); }
public void BindingController_BindingFinished_Navigation() { // 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(); 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); // Verify teController.AssertExpectedNumCallsShowConnectionsPage(0); Assert.IsFalse(this.dteMock.ToolWindows.SolutionExplorer.Window.Active); } // Case 2: Has conflicts (should navigate to team explorer page) this.conflictsController.HasConflicts = true; // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Verify teController.AssertExpectedNumCallsShowConnectionsPage(1); Assert.IsFalse(this.dteMock.ToolWindows.SolutionExplorer.Window.Active); // Case 3: Has no conflicts (should navigate to solution explorer) this.conflictsController.HasConflicts = false; // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Verify teController.AssertExpectedNumCallsShowConnectionsPage(1); Assert.IsTrue(this.dteMock.ToolWindows.SolutionExplorer.Window.Active); }
public void SonarQubeNavigationItem_Execute() { // Setup var serviceProvider = new ConfigurableServiceProvider(); var controller = new ConfigurableTeamExplorerController(); var testSubject = new SonarQubeNavigationItem(controller); // Act testSubject.Execute(); // Verify controller.AssertExpectedNumCallsShowConnectionsPage(1); }
public void SonarQubeNavigationItem_Execute() { // Setup var serviceProvider = new ConfigurableServiceProvider(); var controller = new ConfigurableTeamExplorerController(); var testSubject = new SonarQubeNavigationItem(controller); // Act testSubject.Execute(); // Verify controller.AssertExpectedNumCallsShowConnectionsPage(1); }
public void BindingController_BindingFinished_Navigation() { // 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(); 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); // Verify teController.AssertExpectedNumCallsShowConnectionsPage(0); Assert.IsFalse(this.dteMock.ToolWindows.SolutionExplorer.Window.Active); } // Case 2: Has conflicts (should navigate to team explorer page) this.conflictsController.HasConflicts = true; // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Verify teController.AssertExpectedNumCallsShowConnectionsPage(1); Assert.IsFalse(this.dteMock.ToolWindows.SolutionExplorer.Window.Active); // Case 3: Has no conflicts (should navigate to solution explorer) this.conflictsController.HasConflicts = false; // Act testSubject.SetBindingInProgress(progressEvents, projectVM.ProjectInformation); progressEvents.SimulateFinished(ProgressControllerResult.Succeeded); // Verify teController.AssertExpectedNumCallsShowConnectionsPage(1); Assert.IsTrue(this.dteMock.ToolWindows.SolutionExplorer.Window.Active); }