Skip to content

Commit

Permalink
Fix unit test for nunit 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mavezeau committed Jan 26, 2016
1 parent 2de2fac commit e6ddbfa
Show file tree
Hide file tree
Showing 13 changed files with 704 additions and 777 deletions.
89 changes: 40 additions & 49 deletions src/Tests/IntegrationTests/SampleAgentUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArgumentNullException>(() => 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<WebException>(() => 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<ArgumentException>(() => client.Agents.All());
}

[Test]
public void it_returns_all_agents()
{
List<Agent> agents = _client.Agents.All();
[Test]
public void it_returns_all_agents()
{
List<Agent> 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");
}
}
}
205 changes: 99 additions & 106 deletions src/Tests/IntegrationTests/SampleBuildsConfigsUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ArgumentNullException>(() => 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<WebException>(() => client.BuildConfigs.All());
}

[Test]
public void it_throws_exception_when_no_connection_formed()
{
var client = new TeamCityClient("teamcity.codebetter.com");

Assert.Throws<ArgumentException>(() => 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");
}
}
}
Loading

0 comments on commit e6ddbfa

Please sign in to comment.