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