public void ManageConnectionsCommand_Invoke() { // Arrange 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); } // Assert teController.ShowConnectionsPageCallsCount.Should().Be(0); // Test case 2: was enabled command.Enabled = true; // Act testSubject.Invoke(command, null); // Assert teController.ShowConnectionsPageCallsCount.Should().Be(1); }
public void ManageConnectionsCommand_QueryStatus() { // Arrange OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand(); // Test case 1: no TE controller // Arrange command.Enabled = false; var testSubject1 = new ManageConnectionsCommand(null); // Act testSubject1.QueryStatus(command, null); // Assert command.Enabled.Should().BeFalse("Expected the command to be disabled on QueryStatus when no TE controller"); // Test case 2: has TE controller // Arrange var teController = new ConfigurableTeamExplorerController(); var testSubject2 = new ManageConnectionsCommand(teController); // Act testSubject2.QueryStatus(command, null); // Assert command.Enabled.Should().BeTrue("Expected the command to be disabled on QueryStatus when does have TE controller"); }
public void ManageConnectionsCommand_QueryStatus() { // Arrange OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand(); // Test case 1: no TE controller // Arrange IServiceProvider sp1 = CreateServiceProviderWithEmptyComponentModel(); command.Enabled = false; ManageConnectionsCommand testSubject1; using (new AssertIgnoreScope()) // TE service is missing from MEF { testSubject1 = new ManageConnectionsCommand(null); } // Act testSubject1.QueryStatus(command, null); // Assert command.Enabled.Should().BeFalse("Expected the command to be disabled on QueryStatus when no TE controller"); // Test case 2: has TE controller // Arrange var teController = new ConfigurableTeamExplorerController(); var testSubject2 = new ManageConnectionsCommand(teController); // Act testSubject2.QueryStatus(command, null); // Assert command.Enabled.Should().BeTrue("Expected the command to be disabled on QueryStatus when does have TE controller"); }
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 SonarQubeNavigationItem_Execute() { // Arrange var controller = new ConfigurableTeamExplorerController(); var testSubject = new SonarQubeNavigationItem(controller); // Act testSubject.Execute(); // Assert controller.ShowConnectionsPageCallsCount.Should().Be(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 SonarQubeNavigationItem_Ctor() { // Arrange var controller = new ConfigurableTeamExplorerController(); // Act var testSubject = new SonarQubeNavigationItem(controller); // Assert testSubject.IsVisible.Should().BeTrue("Nav item should be visible"); testSubject.IsEnabled.Should().BeTrue("Nav item should be enabled"); testSubject.Text.Should().Be(Strings.TeamExplorerPageTitle, "Unexpected nav text"); testSubject.Icon.Should().NotBeNull("Icon should not be null"); }
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 SonarQubeNavigationItem_Ctor() { // Setup var serviceProvider = new ConfigurableServiceProvider(); var controller = new ConfigurableTeamExplorerController(); // Act var testSubject = new SonarQubeNavigationItem(controller); // Verify Assert.IsTrue(testSubject.IsVisible, "Nav item should be visible"); Assert.IsTrue(testSubject.IsEnabled, "Nav item should be enabled"); Assert.AreEqual(Strings.TeamExplorerPageTitle, testSubject.Text, "Unexpected nav text"); Assert.IsNotNull(testSubject.Icon, "Icon should not be null"); }
public void ManageConnectionsCommand_QueryStatus() { // Setup OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand(); // Test case 1: no TE controller // Setup IServiceProvider sp1 = CreateServiceProviderWithEmptyComponentModel(); command.Enabled = false; ManageConnectionsCommand testSubject1; using (new AssertIgnoreScope()) // TE service is missing from MEF { testSubject1 = new ManageConnectionsCommand(sp1); } // Act testSubject1.QueryStatus(command, null); // Verify Assert.IsFalse(command.Enabled, "Expected the command to be disabled on QueryStatus when no TE controller"); // Test case 2: has TE controller // Setup var teController = new ConfigurableTeamExplorerController(); var sp2 = CreateServiceProviderWithMefExports <ITeamExplorerController>(teController); var testSubject2 = new ManageConnectionsCommand(sp2); // Act testSubject2.QueryStatus(command, null); // Verify Assert.IsTrue(command.Enabled, "Expected the command to be disabled on QueryStatus when does have TE controller"); }
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); }