Skip to content

Commit

Permalink
Cleanup code ...
Browse files Browse the repository at this point in the history
  • Loading branch information
mavezeau committed Jan 26, 2016
1 parent 61b97d4 commit 2de2fac
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 117 deletions.
12 changes: 0 additions & 12 deletions src/TeamCitySharp/ActionTypes/Agents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,5 @@ public List<Agent> All(bool includeDisconnected = true, bool includeUnauthorized

return agentWrapper.Agent;
}

private string AddqueryString(string url, string queryString)
{
if (url.Contains("?"))
url += "&";
else
url += "?";

url += queryString;

return url;
}
}
}
6 changes: 5 additions & 1 deletion src/Tests/IntegrationTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("IntegrationTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -17,9 +18,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("904b02b8-18c4-4df0-9cf8-6fc55c0ada71")]

// Version information for an assembly consists of the following four values:
Expand All @@ -32,5 +35,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
92 changes: 46 additions & 46 deletions src/Tests/IntegrationTests/SampleConnectionUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,52 @@

namespace TeamCitySharp.IntegrationTests
{
[TestFixture]
public class when_connecting_to_the_teamcity_server
[TestFixture]
public class when_connecting_to_the_teamcity_server
{
private ITeamCityClient _client;

[SetUp]
public void SetUp()
{
private ITeamCityClient _client;

[SetUp]
public void SetUp()
{
_client = new TeamCityClient("localhost:81");
_client = new TeamCityClient("vmmobuild01");
}

[Test]
public void it_will_authenticate_a_known_user()
{
_client.Connect("admin", "qwerty");

Assert.That(_client.Authenticate());
}

[Test]
[ExpectedException(typeof(AuthenticationException))]
public void it_will_throw_an_exception_for_an_unknown_user()
{
_client.Connect("smithy", "smithy");
_client.Authenticate();

//Assert.Throws Exception
}
[Test]
public void it_will_authenticate_a_known_user_throwExceptionOnHttpError()
{
_client.Connect("admin", "qwerty");

Assert.That(_client.Authenticate(false));
}

[Test]
public void it_will_throw_an_exception_for_an_unknown_user_throwExceptionOnHttpError()
{
_client.Connect("smithy", "smithy");
Assert.IsFalse(_client.Authenticate(false));


//Assert.Throws Exception
}
_client = new TeamCityClient("localhost:81");
_client = new TeamCityClient("vmmobuild01");
}

[Test]
public void it_will_authenticate_a_known_user()
{
_client.Connect("admin", "qwerty");

Assert.That(_client.Authenticate());
}

[Test]
[ExpectedException(typeof (AuthenticationException))]
public void it_will_throw_an_exception_for_an_unknown_user()
{
_client.Connect("smithy", "smithy");
_client.Authenticate();

//Assert.Throws Exception
}

[Test]
public void it_will_authenticate_a_known_user_throwExceptionOnHttpError()
{
_client.Connect("admin", "qwerty");

Assert.That(_client.Authenticate(false));
}

[Test]
public void it_will_throw_an_exception_for_an_unknown_user_throwExceptionOnHttpError()
{
_client.Connect("smithy", "smithy");
Assert.IsFalse(_client.Authenticate(false));


//Assert.Throws Exception
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
3 changes: 2 additions & 1 deletion src/Tests/IntegrationTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>

<packages>
<package id="NUnit" version="3.0.1" />
</packages>
</packages>
107 changes: 54 additions & 53 deletions src/Tests/UnitTests/ActionTypes/ServerInformationTest.cs
Original file line number Diff line number Diff line change
@@ -1,63 +1,64 @@
namespace TeamCitySharp.ActionTypes
{
using FakeItEasy;
using FluentAssertions;
using NUnit.Framework;
using TeamCitySharp.Connection;
using FakeItEasy;
using FluentAssertions;
using NUnit.Framework;
using TeamCitySharp.Connection;

[TestFixture]
public class ServerInformationTest
[TestFixture]
public class ServerInformationTest
{
private ServerInformation testee;
private ITeamCityCaller teamCityCaller;

[SetUp]
public void SetUp()
{
private ServerInformation testee;
private ITeamCityCaller teamCityCaller;
this.teamCityCaller = A.Fake<ITeamCityCaller>();
this.testee = new ServerInformation(this.teamCityCaller);
}

[SetUp]
public void SetUp()
{
this.teamCityCaller = A.Fake<ITeamCityCaller>();
this.testee = new ServerInformation(this.teamCityCaller);
}

[TestCase(true, true, true, true)]
[TestCase(false, false, false, false)]
[TestCase(true, false, false, false)]
[TestCase(false, true, false, false)]
[TestCase(false, false, true, false)]
[TestCase(false, false, false, true)]
public void CreatesBackupWithSelectedParts(bool includeBuildLogs, bool includeConfigurations, bool includeDatabase, bool includePersonalChanges)
{
const string Filename = "Filename";
var backupOptions = new BackupOptions
{
Filename = Filename,
IncludeBuildLogs = includeBuildLogs,
IncludeConfigurations = includeConfigurations,
IncludeDatabase = includeDatabase,
IncludePersonalChanges = includePersonalChanges
};

this.testee.TriggerServerInstanceBackup(backupOptions);

A.CallTo(() => this.teamCityCaller.StartBackup(string.Concat(
"/app/rest/server/backup?fileName=",
Filename,
"&includeBuildLogs=" + includeBuildLogs,
"&includeConfigs=" + includeConfigurations,
"&includeDatabase=" + includeDatabase,
"&includePersonalChanges=" + includePersonalChanges)))
.MustHaveHappened();
}

[Test]
public void GetsBackupStatus()
[TestCase(true, true, true, true)]
[TestCase(false, false, false, false)]
[TestCase(true, false, false, false)]
[TestCase(false, true, false, false)]
[TestCase(false, false, true, false)]
[TestCase(false, false, false, true)]
public void CreatesBackupWithSelectedParts(bool includeBuildLogs, bool includeConfigurations, bool includeDatabase,
bool includePersonalChanges)
{
const string Filename = "Filename";
var backupOptions = new BackupOptions
{
const string Status = "Idle";
Filename = Filename,
IncludeBuildLogs = includeBuildLogs,
IncludeConfigurations = includeConfigurations,
IncludeDatabase = includeDatabase,
IncludePersonalChanges = includePersonalChanges
};

this.testee.TriggerServerInstanceBackup(backupOptions);

A.CallTo(() => this.teamCityCaller.StartBackup(string.Concat(
"/app/rest/server/backup?fileName=",
Filename,
"&includeBuildLogs=" + includeBuildLogs,
"&includeConfigs=" + includeConfigurations,
"&includeDatabase=" + includeDatabase,
"&includePersonalChanges=" + includePersonalChanges)))
.MustHaveHappened();
}

[Test]
public void GetsBackupStatus()
{
const string Status = "Idle";

A.CallTo(() => this.teamCityCaller.GetRaw("/app/rest/server/backup")).Returns(Status);
A.CallTo(() => this.teamCityCaller.GetRaw("/app/rest/server/backup")).Returns(Status);

string status = this.testee.GetBackupStatus();
string status = this.testee.GetBackupStatus();

status.Should().Be(Status);
}
status.Should().Be(Status);
}
}
}
}
6 changes: 5 additions & 1 deletion src/Tests/UnitTests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("TeamCitySharp.UnitTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
Expand All @@ -17,9 +18,11 @@
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("ffe7fbda-d6b9-459f-9b4d-a8d7858bd053")]

// Version information for an assembly consists of the following four values:
Expand All @@ -32,5 +35,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
2 changes: 1 addition & 1 deletion src/Tests/UnitTests/TeamCitySharp.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
3 changes: 2 additions & 1 deletion src/Tests/UnitTests/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<packages>
<package id="FakeItEasy" version="1.25.3" targetFramework="net40" />
<package id="FluentAssertions" version="2.0.1" targetFramework="net40" />
<package id="NUnit" version="3.0.1" targetFramework="net40" />
</packages>
</packages>

0 comments on commit 2de2fac

Please sign in to comment.