Ejemplo n.º 1
0
        public void SectionController_BrowseToUrlCommand()
        {
            // Arrange
            var webBrowser  = new ConfigurableWebBrowser();
            var testSubject = this.CreateTestSubject(webBrowser);

            // Case 1: Empty URL
            // Act + Assert CanExecute
            testSubject.BrowseToUrlCommand.CanExecute(null).Should().BeFalse();

            // Case 2: Bad URL
            // Act + Assert CanExecute
            testSubject.BrowseToUrlCommand.CanExecute("not a Uri").Should().BeFalse();

            // Case 3: Good URL
            const string goodUrl = "http://localhost";

            // Act + Assert CanExecute
            testSubject.BrowseToUrlCommand.CanExecute(goodUrl).Should().BeTrue();

            // Act + Assert Execute
            testSubject.BrowseToUrlCommand.Execute(goodUrl);
            webBrowser.NavigatedUrls.Should().HaveCount(1);
            webBrowser.NavigatedUrls.Should().Contain(goodUrl);
        }
        public void SectionController_BrowseToProjectDashboardCommand()
        {
            // Arrange
            var webBrowser     = new ConfigurableWebBrowser();
            var testSubject    = this.CreateTestSubject(webBrowser);
            var serverUrl      = new Uri("http://my-sonar-server:5555");
            var connectionInfo = new ConnectionInformation(serverUrl);
            var projectInfo    = new ProjectInformation {
                Key = "p1"
            };

            Uri expectedUrl = new Uri(serverUrl, string.Format(SonarQubeServiceWrapper.ProjectDashboardRelativeUrl, projectInfo.Key));

            this.sonarQubeService.RegisterProjectDashboardUrl(connectionInfo, projectInfo, expectedUrl);

            // Case 1: Null parameter
            // Act + Assert CanExecute
            testSubject.BrowseToProjectDashboardCommand.CanExecute(null).Should().BeFalse();

            // Case 2: Project VM
            var serverViewModel  = new ServerViewModel(connectionInfo);
            var projectViewModel = new ProjectViewModel(serverViewModel, projectInfo);

            // Act + Assert CanExecute
            testSubject.BrowseToProjectDashboardCommand.CanExecute(projectViewModel).Should().BeTrue();

            // Act + Assert Execute
            testSubject.BrowseToProjectDashboardCommand.Execute(projectViewModel);
            webBrowser.NavigatedUrls.Should().HaveCount(1);
            webBrowser.NavigatedUrls.Should().Contain(expectedUrl.ToString());
        }
Ejemplo n.º 3
0
        public void SectionController_BrowseToProjectDashboardCommand()
        {
            // Setup
            var webBrowser     = new ConfigurableWebBrowser();
            var testSubject    = this.CreateTestSubject(webBrowser);
            var serverUrl      = new Uri("http://my-sonar-server:5555");
            var connectionInfo = new ConnectionInformation(serverUrl);
            var projectInfo    = new ProjectInformation {
                Key = "p1"
            };

            Uri expectedUrl = new Uri(serverUrl, string.Format(SonarQubeServiceWrapper.ProjectDashboardRelativeUrl, projectInfo.Key));

            this.sonarQubeService.RegisterProjectDashboardUrl(connectionInfo, projectInfo, expectedUrl);

            // Case 1: Null parameter
            // Act + Verify CanExecute
            Assert.IsFalse(testSubject.BrowseToProjectDashboardCommand.CanExecute(null));

            // Case 2: Project VM
            var serverViewModel  = new ServerViewModel(connectionInfo);
            var projectViewModel = new ProjectViewModel(serverViewModel, projectInfo);

            // Act + Verify CanExecute
            Assert.IsTrue(testSubject.BrowseToProjectDashboardCommand.CanExecute(projectViewModel));

            // Act + Verify Execute
            testSubject.BrowseToProjectDashboardCommand.Execute(projectViewModel);
            webBrowser.AssertNavigateToCalls(1);
            webBrowser.AssertRequestToNavigateTo(expectedUrl.ToString());
        }
Ejemplo n.º 4
0
        public void SectionController_BrowseToUrlCommand()
        {
            // Setup
            var webBrowser  = new ConfigurableWebBrowser();
            var testSubject = this.CreateTestSubject(webBrowser);

            // Case 1: Empty URL
            // Act + Verify CanExecute
            Assert.IsFalse(testSubject.BrowseToUrlCommand.CanExecute(null));

            // Case 2: Bad URL
            // Act + Verify CanExecute
            Assert.IsFalse(testSubject.BrowseToUrlCommand.CanExecute("not a Uri"));

            // Case 3: Good URL
            const string goodUrl = "http://localhost";

            // Act + Verify CanExecute
            Assert.IsTrue(testSubject.BrowseToUrlCommand.CanExecute(goodUrl));

            // Act + Verify Execute
            testSubject.BrowseToUrlCommand.Execute(goodUrl);
            webBrowser.AssertNavigateToCalls(1);
            webBrowser.AssertRequestToNavigateTo(goodUrl);
        }
Ejemplo n.º 5
0
        public void SectionController_BrowseToProjectDashboardCommand()
        {
            // Arrange
            var webBrowser     = new ConfigurableWebBrowser();
            var testSubject    = this.CreateTestSubject(webBrowser);
            var serverUrl      = new Uri("http://my-sonar-server:5555");
            var connectionInfo = new ConnectionInformation(serverUrl);
            var projectInfo    = new SonarQubeProject("p1", "");
            var expectedUrl    = new Uri(serverUrl, "/foobar");

            this.sonarQubeServiceMock.Setup(x => x.GetProjectDashboardUrl("p1"))
            .Returns(expectedUrl);

            // Case 1: Null parameter
            // Act + Assert CanExecute
            testSubject.BrowseToProjectDashboardCommand.CanExecute(null).Should().BeFalse();

            // Case 2: Project VM is set but SQ server is not connected
            var serverViewModel  = new ServerViewModel(connectionInfo);
            var projectViewModel = new ProjectViewModel(serverViewModel, projectInfo);

            this.sonarQubeServiceMock.Setup(x => x.IsConnected).Returns(false);

            // Act + Assert CanExecute
            testSubject.BrowseToProjectDashboardCommand.CanExecute(projectViewModel).Should().BeFalse();

            // Case 3: Project VM is set and SQ server is connected
            this.sonarQubeServiceMock.Setup(x => x.IsConnected).Returns(true);

            // Act + Assert CanExecute
            testSubject.BrowseToProjectDashboardCommand.CanExecute(projectViewModel).Should().BeTrue();

            // Act + Assert Execute
            testSubject.BrowseToProjectDashboardCommand.Execute(projectViewModel);
            webBrowser.NavigatedUrls.Should().HaveCount(1);
            webBrowser.NavigatedUrls.Should().Contain(expectedUrl.ToString());
        }
        public void SectionController_BrowseToProjectDashboardCommand()
        {
            // Setup
            var webBrowser = new ConfigurableWebBrowser();
            var testSubject = this.CreateTestSubject(webBrowser);
            var serverUrl = new Uri("http://my-sonar-server:5555");
            var connectionInfo = new ConnectionInformation(serverUrl);
            var projectInfo = new ProjectInformation { Key = "p1" };

            Uri expectedUrl = new Uri(serverUrl, string.Format(SonarQubeServiceWrapper.ProjectDashboardRelativeUrl, projectInfo.Key));
            this.sonarQubeService.RegisterProjectDashboardUrl(connectionInfo, projectInfo, expectedUrl);

            // Case 1: Null parameter
            // Act + Verify CanExecute
            Assert.IsFalse(testSubject.BrowseToProjectDashboardCommand.CanExecute(null));

            // Case 2: Project VM
            var serverViewModel = new ServerViewModel(connectionInfo);
            var projectViewModel = new ProjectViewModel(serverViewModel, projectInfo);

            // Act + Verify CanExecute
            Assert.IsTrue(testSubject.BrowseToProjectDashboardCommand.CanExecute(projectViewModel));

            // Act + Verify Execute
            testSubject.BrowseToProjectDashboardCommand.Execute(projectViewModel);
            webBrowser.AssertNavigateToCalls(1);
            webBrowser.AssertRequestToNavigateTo(expectedUrl.ToString());
        }
        public void SectionController_BrowseToUrlCommand()
        {
            // Setup
            var webBrowser = new ConfigurableWebBrowser();
            var testSubject = this.CreateTestSubject(webBrowser);

            // Case 1: Empty URL
            // Act + Verify CanExecute
            Assert.IsFalse(testSubject.BrowseToUrlCommand.CanExecute(null));

            // Case 2: Bad URL
            // Act + Verify CanExecute
            Assert.IsFalse(testSubject.BrowseToUrlCommand.CanExecute("not a Uri"));

            // Case 3: Good URL
            const string goodUrl = "http://localhost";

            // Act + Verify CanExecute
            Assert.IsTrue(testSubject.BrowseToUrlCommand.CanExecute(goodUrl));

            // Act + Verify Execute
            testSubject.BrowseToUrlCommand.Execute(goodUrl);
            webBrowser.AssertNavigateToCalls(1);
            webBrowser.AssertRequestToNavigateTo(goodUrl);
        }