public void StateManager_SyncCommandFromActiveSection() { // Arrange var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host, section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new SonarQubeProject[] { new SonarQubeProject("", ""), new SonarQubeProject("", "") }; testSubject.SetProjects(connection1, projects); ServerViewModel serverVM = testSubject.ManagedState.ConnectedServers.Single(); // Case 1: has active section host.SetActiveSection(section); // Act testSubject.SyncCommandFromActiveSection(); VerifySectionCommands(section, serverVM); // Case 2: has no active section host.ClearActiveSection(); // Act testSubject.SyncCommandFromActiveSection(); VerifyNoCommands(serverVM); // Case 3: re-active host.SetActiveSection(section); // Act testSubject.SyncCommandFromActiveSection(); VerifySectionCommands(section, serverVM); }
public void StateManager_ClearBoundProject() { // Arrange var section = ConfigurableSectionController.CreateDefault(); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ConfigurableHost host = new ConfigurableHost(); host.SetActiveSection(section); StateManager testSubject = this.CreateTestSubject(host); section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.ManagedState.ConnectedServers.Add(new ServerViewModel(new ConnectionInformation(new Uri("http://zzz1")))); testSubject.ManagedState.ConnectedServers.Add(new ServerViewModel(new ConnectionInformation(new Uri("http://zzz2")))); testSubject.ManagedState.ConnectedServers.ToList().ForEach(s => s.Projects.Add(new ProjectViewModel(s, new SonarQubeProject(Guid.NewGuid().ToString(), "")))); var allProjects = testSubject.ManagedState.ConnectedServers.SelectMany(s => s.Projects).ToList(); testSubject.SetBoundProject(new Uri("http://zzz1"), null, allProjects.First().Project.Key); // Sanity testSubject.ManagedState.HasBoundProject.Should().BeTrue(); // Act testSubject.ClearBoundProject(); // Assert testSubject.ManagedState.HasBoundProject.Should().BeFalse(); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); }
public void StateManager_BindCommand_DynamicText() { // Arrange var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host, section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new SonarQubeProject[] { new SonarQubeProject("", "") }; testSubject.SetProjects(connection1, projects); ProjectViewModel projectVM = testSubject.ManagedState.ConnectedServers.Single().Projects.Single(); host.SetActiveSection(section); testSubject.SyncCommandFromActiveSection(); ContextualCommandViewModel bindCmd = projectVM.Commands.First(x => x.InternalRealCommand.Equals(section.BindCommand)); // Case 1: Bound projectVM.IsBound = true; // Act + Assert bindCmd.DisplayText.Should().Be(Strings.SyncButtonText, "Unexpected disabled context command text"); // Case 2: Not bound projectVM.IsBound = false; // Act + Assert bindCmd.DisplayText.Should().Be(Strings.BindButtonText, "Unexpected context command text"); }
public void StateManager_ToggleShowAllProjectsCommand_DynamicText() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host, section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new ProjectInformation[] { new ProjectInformation(), new ProjectInformation() }; testSubject.SetProjects(connection1, projects); ServerViewModel serverVM = testSubject.ManagedState.ConnectedServers.Single(); host.SetActiveSection(section); testSubject.SyncCommandFromActiveSection(); ContextualCommandViewModel toggleContextCmd = serverVM.Commands.First(x => x.InternalRealCommand.Equals(section.ToggleShowAllProjectsCommand)); // Case 1: No bound projects serverVM.ShowAllProjects = true; // Act + Verify Assert.AreEqual(Strings.HideUnboundProjectsCommandText, toggleContextCmd.DisplayText, "Unexpected disabled context command text"); // Case 2: has bound projects serverVM.ShowAllProjects = false; // Act + Verify Assert.AreEqual(Strings.ShowAllProjectsCommandText, toggleContextCmd.DisplayText, "Unexpected context command text"); }
public void StateManager_SetProjectsUIThread_With_BoundProjectKey() { // Arrange var section = ConfigurableSectionController.CreateDefault(); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host); host.VisualStateManager = testSubject; section.ViewModel.State = testSubject.ManagedState; host.SetActiveSection(section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new[] { new SonarQubeProject("project1", ""), new SonarQubeProject("project2", "") }; // Case 1 - projects does not contain BoundProjectKey testSubject.BoundProjectKey = "missing_project"; testSubject.SetProjects(connection1, projects); // Assert var message = notifications.AssertNotification(NotificationIds.FailedToFindBoundProjectKeyId); message.Should().MatchRegex("\\[.+\\]\\(\\)"); // Contains the hyperlink syntax [text]() notifications.AssertNotification(NotificationIds.FailedToFindBoundProjectKeyId, section.ReconnectCommand); // Case 2 - projects contains BoundProjectKey testSubject.BoundProjectKey = "project1"; testSubject.SetProjects(connection1, projects); // Assert notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); }
public void StateManager_IsBusyChanged() { // Arrange var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host); testSubject.IsBusyChanged += (s, isBusy) => section.ViewModel.IsBusy = isBusy; // Case 1: no active section -> no-op (i.e. no exception) testSubject.IsBusy = true; testSubject.ManagedState.IsBusy.Should().BeTrue(); testSubject.IsBusy = false; testSubject.ManagedState.IsBusy.Should().BeFalse(); // Case 2: has active section host.SetActiveSection(section); // Sanity (!IsBusy) section.ViewModel.IsBusy.Should().BeFalse(); // Act (IsBusy -> IsBusy) testSubject.IsBusy = true; // Assert section.ViewModel.IsBusy.Should().BeTrue(); testSubject.ManagedState.IsBusy.Should().BeTrue(); // Act (!IsBusy -> !IsBusy) testSubject.IsBusy = false; // Assert section.ViewModel.IsBusy.Should().BeFalse(); testSubject.ManagedState.IsBusy.Should().BeFalse(); // Dispose (should stop updated the view model) testSubject.Dispose(); testSubject.IsBusy = true; // Assert section.ViewModel.IsBusy.Should().BeFalse(); testSubject.ManagedState.IsBusy.Should().BeTrue(); }
public void StateManager_SetBoundProject() { // Arrange var section = ConfigurableSectionController.CreateDefault(); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ConfigurableHost host = new ConfigurableHost(); host.SetActiveSection(section); StateManager testSubject = this.CreateTestSubject(host); section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); var conn = new ConnectionInformation(new Uri("http://xyz")) { Organization = new SonarQubeOrganization("org1", "org1 name") }; var projects = new[] { new SonarQubeProject("111", ""), new SonarQubeProject("222", "") }; testSubject.SetProjects(conn, projects); TransferableVisualState state = testSubject.ManagedState; bool hasBoundProjectChanged = false; state.PropertyChanged += (o, e) => { e.PropertyName.Should().Be(nameof(state.HasBoundProject)); hasBoundProjectChanged = true; }; // Act testSubject.SetBoundProject(conn.ServerUri, "org1", "222"); // Assert notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); var serverVM = state.ConnectedServers.Single(); var project0VM = serverVM.Projects.Single(p => p.Project == projects[0]); var project1VM = serverVM.Projects.Single(p => p.Project == projects[1]); project1VM.IsBound.Should().BeTrue(); project0VM.IsBound.Should().BeFalse(); testSubject.ManagedState.HasBoundProject.Should().BeTrue("Expected a bound project"); hasBoundProjectChanged.Should().BeTrue("HasBoundProject expected to change"); }
public void StateManager_SetBoundProject() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ConfigurableHost host = new ConfigurableHost(); host.SetActiveSection(section); StateManager testSubject = this.CreateTestSubject(host); section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); var conn = new ConnectionInformation(new Uri("http://xyz")); var projects = new[] { new ProjectInformation(), new ProjectInformation() }; testSubject.SetProjects(conn, projects); TransferableVisualState state = testSubject.ManagedState; bool hasBoundProjectChanged = false; state.PropertyChanged += (o, e) => { Assert.AreEqual(nameof(state.HasBoundProject), e.PropertyName); hasBoundProjectChanged = true; }; // Act testSubject.SetBoundProject(projects[1]); // Verify notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); var serverVM = state.ConnectedServers.Single(); var project0VM = serverVM.Projects.Single(p => p.ProjectInformation == projects[0]); var project1VM = serverVM.Projects.Single(p => p.ProjectInformation == projects[1]); Assert.IsTrue(project1VM.IsBound, "Expected to be bound"); Assert.IsFalse(project0VM.IsBound, "Not expected to be bound"); Assert.IsTrue(testSubject.ManagedState.HasBoundProject, "Expected a bound project"); Assert.IsTrue(hasBoundProjectChanged, "HasBoundProject expected to change"); }
public void StateManager_SetProjectsUIThread() { // Arrange var section = ConfigurableSectionController.CreateDefault(); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host); host.VisualStateManager = testSubject; section.ViewModel.State = testSubject.ManagedState; var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var connection2 = new ConnectionInformation(new Uri("http://127.0.0.2")); var projects = new[] { new SonarQubeProject("", ""), new SonarQubeProject("", "") }; host.SetActiveSection(section); ServerViewModel serverVM; // Act + Assert // Case 1 - not connected to server (indicated by null) section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.SetProjects(connection1, null); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); VerifyConnectSectionViewModelIsNotConnected(section.ViewModel, connection1); VerifyConnectSectionViewModelIsNotConnected(section.ViewModel, connection2); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); // Case 2 - connection1, empty project collection section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.SetProjects(connection1, new SonarQubeProject[0]); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasNoProjects(section.ViewModel, connection1); serverVM.ShowAllProjects.Should().BeTrue("Expected show all projects"); VerifySectionCommands(section, serverVM); VerifyConnectSectionViewModelIsNotConnected(section.ViewModel, connection2); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); // Case 3 - connection1, non-empty project collection section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.SetProjects(connection1, projects); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection1, projects); VerifySectionCommands(section, serverVM); VerifyConnectSectionViewModelIsNotConnected(section.ViewModel, connection2); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); serverVM.ShowAllProjects.Should().BeTrue("Expected show all projects to be true when adding new SonarQubeProjects"); // Case 4 - connection2, change projects testSubject.SetProjects(connection1, projects); section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.SetProjects(connection2, projects); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection1, projects); VerifySectionCommands(section, serverVM); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection2, projects); VerifySectionCommands(section, serverVM); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); serverVM.ShowAllProjects.Should().BeTrue("Expected show all projects to be true when changing projects"); // Case 5 - connection1 & connection2, once detached (connected or not), are reset, changes still being tracked host.ClearActiveSection(); testSubject.SetProjects(connection1, projects); testSubject.SetProjects(connection2, projects); // Act section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); host.SetActiveSection(section); // Assert notifications.AssertNotification(NotificationIds.FailedToFindBoundProjectKeyId); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection1, projects); VerifySectionCommands(section, serverVM); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection2, projects); VerifySectionCommands(section, serverVM); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); }
public void StateManager_IsBusyChanged() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host); testSubject.IsBusyChanged += (s, isBusy) => section.ViewModel.IsBusy = isBusy; // Case 1: no active section -> no-op (i.e. no exception) testSubject.IsBusy = true; Assert.IsTrue(testSubject.ManagedState.IsBusy); testSubject.IsBusy = false; Assert.IsFalse(testSubject.ManagedState.IsBusy); // Case 2: has active section host.SetActiveSection(section); // Sanity (!IsBusy) Assert.IsFalse(section.ViewModel.IsBusy); // Act (IsBusy -> IsBusy) testSubject.IsBusy = true; // Verify Assert.IsTrue(section.ViewModel.IsBusy); Assert.IsTrue(testSubject.ManagedState.IsBusy); // Act (!IsBusy -> !IsBusy) testSubject.IsBusy = false; // Verify Assert.IsFalse(section.ViewModel.IsBusy); Assert.IsFalse(testSubject.ManagedState.IsBusy); // Dispose (should stop updated the view model) testSubject.Dispose(); testSubject.IsBusy = true; // Verify Assert.IsFalse(section.ViewModel.IsBusy); Assert.IsTrue(testSubject.ManagedState.IsBusy); }
public void StateManager_SetProjectsUIThread() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host); host.VisualStateManager = testSubject; section.ViewModel.State = testSubject.ManagedState; var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var connection2 = new ConnectionInformation(new Uri("http://127.0.0.2")); var projects = new[] { new ProjectInformation(), new ProjectInformation() }; host.SetActiveSection(section); ServerViewModel serverVM; // Act + Verify // Case 1 - not connected to server (indicated by null) section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.SetProjects(connection1, null); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); VerifyConnectSectionViewModelIsNotConnected(section.ViewModel, connection1); VerifyConnectSectionViewModelIsNotConnected(section.ViewModel, connection2); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); // Case 2 - connection1, empty project collection section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.SetProjects(connection1, new ProjectInformation[0]); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasNoProjects(section.ViewModel, connection1); Assert.IsTrue(serverVM.ShowAllProjects, "Expected show all projects"); VerifySectionCommands(section, serverVM); VerifyConnectSectionViewModelIsNotConnected(section.ViewModel, connection2); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); // Case 3 - connection1, non-empty project collection section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.SetProjects(connection1, projects); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection1, projects); VerifySectionCommands(section, serverVM); VerifyConnectSectionViewModelIsNotConnected(section.ViewModel, connection2); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); Assert.IsTrue(serverVM.ShowAllProjects, "Expected show all projects to be true when adding new projects"); // Case 4 - connection2, change projects testSubject.SetProjects(connection1, projects); section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.SetProjects(connection2, projects); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection1, projects); VerifySectionCommands(section, serverVM); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection2, projects); VerifySectionCommands(section, serverVM); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); Assert.IsTrue(serverVM.ShowAllProjects, "Expected show all projects to be true when changing projects"); // Case 5 - connection1 & connection2, once detached (connected or not), are reset, changes still being tracked host.ClearActiveSection(); testSubject.SetProjects(connection1, projects); testSubject.SetProjects(connection2, projects); // Act section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); host.SetActiveSection(section); // Verify notifications.AssertNotification(NotificationIds.FailedToFindBoundProjectKeyId); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection1, projects); VerifySectionCommands(section, serverVM); serverVM = VerifyConnectSectionViewModelIsConnectedAndHasProjects(section.ViewModel, connection2, projects); VerifySectionCommands(section, serverVM); VerifyConnectSectionViewModelHasNoBoundProjects(section.ViewModel); }
public void StateManager_SetBoundProject() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ConfigurableHost host = new ConfigurableHost(); host.SetActiveSection(section); StateManager testSubject = this.CreateTestSubject(host); section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); var conn = new ConnectionInformation(new Uri("http://xyz")); var projects = new[] { new ProjectInformation(), new ProjectInformation() }; testSubject.SetProjects(conn, projects); TransferableVisualState state = testSubject.ManagedState; bool hasBoundProjectChanged = false; state.PropertyChanged += (o, e) => { Assert.AreEqual(nameof(state.HasBoundProject), e.PropertyName); hasBoundProjectChanged = true; }; // Act testSubject.SetBoundProject(projects[1]); // Verify notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); var serverVM = state.ConnectedServers.Single(); var project0VM = serverVM.Projects.Single(p => p.ProjectInformation == projects[0]); var project1VM = serverVM.Projects.Single(p => p.ProjectInformation == projects[1]); Assert.IsTrue(project1VM.IsBound, "Expected to be bound"); Assert.IsFalse(project0VM.IsBound, "Not expected to be bound"); Assert.IsTrue(testSubject.ManagedState.HasBoundProject, "Expected a bound project"); Assert.IsTrue(hasBoundProjectChanged, "HasBoundProject expected to change"); }
public void StateManager_ClearBoundProject() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ConfigurableHost host = new ConfigurableHost(); host.SetActiveSection(section); StateManager testSubject = this.CreateTestSubject(host); section.UserNotifications.ShowNotificationError("message", NotificationIds.FailedToFindBoundProjectKeyId, null); testSubject.ManagedState.ConnectedServers.Add(new ServerViewModel(new ConnectionInformation(new Uri("http://zzz1")))); testSubject.ManagedState.ConnectedServers.Add(new ServerViewModel(new ConnectionInformation(new Uri("http://zzz2")))); testSubject.ManagedState.ConnectedServers.ToList().ForEach(s => s.Projects.Add(new ProjectViewModel(s, new ProjectInformation()))); var allProjects = testSubject.ManagedState.ConnectedServers.SelectMany(s => s.Projects).ToList(); testSubject.SetBoundProject(allProjects.First().ProjectInformation); // Sanity Assert.IsTrue(testSubject.ManagedState.HasBoundProject); // Act testSubject.ClearBoundProject(); // Verify Assert.IsFalse(testSubject.ManagedState.HasBoundProject); notifications.AssertNoNotification(NotificationIds.FailedToFindBoundProjectKeyId); }
public void StateManager_BindCommand_DynamicText() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host, section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new ProjectInformation[] { new ProjectInformation() }; testSubject.SetProjects(connection1, projects); ProjectViewModel projectVM = testSubject.ManagedState.ConnectedServers.Single().Projects.Single(); host.SetActiveSection(section); testSubject.SyncCommandFromActiveSection(); ContextualCommandViewModel bindCmd = projectVM.Commands.First(x => x.InternalRealCommand.Equals(section.BindCommand)); // Case 1: Bound projectVM.IsBound = true; // Act + Verify Assert.AreEqual(Strings.SyncButtonText, bindCmd.DisplayText, "Unexpected disabled context command text"); // Case 2: Not bound projectVM.IsBound = false; // Act + Verify Assert.AreEqual(Strings.BindButtonText, bindCmd.DisplayText, "Unexpected context command text"); }
public void StateManager_ToggleShowAllProjectsCommand_DynamicText() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host, section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new ProjectInformation[] { new ProjectInformation(), new ProjectInformation() }; testSubject.SetProjects(connection1, projects); ServerViewModel serverVM = testSubject.ManagedState.ConnectedServers.Single(); host.SetActiveSection(section); testSubject.SyncCommandFromActiveSection(); ContextualCommandViewModel toggleContextCmd = serverVM.Commands.First(x => x.InternalRealCommand.Equals(section.ToggleShowAllProjectsCommand)); // Case 1: No bound projects serverVM.ShowAllProjects = true; // Act + Verify Assert.AreEqual(Strings.HideUnboundProjectsCommandText, toggleContextCmd.DisplayText, "Unexpected disabled context command text"); // Case 2: has bound projects serverVM.ShowAllProjects = false; // Act + Verify Assert.AreEqual(Strings.ShowAllProjectsCommandText, toggleContextCmd.DisplayText, "Unexpected context command text"); }
public void StateManager_SyncCommandFromActiveSection() { // Setup var section = ConfigurableSectionController.CreateDefault(); ConfigurableHost host = new ConfigurableHost(); StateManager testSubject = this.CreateTestSubject(host, section); var connection1 = new ConnectionInformation(new Uri("http://127.0.0.1")); var projects = new ProjectInformation[] { new ProjectInformation(), new ProjectInformation() }; testSubject.SetProjects(connection1, projects); ServerViewModel serverVM = testSubject.ManagedState.ConnectedServers.Single(); // Case 1: has active section host.SetActiveSection(section); // Act testSubject.SyncCommandFromActiveSection(); VerifySectionCommands(section, serverVM); // Case 2: has no active section host.ClearActiveSection(); // Act testSubject.SyncCommandFromActiveSection(); VerifyNoCommands(serverVM); // Case 3: re-active host.SetActiveSection(section); // Act testSubject.SyncCommandFromActiveSection(); VerifySectionCommands(section, serverVM); }