public void TransferableVisualState_BoundProjectManagement()
        {
            // Arrange
            var testSubject = new TransferableVisualState();
            var server      = new ServerViewModel(new ConnectionInformation(new System.Uri("http://server")));
            var project1    = new ProjectViewModel(server, new SonarQubeProject("", ""));
            var project2    = new ProjectViewModel(server, new SonarQubeProject("", ""));

            // Act (bind to something)
            testSubject.SetBoundProject(project1);

            // Assert
            testSubject.HasBoundProject.Should().BeTrue();
            project1.IsBound.Should().BeTrue();
            project2.IsBound.Should().BeFalse();
            server.ShowAllProjects.Should().BeFalse();

            // Act (bind to something else)
            testSubject.SetBoundProject(project2);

            // Assert
            testSubject.HasBoundProject.Should().BeTrue();
            project1.IsBound.Should().BeFalse();
            project2.IsBound.Should().BeTrue();
            server.ShowAllProjects.Should().BeFalse();

            // Act(clear binding)
            testSubject.ClearBoundProject();

            // Assert
            testSubject.HasBoundProject.Should().BeFalse();
            project1.IsBound.Should().BeFalse();
            project2.IsBound.Should().BeFalse();
            server.ShowAllProjects.Should().BeTrue();
        }
コード例 #2
0
        public void TransferableVisualState_BoundProjectManagement()
        {
            // Setup
            var testSubject = new TransferableVisualState();
            var server      = new ServerViewModel(new Integration.Service.ConnectionInformation(new System.Uri("http://server")));
            var project1    = new ProjectViewModel(server, new Integration.Service.ProjectInformation());
            var project2    = new ProjectViewModel(server, new Integration.Service.ProjectInformation());

            // Act (bind to something)
            testSubject.SetBoundProject(project1);

            // Verify
            Assert.IsTrue(testSubject.HasBoundProject);
            Assert.IsTrue(project1.IsBound);
            Assert.IsFalse(project2.IsBound);
            Assert.IsFalse(server.ShowAllProjects);

            // Act (bind to something else)
            testSubject.SetBoundProject(project2);

            // Verify
            Assert.IsTrue(testSubject.HasBoundProject);
            Assert.IsFalse(project1.IsBound);
            Assert.IsTrue(project2.IsBound);
            Assert.IsFalse(server.ShowAllProjects);

            // Act(clear binding)
            testSubject.ClearBoundProject();

            // Verify
            Assert.IsFalse(testSubject.HasBoundProject);
            Assert.IsFalse(project1.IsBound);
            Assert.IsFalse(project2.IsBound);
            Assert.IsTrue(server.ShowAllProjects);
        }
        public void TransferableVisualState_DefaultState()
        {
            // Arrange
            var testSubject = new TransferableVisualState();

            // Assert
            testSubject.HasBoundProject.Should().BeFalse();
            testSubject.IsBusy.Should().BeFalse();
            testSubject.ConnectedServers.Should().NotBeNull();
            testSubject.ConnectedServers.Should().BeEmpty();
        }
コード例 #4
0
        public void TransferableVisualState_DefaultState()
        {
            // Setup
            var testSubject = new TransferableVisualState();

            // Verify
            Assert.IsFalse(testSubject.HasBoundProject);
            Assert.IsFalse(testSubject.IsBusy);
            Assert.IsNotNull(testSubject.ConnectedServers);
            Assert.AreEqual(0, testSubject.ConnectedServers.Count);
        }
コード例 #5
0
        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");
        }
コード例 #6
0
        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");
        }