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 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"); }