From e6ddbfa35d1e0b212ba6cb8cbb49c41fa7f155c5 Mon Sep 17 00:00:00 2001 From: Marc-Andre Vezeau Date: Tue, 26 Jan 2016 17:29:12 -0500 Subject: [PATCH] Fix unit test for nunit 3.0.1 --- .../IntegrationTests/SampleAgentUsage.cs | 89 ++-- .../SampleBuildsConfigsUsage.cs | 205 +++++---- .../IntegrationTests/SampleBuildsUsage.cs | 390 +++++++++--------- .../IntegrationTests/SampleChangeUsage.cs | 101 +++-- .../IntegrationTests/SampleConnectionUsage.cs | 5 +- .../IntegrationTests/SampleCreateUser.cs | 52 +-- .../IntegrationTests/SampleProjectUsage.cs | 195 +++++---- .../IntegrationTests/SampleServerUsage.cs | 89 ++-- .../IntegrationTests/SampleStatisticsUsage.cs | 42 +- src/Tests/IntegrationTests/SampleUserUsage.cs | 219 +++++----- src/Tests/IntegrationTests/SampleVcsUsage.cs | 90 ++-- .../TeamCitySharp.IntegrationTests.csproj | 2 +- .../UnitTests/TeamCitySharp.UnitTests.csproj | 2 +- 13 files changed, 704 insertions(+), 777 deletions(-) diff --git a/src/Tests/IntegrationTests/SampleAgentUsage.cs b/src/Tests/IntegrationTests/SampleAgentUsage.cs index 0385a1ca..b2400d7a 100644 --- a/src/Tests/IntegrationTests/SampleAgentUsage.cs +++ b/src/Tests/IntegrationTests/SampleAgentUsage.cs @@ -7,64 +7,55 @@ namespace TeamCitySharp.IntegrationTests { - [TestFixture] - public class when_interacting_to_get_agent_details - { - private ITeamCityClient _client; - - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } - - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void it_throws_exception_when_no_host() - { - var client = new TeamCityClient(null); - - //Assert: Exception - } + [TestFixture] + public class when_interacting_to_get_agent_details + { + private ITeamCityClient _client; - [Test] - [ExpectedException(typeof(WebException))] - public void it_throws_exception_when_host_url_invalid() - { - var client = new TeamCityClient("teamcity:81"); - client.Connect("teamcitysharpuser", "qwerty"); + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } - var agents = client.Agents.All(); + [Test] + public void it_throws_exception_when_no_host() + { + Assert.Throws(() => new TeamCityClient(null)); + } - //Assert: Exception - } + [Test] + public void it_throws_exception_when_host_url_invalid() + { + var client = new TeamCityClient("teamcity:81"); + client.Connect("teamcitysharpuser", "qwerty"); - [Test] - [ExpectedException(typeof(ArgumentException))] - public void it_throws_exception_when_no_client_connection_made() - { - var client = new TeamCityClient("teamcity.codebetter.com"); + Assert.Throws(() => client.Agents.All()); + } - var agents = client.Agents.All(); + [Test] + public void it_throws_exception_when_no_client_connection_made() + { + var client = new TeamCityClient("teamcity.codebetter.com"); - //Assert: Exception - } + Assert.Throws(() => client.Agents.All()); + } - [Test] - public void it_returns_all_agents() - { - List agents = _client.Agents.All(); + [Test] + public void it_returns_all_agents() + { + List agents = _client.Agents.All(); - Assert.That(agents.Any(), "No agents were found"); - } + Assert.That(agents.Any(), "No agents were found"); + } - [TestCase("agent01")] - public void it_returns_last_build_status_for_agent(string agentName) - { - Build lastBuild = _client.Builds.LastBuildByAgent(agentName); + [TestCase("agent01")] + public void it_returns_last_build_status_for_agent(string agentName) + { + Build lastBuild = _client.Builds.LastBuildByAgent(agentName); - Assert.That(lastBuild != null, "No build information found for the last build on the specified agent"); - } + Assert.That(lastBuild != null, "No build information found for the last build on the specified agent"); } + } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleBuildsConfigsUsage.cs b/src/Tests/IntegrationTests/SampleBuildsConfigsUsage.cs index 6634e5cb..ac2fd972 100644 --- a/src/Tests/IntegrationTests/SampleBuildsConfigsUsage.cs +++ b/src/Tests/IntegrationTests/SampleBuildsConfigsUsage.cs @@ -6,112 +6,105 @@ namespace TeamCitySharp.IntegrationTests { - [TestFixture] - public class when_interations_to_get_build_configuration_details + [TestFixture] + public class when_interations_to_get_build_configuration_details + { + private ITeamCityClient _client; + + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } + + [Test] + public void it_throws_exception_when_no_url_passed() + { + Assert.Throws(() => new TeamCityClient(null)); + } + + [Test] + public void it_throws_exception_when_host_does_not_exist() + { + var client = new TeamCityClient("test:81"); + client.Connect("teamcitysharpuser", "qwerty"); + + Assert.Throws(() => client.BuildConfigs.All()); + } + + [Test] + public void it_throws_exception_when_no_connection_formed() + { + var client = new TeamCityClient("teamcity.codebetter.com"); + + Assert.Throws(() => client.BuildConfigs.All()); + + //Assert: Exception + } + + [Test] + public void it_returns_all_build_types() + { + var buildConfigs = _client.BuildConfigs.All(); + + Assert.That(buildConfigs.Any(), "No build types were found in this server"); + } + + [Test] + public void it_returns_build_config_details_by_configuration_id() { - private ITeamCityClient _client; - - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } - - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void it_throws_exception_when_no_url_passed() - { - var client = new TeamCityClient(null); - - //Assert: Exception - } - - [Test] - [ExpectedException(typeof(WebException))] - public void it_throws_exception_when_host_does_not_exist() - { - var client = new TeamCityClient("test:81"); - client.Connect("teamcitysharpuser", "qwerty"); - - var builds = client.BuildConfigs.All(); - - //Assert: Exception - } - - [Test] - [ExpectedException(typeof(ArgumentException))] - public void it_throws_exception_when_no_connection_formed() - { - var client = new TeamCityClient("teamcity.codebetter.com"); - - var builds = client.BuildConfigs.All(); - - //Assert: Exception - } - - [Test] - public void it_returns_all_build_types() - { - var buildConfigs = _client.BuildConfigs.All(); - - Assert.That(buildConfigs.Any(), "No build types were found in this server"); - } - - [Test] - public void it_returns_build_config_details_by_configuration_id() - { - string buildConfigId = "bt437"; - var buildConfig = _client.BuildConfigs.ByConfigurationId(buildConfigId); - - Assert.That(buildConfig != null, "Cannot find a build type for that buildId"); - } - - [Test] - public void it_pauses_configuration() - { - string buildConfigId = "bt437"; - var buildLocator = BuildTypeLocator.WithId(buildConfigId); - _client.BuildConfigs.SetConfigurationPauseStatus(buildLocator, true); - var status = _client.BuildConfigs.GetConfigurationPauseStatus(buildLocator); - Assert.That(status == true, "Build not paused"); - } - - [Test] - public void it_unpauses_configuration() - { - string buildConfigId = "bt437"; - var buildLocator = BuildTypeLocator.WithId(buildConfigId); - _client.BuildConfigs.SetConfigurationPauseStatus(buildLocator, false); - var status = _client.BuildConfigs.GetConfigurationPauseStatus(buildLocator); - Assert.That(status == false, "Build not unpaused"); - } - - [Test] - public void it_returns_build_config_details_by_configuration_name() - { - string buildConfigName = "Release Build"; - var buildConfig = _client.BuildConfigs.ByConfigurationName(buildConfigName); - - Assert.That(buildConfig != null, "Cannot find a build type for that buildName"); - } - - [Test] - public void it_returns_build_configs_by_project_id() - { - string projectId = "project137"; - var buildConfigs = _client.BuildConfigs.ByProjectId(projectId); - - Assert.That(buildConfigs.Any(), "Cannot find a build type for that projectId"); - } - - [Test] - public void it_returns_build_configs_by_project_name() - { - string projectName = "YouTrackSharp"; - var buildConfigs = _client.BuildConfigs.ByProjectName(projectName); - - Assert.That(buildConfigs.Any(), "Cannot find a build type for that projectName"); - } + string buildConfigId = "bt437"; + var buildConfig = _client.BuildConfigs.ByConfigurationId(buildConfigId); + + Assert.That(buildConfig != null, "Cannot find a build type for that buildId"); + } + + [Test] + public void it_pauses_configuration() + { + string buildConfigId = "bt437"; + var buildLocator = BuildTypeLocator.WithId(buildConfigId); + _client.BuildConfigs.SetConfigurationPauseStatus(buildLocator, true); + var status = _client.BuildConfigs.GetConfigurationPauseStatus(buildLocator); + Assert.That(status == true, "Build not paused"); + } + + [Test] + public void it_unpauses_configuration() + { + string buildConfigId = "bt437"; + var buildLocator = BuildTypeLocator.WithId(buildConfigId); + _client.BuildConfigs.SetConfigurationPauseStatus(buildLocator, false); + var status = _client.BuildConfigs.GetConfigurationPauseStatus(buildLocator); + Assert.That(status == false, "Build not unpaused"); + } + + [Test] + public void it_returns_build_config_details_by_configuration_name() + { + string buildConfigName = "Release Build"; + var buildConfig = _client.BuildConfigs.ByConfigurationName(buildConfigName); + + Assert.That(buildConfig != null, "Cannot find a build type for that buildName"); + } + + [Test] + public void it_returns_build_configs_by_project_id() + { + string projectId = "project137"; + var buildConfigs = _client.BuildConfigs.ByProjectId(projectId); + + Assert.That(buildConfigs.Any(), "Cannot find a build type for that projectId"); + } + + [Test] + public void it_returns_build_configs_by_project_name() + { + string projectName = "YouTrackSharp"; + var buildConfigs = _client.BuildConfigs.ByProjectName(projectName); + + Assert.That(buildConfigs.Any(), "Cannot find a build type for that projectName"); } + } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleBuildsUsage.cs b/src/Tests/IntegrationTests/SampleBuildsUsage.cs index daa77e2e..0d1b6de0 100644 --- a/src/Tests/IntegrationTests/SampleBuildsUsage.cs +++ b/src/Tests/IntegrationTests/SampleBuildsUsage.cs @@ -7,202 +7,194 @@ namespace TeamCitySharp.IntegrationTests { - [TestFixture] - public class when_interacting_to_get_build_status_info - { - private ITeamCityClient _client; - - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } - - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void it_throws_exception_when_no_url_passed() - { - new TeamCityClient(null); - - //Assert: Exception - } - - [Test] - [ExpectedException(typeof(WebException))] - public void it_throws_exception_when_host_does_not_exist() - { - var client = new TeamCityClient("test:81"); - client.Connect("admin", "qwerty"); - - const string buildConfigId = "Release Build"; - client.Builds.SuccessfulBuildsByBuildConfigId(buildConfigId); - - //Assert: Exception - } - - [Test] - [ExpectedException(typeof(ArgumentException))] - public void it_throws_exception_when_no_connection_formed() - { - var client = new TeamCityClient("teamcity.codebetter.com"); - - const string buildConfigId = "Release Build"; - client.Builds.SuccessfulBuildsByBuildConfigId(buildConfigId); - - //Assert: Exception - } - - [Test] - public void it_returns_last_successful_build_by_build_config_id() - { - const string buildConfigId = "bt437"; - var build = _client.Builds.LastSuccessfulBuildByBuildConfigId(buildConfigId); - - Assert.That(build != null, "No successful builds have been found"); - } - - [Test] - public void it_returns_last_successful_builds_by_build_config_id() - { - const string buildConfigId = "bt437"; - var buildDetails = _client.Builds.SuccessfulBuildsByBuildConfigId(buildConfigId); - - Assert.That(buildDetails.Any(), "No successful builds have been found"); - } - - [Test] - public void it_returns_last_failed_build_by_build_config_id() - { - const string buildConfigId = "bt437"; - var buildDetails = _client.Builds.LastFailedBuildByBuildConfigId(buildConfigId); - - Assert.That(buildDetails != null, "No failed builds have been found"); - } - - [Test] - public void it_returns_all_non_successful_builds_by_config_id() - { - const string buildConfigId = "bt437"; - var builds = _client.Builds.FailedBuildsByBuildConfigId(buildConfigId); - - Assert.That(builds.Any(), "No failed builds have been found"); - } - - [Test] - public void it_returns_last_error_build_by_config_id() - { - const string buildConfigId = "bt437"; - var buildDetails = _client.Builds.LastErrorBuildByBuildConfigId(buildConfigId); - - Assert.That(buildDetails != null, "No errored builds have been found"); - } - - [Test] - public void it_returns_all_error_builds_by_config_id() - { - const string buildId = "bt437"; - var builds = _client.Builds.ErrorBuildsByBuildConfigId(buildId); - - Assert.That(builds.Any(), "No errored builds have been found"); - } - - [Test] - public void it_returns_the_last_build_status_by_build_config_id() - { - const string buildConfigId = "bt437"; - var build = _client.Builds.LastBuildByBuildConfigId(buildConfigId); - - Assert.That(build != null, "No builds for this build config have been found"); - } - - [Test] - public void it_returns_all_builds_by_build_config_id() - { - const string buildConfigId = "bt437"; - var builds = _client.Builds.ByBuildConfigId(buildConfigId); - - Assert.That(builds.Any(), "No builds for this build configuration have been found"); - } - - [Test] - public void it_returns_all_builds_by_build_config_id_and_tag() - { - const string buildConfigId = "bt437"; - const string tag = "Release"; - var builds = _client.Builds.ByConfigIdAndTag(buildConfigId, tag); - - Assert.IsNotNull(builds, "No builds were found for this build id and Tag"); - } - - [Test] - public void it_returns_all_builds_by_username() - { - const string userName = "teamcitysharpuser"; - var builds = _client.Builds.ByUserName(userName); - - Assert.IsNotNull(builds, "No builds for this user have been found"); - } - - [Test] - public void it_returns_all_non_successful_builds_by_username() - { - const string userName = "teamcitysharpuser"; - var builds = _client.Builds.NonSuccessfulBuildsForUser(userName); - - Assert.IsNotNull(builds, "No non successful builds found for this user"); - } - - [Test] - public void it_returns_all_non_successful_build_count_by_username() - { - const string userName = "teamcitysharpuser"; - var builds = _client.Builds.NonSuccessfulBuildsForUser(userName); - - Assert.IsNotNull(builds, "No non successful builds found for this user"); - } - - [Test] - public void it_returns_all_running_builds() - { - var builds = _client.Builds.ByBuildLocator(BuildLocator.RunningBuilds()); - - Assert.IsNotNull(builds, "There are currently no running builds"); - } - - [Test] - public void it_returns_all_successful_builds_since_date() - { - var builds = _client.Builds.AllBuildsOfStatusSinceDate(DateTime.Now.AddDays(-2), BuildStatus.FAILURE); - - Assert.IsNotNull(builds); - } - - [Test] - public void it_does_not_populate_the_status_text_field_of_the_build_object() - { - const string buildConfigId = "bt5"; - var client = new TeamCityClient("localhost:81"); - client.Connect("admin", "qwerty"); - - var build = - client.Builds.ByBuildLocator(BuildLocator.WithDimensions(BuildTypeLocator.WithId(buildConfigId), - maxResults: 1)); - Assert.That(build.Count == 1); - Assert.IsNull(build[0].StatusText); - } - - [Test] - public void ig_returns_correct_build_when_calling_by_id() - { - const string buildId = "5726"; - var client = new TeamCityClient("localhost:81"); - client.Connect("admin", "qwerty"); - - var build = client.Builds.ById(buildId); - - Assert.That(build != null); - Assert.That(build.Id == buildId); - } - } -} + [TestFixture] + public class when_interacting_to_get_build_status_info + { + private ITeamCityClient _client; + + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } + + [Test] + public void it_throws_exception_when_no_url_passed() + { + Assert.Throws(() => new TeamCityClient(null)); + } + + [Test] + public void it_throws_exception_when_host_does_not_exist() + { + var client = new TeamCityClient("test:81"); + client.Connect("admin", "qwerty"); + + const string buildConfigId = "Release Build"; + Assert.Throws(() => client.Builds.SuccessfulBuildsByBuildConfigId(buildConfigId)); + + } + + [Test] + public void it_throws_exception_when_no_connection_formed() + { + var client = new TeamCityClient("teamcity.codebetter.com"); + + const string buildConfigId = "Release Build"; + Assert.Throws(() => client.Builds.SuccessfulBuildsByBuildConfigId(buildConfigId)); + } + + [Test] + public void it_returns_last_successful_build_by_build_config_id() + { + const string buildConfigId = "bt437"; + var build = _client.Builds.LastSuccessfulBuildByBuildConfigId(buildConfigId); + + Assert.That(build != null, "No successful builds have been found"); + } + + [Test] + public void it_returns_last_successful_builds_by_build_config_id() + { + const string buildConfigId = "bt437"; + var buildDetails = _client.Builds.SuccessfulBuildsByBuildConfigId(buildConfigId); + + Assert.That(buildDetails.Any(), "No successful builds have been found"); + } + + [Test] + public void it_returns_last_failed_build_by_build_config_id() + { + const string buildConfigId = "bt437"; + var buildDetails = _client.Builds.LastFailedBuildByBuildConfigId(buildConfigId); + + Assert.That(buildDetails != null, "No failed builds have been found"); + } + + [Test] + public void it_returns_all_non_successful_builds_by_config_id() + { + const string buildConfigId = "bt437"; + var builds = _client.Builds.FailedBuildsByBuildConfigId(buildConfigId); + + Assert.That(builds.Any(), "No failed builds have been found"); + } + + [Test] + public void it_returns_last_error_build_by_config_id() + { + const string buildConfigId = "bt437"; + var buildDetails = _client.Builds.LastErrorBuildByBuildConfigId(buildConfigId); + + Assert.That(buildDetails != null, "No errored builds have been found"); + } + + [Test] + public void it_returns_all_error_builds_by_config_id() + { + const string buildId = "bt437"; + var builds = _client.Builds.ErrorBuildsByBuildConfigId(buildId); + + Assert.That(builds.Any(), "No errored builds have been found"); + } + + [Test] + public void it_returns_the_last_build_status_by_build_config_id() + { + const string buildConfigId = "bt437"; + var build = _client.Builds.LastBuildByBuildConfigId(buildConfigId); + + Assert.That(build != null, "No builds for this build config have been found"); + } + + [Test] + public void it_returns_all_builds_by_build_config_id() + { + const string buildConfigId = "bt437"; + var builds = _client.Builds.ByBuildConfigId(buildConfigId); + + Assert.That(builds.Any(), "No builds for this build configuration have been found"); + } + + [Test] + public void it_returns_all_builds_by_build_config_id_and_tag() + { + const string buildConfigId = "bt437"; + const string tag = "Release"; + var builds = _client.Builds.ByConfigIdAndTag(buildConfigId, tag); + + Assert.IsNotNull(builds, "No builds were found for this build id and Tag"); + } + + [Test] + public void it_returns_all_builds_by_username() + { + const string userName = "teamcitysharpuser"; + var builds = _client.Builds.ByUserName(userName); + + Assert.IsNotNull(builds, "No builds for this user have been found"); + } + + [Test] + public void it_returns_all_non_successful_builds_by_username() + { + const string userName = "teamcitysharpuser"; + var builds = _client.Builds.NonSuccessfulBuildsForUser(userName); + + Assert.IsNotNull(builds, "No non successful builds found for this user"); + } + + [Test] + public void it_returns_all_non_successful_build_count_by_username() + { + const string userName = "teamcitysharpuser"; + var builds = _client.Builds.NonSuccessfulBuildsForUser(userName); + + Assert.IsNotNull(builds, "No non successful builds found for this user"); + } + + [Test] + public void it_returns_all_running_builds() + { + var builds = _client.Builds.ByBuildLocator(BuildLocator.RunningBuilds()); + + Assert.IsNotNull(builds, "There are currently no running builds"); + } + + [Test] + public void it_returns_all_successful_builds_since_date() + { + var builds = _client.Builds.AllBuildsOfStatusSinceDate(DateTime.Now.AddDays(-2), BuildStatus.FAILURE); + + Assert.IsNotNull(builds); + } + + [Test] + public void it_does_not_populate_the_status_text_field_of_the_build_object() + { + const string buildConfigId = "bt5"; + var client = new TeamCityClient("localhost:81"); + client.Connect("admin", "qwerty"); + + var build = + client.Builds.ByBuildLocator(BuildLocator.WithDimensions(BuildTypeLocator.WithId(buildConfigId), + maxResults: 1)); + Assert.That(build.Count == 1); + Assert.IsNull(build[0].StatusText); + } + + [Test] + public void ig_returns_correct_build_when_calling_by_id() + { + const string buildId = "5726"; + var client = new TeamCityClient("localhost:81"); + client.Connect("admin", "qwerty"); + + var build = client.Builds.ById(buildId); + + Assert.That(build != null); + Assert.That(build.Id == buildId); + } + } +} \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleChangeUsage.cs b/src/Tests/IntegrationTests/SampleChangeUsage.cs index fa8eca06..618fa179 100644 --- a/src/Tests/IntegrationTests/SampleChangeUsage.cs +++ b/src/Tests/IntegrationTests/SampleChangeUsage.cs @@ -7,72 +7,65 @@ namespace TeamCitySharp.IntegrationTests { - [TestFixture] - public class when_interacting_to_get_change_information - { - private ITeamCityClient _client; - - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } + [TestFixture] + public class when_interacting_to_get_change_information + { + private ITeamCityClient _client; - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void it_returns_exception_when_no_host_specified() - { - var client = new TeamCityClient(null); - - //Assert: Exception - } + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } - [Test] - [ExpectedException(typeof(WebException))] - public void it_returns_exception_when_host_does_not_exist() - { - var client = new TeamCityClient("test:81"); - client.Connect("admin", "qwerty"); + [Test] + public void it_returns_exception_when_no_host_specified() + { + Assert.Throws(() => new TeamCityClient(null)); + } - var changes = client.Changes.All(); + [Test] + public void it_returns_exception_when_host_does_not_exist() + { + var client = new TeamCityClient("test:81"); + client.Connect("admin", "qwerty"); - //Assert: Exception - } + Assert.Throws(() => client.Changes.All()); - [Test] - [ExpectedException(typeof(ArgumentException))] - public void it_returns_exception_when_no_connection_made() - { - var client = new TeamCityClient("teamcity.codebetter.com"); + } - var changes = client.Changes.All(); + [Test] + public void it_returns_exception_when_no_connection_made() + { + var client = new TeamCityClient("teamcity.codebetter.com"); - //Assert: Exception - } + var changes = client.Changes.All(); + Assert.Throws(() => client.Changes.All()); + } - [Test] - public void it_returns_all_changes() - { - List changes = _client.Changes.All(); + [Test] + public void it_returns_all_changes() + { + List changes = _client.Changes.All(); - Assert.That(changes.Any(), "Cannot find any changes recorded in any of the projects"); - } + Assert.That(changes.Any(), "Cannot find any changes recorded in any of the projects"); + } - [TestCase("42843")] - public void it_returns_change_details_by_change_id(string changeId) - { - Change changeDetails = _client.Changes.ByChangeId(changeId); + [TestCase("42843")] + public void it_returns_change_details_by_change_id(string changeId) + { + Change changeDetails = _client.Changes.ByChangeId(changeId); - Assert.That(changeDetails != null, "Cannot find details of that specified change"); - } + Assert.That(changeDetails != null, "Cannot find details of that specified change"); + } - [TestCase("bt113")] - public void it_returns_change_details_for_build_config(string buildConfigId) - { - Change changeDetails = _client.Changes.LastChangeDetailByBuildConfigId(buildConfigId); + [TestCase("bt113")] + public void it_returns_change_details_for_build_config(string buildConfigId) + { + Change changeDetails = _client.Changes.LastChangeDetailByBuildConfigId(buildConfigId); - Assert.That(changeDetails != null, "Cannot find details of that specified change"); - } + Assert.That(changeDetails != null, "Cannot find details of that specified change"); } + } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleConnectionUsage.cs b/src/Tests/IntegrationTests/SampleConnectionUsage.cs index 3c9c2ee1..8484b882 100644 --- a/src/Tests/IntegrationTests/SampleConnectionUsage.cs +++ b/src/Tests/IntegrationTests/SampleConnectionUsage.cs @@ -24,13 +24,10 @@ public void it_will_authenticate_a_known_user() } [Test] - [ExpectedException(typeof (AuthenticationException))] public void it_will_throw_an_exception_for_an_unknown_user() { _client.Connect("smithy", "smithy"); - _client.Authenticate(); - - //Assert.Throws Exception + Assert.Throws(() => _client.Authenticate()); } [Test] diff --git a/src/Tests/IntegrationTests/SampleCreateUser.cs b/src/Tests/IntegrationTests/SampleCreateUser.cs index 52d830bd..67c520cc 100644 --- a/src/Tests/IntegrationTests/SampleCreateUser.cs +++ b/src/Tests/IntegrationTests/SampleCreateUser.cs @@ -7,36 +7,36 @@ namespace TeamCitySharp.IntegrationTests { - [TestFixture] - [Ignore] - public class when_team_city_client_is_asked_to_create_a_new_user_with_a_password + [TestFixture] + [Ignore("ignore")] + public class when_team_city_client_is_asked_to_create_a_new_user_with_a_password + { + private ITeamCityClient _client; + + [SetUp] + public void SetUp() { - private ITeamCityClient _client; + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } + [Test] + public void it_will_add_a_new_user_and_new_user_will_be_able_to_log_in() + { + string userName = "John.Doe"; + string name = "John Doe"; + string email = "John.Doe@test.com"; + string password = "J0hnD03"; - [Test] - public void it_will_add_a_new_user_and_new_user_will_be_able_to_log_in() - { - string userName = "John.Doe"; - string name = "John Doe"; - string email = "John.Doe@test.com"; - string password = "J0hnD03"; - - var createUserResult = _client.Users.Create(userName, name, email, password); + var createUserResult = _client.Users.Create(userName, name, email, password); - ITeamCityClient _newUser; - _newUser = new TeamCityClient("teamcity.codebetter.com"); - _newUser.Connect(userName, password); + ITeamCityClient _newUser; + _newUser = new TeamCityClient("teamcity.codebetter.com"); + _newUser.Connect(userName, password); - var loginResponse = _newUser.Authenticate(); + var loginResponse = _newUser.Authenticate(); - Assert.That(createUserResult && loginResponse); - } + Assert.That(createUserResult && loginResponse); } -} + } +} \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleProjectUsage.cs b/src/Tests/IntegrationTests/SampleProjectUsage.cs index 5bcd7bd4..2e4310cd 100644 --- a/src/Tests/IntegrationTests/SampleProjectUsage.cs +++ b/src/Tests/IntegrationTests/SampleProjectUsage.cs @@ -1,101 +1,94 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using NUnit.Framework; -using TeamCitySharp.DomainEntities; - -namespace TeamCitySharp.IntegrationTests -{ - [TestFixture] - public class when_interacting_to_get_project_details - { - private ITeamCityClient _client; - - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } - - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void it_throws_exception_when_not_passing_url() - { - var client = new TeamCityClient(null); - - //Assert: Exception - } - - [Test] - [ExpectedException(typeof(WebException))] - public void it_throws_exception_when_host_does_not_exist() - { - var client = new TeamCityClient("test:81"); - client.Connect("admin", "qwerty"); - - var allProjects = client.Projects.All(); - - //Assert: Exception - } - - - [Test] - [ExpectedException(typeof(ArgumentException))] - public void it_throws_exception_when_no_connection_formed() - { - var client = new TeamCityClient("teamcity.codebetter.com"); - - var projects = client.Projects.All(); - - //Assert: Exception - } - - [Test] - public void it_returns_all_projects() - { - List projects = _client.Projects.All(); - - Assert.That(projects.Any(), "No projects were found for this server"); - } - - [TestCase("project137")] - public void it_returns_project_details_when_passing_a_project_id(string projectId) - { - Project projectDetails = _client.Projects.ById(projectId); - - Assert.That(projectDetails != null, "No details found for that specific project"); - } - - [TestCase("YouTrackSharp")] - public void it_returns_project_details_when_passing_a_project_name(string projectName) - { - Project projectDetails = _client.Projects.ByName(projectName); - - Assert.That(projectDetails != null, "No details found for that specific project"); - } - - [Test] - public void it_returns_project_details_when_passing_project() - { - var project = new Project { Id = "project137" }; - Project projectDetails = _client.Projects.Details(project); - - Assert.That(!string.IsNullOrWhiteSpace(projectDetails.Id)); - } - - - [Test] - public void it_returns_project_details_when_creating_project() - { - var client = new TeamCityClient("localhost:81"); - client.Connect("admin", "qwerty"); - var projectName = Guid.NewGuid().ToString("N"); - var project = client.Projects.Create(projectName); - - Assert.That(project, Is.Not.Null); - Assert.That(project.Name, Is.EqualTo(projectName)); - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using NUnit.Framework; +using TeamCitySharp.DomainEntities; + +namespace TeamCitySharp.IntegrationTests +{ + [TestFixture] + public class when_interacting_to_get_project_details + { + private ITeamCityClient _client; + + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } + + [Test] + public void it_throws_exception_when_not_passing_url() + { + Assert.Throws(() => new TeamCityClient(null)); + } + + [Test] + public void it_throws_exception_when_host_does_not_exist() + { + var client = new TeamCityClient("test:81"); + client.Connect("admin", "qwerty"); + + Assert.Throws(() => client.Projects.All()); + } + + + [Test] + public void it_throws_exception_when_no_connection_formed() + { + var client = new TeamCityClient("teamcity.codebetter.com"); + + Assert.Throws(() => client.Projects.All()); + + //Assert: Exception + } + + [Test] + public void it_returns_all_projects() + { + List projects = _client.Projects.All(); + + Assert.That(projects.Any(), "No projects were found for this server"); + } + + [TestCase("project137")] + public void it_returns_project_details_when_passing_a_project_id(string projectId) + { + Project projectDetails = _client.Projects.ById(projectId); + + Assert.That(projectDetails != null, "No details found for that specific project"); + } + + [TestCase("YouTrackSharp")] + public void it_returns_project_details_when_passing_a_project_name(string projectName) + { + Project projectDetails = _client.Projects.ByName(projectName); + + Assert.That(projectDetails != null, "No details found for that specific project"); + } + + [Test] + public void it_returns_project_details_when_passing_project() + { + var project = new Project {Id = "project137"}; + Project projectDetails = _client.Projects.Details(project); + + Assert.That(!string.IsNullOrWhiteSpace(projectDetails.Id)); + } + + + [Test] + public void it_returns_project_details_when_creating_project() + { + var client = new TeamCityClient("localhost:81"); + client.Connect("admin", "qwerty"); + var projectName = Guid.NewGuid().ToString("N"); + var project = client.Projects.Create(projectName); + + Assert.That(project, Is.Not.Null); + Assert.That(project.Name, Is.EqualTo(projectName)); + } + } +} \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleServerUsage.cs b/src/Tests/IntegrationTests/SampleServerUsage.cs index a89ad7f8..567fafc7 100644 --- a/src/Tests/IntegrationTests/SampleServerUsage.cs +++ b/src/Tests/IntegrationTests/SampleServerUsage.cs @@ -7,64 +7,57 @@ namespace TeamCitySharp.IntegrationTests { - [TestFixture] - public class when_interacting_to_get_server_info - { - private ITeamCityClient _client; - - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("localhost:81"); - _client.Connect("admin", "qwerty"); - } - - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void it_throws_exception_when_no_url_passed() - { - var client = new TeamCityClient(null); + [TestFixture] + public class when_interacting_to_get_server_info + { + private ITeamCityClient _client; - //Assert: Exception - } + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("localhost:81"); + _client.Connect("admin", "qwerty"); + } - [Test] - [ExpectedException(typeof(WebException))] - public void it_throws_exception_when_host_does_not_exist() - { - var client = new TeamCityClient("test:81"); - client.Connect("admin", "qwerty"); + [Test] + public void it_throws_exception_when_no_url_passed() + { + Assert.Throws(() => new TeamCityClient(null)); + } - var plugins = client.ServerInformation.AllPlugins(); + [Test] + public void it_throws_exception_when_host_does_not_exist() + { + var client = new TeamCityClient("test:81"); + client.Connect("admin", "qwerty"); - //Assert: Exception - } + Assert.Throws(() => client.ServerInformation.AllPlugins()); + } - [Test] - [ExpectedException(typeof(ArgumentException))] - public void it_throws_exception_when_no_connection_formed() - { - var client = new TeamCityClient("teamcity.codebetter.com"); + [Test] + public void it_throws_exception_when_no_connection_formed() + { + var client = new TeamCityClient("teamcity.codebetter.com"); - var plugins = client.ServerInformation.AllPlugins(); + Assert.Throws(() => client.ServerInformation.AllPlugins()); - //Assert: Exception - } + //Assert: Exception + } - [Test] - public void it_returns_server_info() - { - Server serverInfo = _client.ServerInformation.ServerInfo(); + [Test] + public void it_returns_server_info() + { + Server serverInfo = _client.ServerInformation.ServerInfo(); - Assert.That(serverInfo != null, "The server is not returning any information"); - } + Assert.That(serverInfo != null, "The server is not returning any information"); + } - [Test] - public void it_returns_all_server_plugins() - { - List plugins = _client.ServerInformation.AllPlugins(); + [Test] + public void it_returns_all_server_plugins() + { + List plugins = _client.ServerInformation.AllPlugins(); - Assert.IsNotNull(plugins, "Server is not returning a plugin list"); - } + Assert.IsNotNull(plugins, "Server is not returning a plugin list"); } + } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleStatisticsUsage.cs b/src/Tests/IntegrationTests/SampleStatisticsUsage.cs index 60d8428d..324cd77e 100644 --- a/src/Tests/IntegrationTests/SampleStatisticsUsage.cs +++ b/src/Tests/IntegrationTests/SampleStatisticsUsage.cs @@ -1,32 +1,28 @@ -using System; -using System.Net; using NUnit.Framework; -using System.Collections.Generic; using System.Linq; -using TeamCitySharp.DomainEntities; namespace TeamCitySharp.IntegrationTests { - [TestFixture] - public class when_interacting_to_get_build_statistics - { - private ITeamCityClient _client; + [TestFixture] + public class when_interacting_to_get_build_statistics + { + private ITeamCityClient _client; - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } - [Test] - public void it_returns_no_of_tests_from_last_successful_build() - { - var proj = _client.Projects.ById("AutoFixture"); - var build = _client.Builds.LastSuccessfulBuildByBuildConfigId(proj.BuildTypes.BuildType[0].Id); - var stats = _client.Statistics.GetByBuildId(build.Id); + [Test] + public void it_returns_no_of_tests_from_last_successful_build() + { + var proj = _client.Projects.ById("AutoFixture"); + var build = _client.Builds.LastSuccessfulBuildByBuildConfigId(proj.BuildTypes.BuildType[0].Id); + var stats = _client.Statistics.GetByBuildId(build.Id); - Assert.That(stats.Any(property => property.Name.Equals("PassedTestCount"))); - } - } + Assert.That(stats.Any(property => property.Name.Equals("PassedTestCount"))); + } + } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleUserUsage.cs b/src/Tests/IntegrationTests/SampleUserUsage.cs index 6c081713..ff718122 100644 --- a/src/Tests/IntegrationTests/SampleUserUsage.cs +++ b/src/Tests/IntegrationTests/SampleUserUsage.cs @@ -7,121 +7,110 @@ namespace TeamCitySharp.IntegrationTests { - [TestFixture] - public class when_interacting_to_get_user_information + [TestFixture] + public class when_interacting_to_get_user_information + { + private ITeamCityClient _client; + + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } + + [Test] + public void it_returns_exception_when_no_host_specified() + { + Assert.Throws(() => new TeamCityClient(null)); + } + + [Test] + public void it_returns_exception_when_host_does_not_exist() + { + var client = new TeamCityClient("test:81"); + client.Connect("admin", "qwerty"); + + Assert.Throws(() => client.Users.All()); + } + + [Test] + public void it_returns_exception_when_no_connection_made() + { + var client = new TeamCityClient("teamcity.codebetter.com"); + + Assert.Throws(() => client.Users.All()); + } + + [Test] + public void it_returns_all_user_groups() + { + List groups = _client.Users.AllUserGroups(); + + Assert.That(groups.Any(), "No user groups were found"); + } + + [Test] + public void it_returns_all_users_by_user_group_name() + { + string userGroupName = "ALL_USERS_GROUP"; + List users = _client.Users.AllUsersByUserGroup(userGroupName); + + Assert.That(users.Any(), "No users were found for this group"); + } + + [Test] + public void it_returns_all_roles_by_user_group_name() { - private ITeamCityClient _client; - - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } - - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void it_returns_exception_when_no_host_specified() - { - var client = new TeamCityClient(null); - - //Assert: Exception - } - - [Test] - [ExpectedException(typeof(WebException))] - public void it_returns_exception_when_host_does_not_exist() - { - var client = new TeamCityClient("test:81"); - client.Connect("admin", "qwerty"); - - var users = client.Users.All(); - - //Assert: Exception - } - - [Test] - [ExpectedException(typeof(ArgumentException))] - public void it_returns_exception_when_no_connection_made() - { - var client = new TeamCityClient("teamcity.codebetter.com"); - - var users = client.Users.All(); - - //Assert: Exception - } - - [Test] - public void it_returns_all_user_groups() - { - List groups = _client.Users.AllUserGroups(); - - Assert.That(groups.Any(), "No user groups were found"); - } - - [Test] - public void it_returns_all_users_by_user_group_name() - { - string userGroupName = "ALL_USERS_GROUP"; - List users = _client.Users.AllUsersByUserGroup(userGroupName); - - Assert.That(users.Any(), "No users were found for this group"); - } - - [Test] - public void it_returns_all_roles_by_user_group_name() - { - string userGroupName = "ALL_USERS_GROUP"; - List roles = _client.Users.AllUserRolesByUserGroup(userGroupName); - - Assert.That(roles.Any(), "No roles were found for that userGroup"); - } - - [Test] - public void it_returns_all_users() - { - List users = _client.Users.All(); - - Assert.That(users.Any(), "No users found for this server"); - } - - [Test] - public void it_returns_all_user_roles_by_user_name() - { - string userName = "teamcitysharpuser"; - List roles = _client.Users.AllRolesByUserName(userName); - - Assert.That(roles.Any(), "No roles found for this user"); - } - - [Test] - public void it_returns_all_user_groups_by_user_group_name() - { - string userName = "teamcitysharpuser"; - List groups = _client.Users.AllGroupsByUserName(userName); - - Assert.That(groups.Any(), "This user is not a member of any groups"); - } - - [Test] - public void it_returns_user_details_by_user() - { - string userName = "teamcitysharpuser"; - User details = _client.Users.Details(userName); - - Assert.That(details.Email.ToLowerInvariant().Equals("teamcitysharp@paulstack.co.uk"), "Incorrect email address"); - } - - [Test] - [ExpectedException] - public void it_should_throw_exception_when_forbidden_status_code_returned() - { - var client = new TeamCityClient("localhost:81"); - client.ConnectAsGuest(); - - var users = client.Users.All(); - - //assert: Throws exception - } + string userGroupName = "ALL_USERS_GROUP"; + List roles = _client.Users.AllUserRolesByUserGroup(userGroupName); + + Assert.That(roles.Any(), "No roles were found for that userGroup"); + } + + [Test] + public void it_returns_all_users() + { + List users = _client.Users.All(); + + Assert.That(users.Any(), "No users found for this server"); + } + + [Test] + public void it_returns_all_user_roles_by_user_name() + { + string userName = "teamcitysharpuser"; + List roles = _client.Users.AllRolesByUserName(userName); + + Assert.That(roles.Any(), "No roles found for this user"); + } + + [Test] + public void it_returns_all_user_groups_by_user_group_name() + { + string userName = "teamcitysharpuser"; + List groups = _client.Users.AllGroupsByUserName(userName); + + Assert.That(groups.Any(), "This user is not a member of any groups"); + } + + [Test] + public void it_returns_user_details_by_user() + { + string userName = "teamcitysharpuser"; + User details = _client.Users.Details(userName); + + Assert.That(details.Email.ToLowerInvariant().Equals("teamcitysharp@paulstack.co.uk"), "Incorrect email address"); + } + + [Test] + public void it_should_throw_exception_when_forbidden_status_code_returned() + { + var client = new TeamCityClient("localhost:81"); + client.ConnectAsGuest(); + + Assert.Throws(() => client.Users.All()); + } + } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/SampleVcsUsage.cs b/src/Tests/IntegrationTests/SampleVcsUsage.cs index 9be8c268..9e8f5cc1 100644 --- a/src/Tests/IntegrationTests/SampleVcsUsage.cs +++ b/src/Tests/IntegrationTests/SampleVcsUsage.cs @@ -7,64 +7,54 @@ namespace TeamCitySharp.IntegrationTests { - [TestFixture] - public class when_interacting_to_get_vcs_details - { - private ITeamCityClient _client; - - [SetUp] - public void SetUp() - { - _client = new TeamCityClient("teamcity.codebetter.com"); - _client.Connect("teamcitysharpuser", "qwerty"); - } - - [Test] - [ExpectedException(typeof(ArgumentNullException))] - public void it_returns_exception_when_no_host_specified() - { - var client = new TeamCityClient(null); - - //Assert: Exception - } + [TestFixture] + public class when_interacting_to_get_vcs_details + { + private ITeamCityClient _client; - [Test] - [ExpectedException(typeof(WebException))] - public void it_returns_exception_when_host_does_not_exist() - { - var client = new TeamCityClient("test:81"); - client.Connect("admin", "qwerty"); + [SetUp] + public void SetUp() + { + _client = new TeamCityClient("teamcity.codebetter.com"); + _client.Connect("teamcitysharpuser", "qwerty"); + } - var vcsroots = client.VcsRoots.All(); + [Test] + public void it_returns_exception_when_no_host_specified() + { + Assert.Throws(() => new TeamCityClient(null)); + } - //Assert: Exception - } + [Test] + public void it_returns_exception_when_host_does_not_exist() + { + var client = new TeamCityClient("test:81"); + client.Connect("admin", "qwerty"); - [Test] - [ExpectedException(typeof(ArgumentException))] - public void it_returns_exception_when_no_connection_formed() - { - var client = new TeamCityClient("teamcity.codebetter.com"); + Assert.Throws(() => client.VcsRoots.All()); + } - var vcsRoots = client.VcsRoots.All(); + [Test] + public void it_returns_exception_when_no_connection_formed() + { + var client = new TeamCityClient("teamcity.codebetter.com"); + Assert.Throws(() => client.VcsRoots.All()); + } - //Assert: Exception - } - - [Test] - public void it_returns_all_vcs_roots() - { - List vcsRoots = _client.VcsRoots.All(); + [Test] + public void it_returns_all_vcs_roots() + { + List vcsRoots = _client.VcsRoots.All(); - Assert.That(vcsRoots.Any(), "No VCS Roots were found for the installation"); - } + Assert.That(vcsRoots.Any(), "No VCS Roots were found for the installation"); + } - [TestCase("1")] - public void it_returns_vcs_details_when_passing_vcs_root_id(string vcsRootId) - { - VcsRoot rootDetails = _client.VcsRoots.ById(vcsRootId); + [TestCase("1")] + public void it_returns_vcs_details_when_passing_vcs_root_id(string vcsRootId) + { + VcsRoot rootDetails = _client.VcsRoots.ById(vcsRootId); - Assert.That(rootDetails != null, "Cannot find the specific VCSRoot"); - } + Assert.That(rootDetails != null, "Cannot find the specific VCSRoot"); } + } } \ No newline at end of file diff --git a/src/Tests/IntegrationTests/TeamCitySharp.IntegrationTests.csproj b/src/Tests/IntegrationTests/TeamCitySharp.IntegrationTests.csproj index 03278016..bba14413 100644 --- a/src/Tests/IntegrationTests/TeamCitySharp.IntegrationTests.csproj +++ b/src/Tests/IntegrationTests/TeamCitySharp.IntegrationTests.csproj @@ -32,7 +32,7 @@ - ..\..\..\packages\NUnit.3.0.1\lib\nunit.framework.dll + ..\..\..\packages\NUnit.3.0.1\lib\net40\nunit.framework.dll diff --git a/src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj b/src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj index bf1e2c49..750c0b35 100644 --- a/src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj +++ b/src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj @@ -41,7 +41,7 @@ ..\..\..\packages\FluentAssertions.2.0.1\lib\net40\FluentAssertions.dll - ..\..\..\packages\NUnit.3.0.1\lib\nunit.framework.dll + ..\..\..\packages\NUnit.3.0.1\lib\net40\nunit.framework.dll