refactor in order to use constansts instead of hardcoded values

This commit is contained in:
aedampir@gmail.com
2016-06-29 02:32:44 +07:00
parent 7af37853a4
commit ece24c5690
@@ -12,6 +12,12 @@ public class RepositoryCommitsClientTests
public class TestsWithExistingRepositories
{
readonly IRepositoryCommitsClient _fixture;
const int octokitNetRepositoryId = 7528679;
const string octokitNetRepositoryOwner = "octokit";
const string octokitNetRepositorName = "octokit.net";
const int reactiveGitRepositoryId = 22718025;
const string reactiveGitRepositoryOwner = "shiftkey";
const string reactiveGitRepositorName = "ReactiveGit";
public TestsWithExistingRepositories()
{
@@ -23,35 +29,35 @@ public class RepositoryCommitsClientTests
[IntegrationTest]
public async Task CanGetMergeBaseCommit()
{
var compareResult = await _fixture.Compare("octokit", "octokit.net", "65a22f4d2cff94a286ac3e96440c810c5509196f", "65a22f4d2cff94a286ac3e96440c810c5509196f");
var compareResult = await _fixture.Compare(octokitNetRepositoryOwner, octokitNetRepositorName, "65a22f4d2cff94a286ac3e96440c810c5509196f", "65a22f4d2cff94a286ac3e96440c810c5509196f");
Assert.NotNull(compareResult.MergeBaseCommit);
}
[IntegrationTest]
public async Task CanGetMergeBaseCommitWithRepositoryId()
{
var compareResult = await _fixture.Compare(7528679, "65a22f4d2cff94a286ac3e96440c810c5509196f", "65a22f4d2cff94a286ac3e96440c810c5509196f");
var compareResult = await _fixture.Compare(octokitNetRepositoryId, "65a22f4d2cff94a286ac3e96440c810c5509196f", "65a22f4d2cff94a286ac3e96440c810c5509196f");
Assert.NotNull(compareResult.MergeBaseCommit);
}
[IntegrationTest]
public async Task CanGetCommit()
{
var commit = await _fixture.Get("octokit", "octokit.net", "65a22f4d2cff94a286ac3e96440c810c5509196f");
var commit = await _fixture.Get(octokitNetRepositoryOwner, octokitNetRepositorName, "65a22f4d2cff94a286ac3e96440c810c5509196f");
Assert.NotNull(commit);
}
[IntegrationTest]
public async Task CanGetCommitWithRepositoryId()
{
var commit = await _fixture.Get(7528679, "65a22f4d2cff94a286ac3e96440c810c5509196f");
var commit = await _fixture.Get(octokitNetRepositoryId, "65a22f4d2cff94a286ac3e96440c810c5509196f");
Assert.NotNull(commit);
}
[IntegrationTest]
public async Task CanGetCommitWithFiles()
{
var commit = await _fixture.Get("octokit", "octokit.net", "65a22f4d2cff94a286ac3e96440c810c5509196f");
var commit = await _fixture.Get(octokitNetRepositoryOwner, octokitNetRepositorName, "65a22f4d2cff94a286ac3e96440c810c5509196f");
Assert.True(commit.Files.Any(file => file.Filename.EndsWith("IConnection.cs")));
}
@@ -59,7 +65,7 @@ public class RepositoryCommitsClientTests
[IntegrationTest]
public async Task CanGetCommitWithFilesWithRepositoryId()
{
var commit = await _fixture.Get(7528679, "65a22f4d2cff94a286ac3e96440c810c5509196f");
var commit = await _fixture.Get(octokitNetRepositoryId, "65a22f4d2cff94a286ac3e96440c810c5509196f");
Assert.True(commit.Files.Any(file => file.Filename.EndsWith("IConnection.cs")));
}
@@ -67,14 +73,14 @@ public class RepositoryCommitsClientTests
[IntegrationTest]
public async Task CanGetListOfCommits()
{
var list = await _fixture.GetAll("shiftkey", "ReactiveGit");
var list = await _fixture.GetAll(reactiveGitRepositoryOwner, reactiveGitRepositorName);
Assert.NotEmpty(list);
}
[IntegrationTest]
public async Task CanGetListOfCommitsWithRepositoryId()
{
var list = await _fixture.GetAll(22718025);
var list = await _fixture.GetAll(reactiveGitRepositoryId);
Assert.NotEmpty(list);
}
@@ -87,7 +93,7 @@ public class RepositoryCommitsClientTests
PageCount = 1
};
var commits = await _fixture.GetAll("shiftkey", "ReactiveGit", options);
var commits = await _fixture.GetAll(reactiveGitRepositoryOwner, reactiveGitRepositorName, options);
Assert.Equal(5, commits.Count);
}
@@ -100,7 +106,7 @@ public class RepositoryCommitsClientTests
PageCount = 1
};
var commits = await _fixture.GetAll(22718025, options);
var commits = await _fixture.GetAll(reactiveGitRepositoryId, options);
Assert.Equal(5, commits.Count);
}
@@ -114,7 +120,7 @@ public class RepositoryCommitsClientTests
StartPage = 2
};
var commits = await _fixture.GetAll("shiftkey", "ReactiveGit", options);
var commits = await _fixture.GetAll(reactiveGitRepositoryOwner, reactiveGitRepositorName, options);
Assert.Equal(5, commits.Count);
}
@@ -128,7 +134,7 @@ public class RepositoryCommitsClientTests
StartPage = 2
};
var commits = await _fixture.GetAll(22718025, options);
var commits = await _fixture.GetAll(reactiveGitRepositoryId, options);
Assert.Equal(5, commits.Count);
}
@@ -148,8 +154,8 @@ public class RepositoryCommitsClientTests
StartPage = 2
};
var firstCommit = await _fixture.GetAll("shiftkey", "ReactiveGit", startOptions);
var secondCommit = await _fixture.GetAll("shiftkey", "ReactiveGit", skipStartOptions);
var firstCommit = await _fixture.GetAll(reactiveGitRepositoryOwner, reactiveGitRepositorName, startOptions);
var secondCommit = await _fixture.GetAll(reactiveGitRepositoryOwner, reactiveGitRepositorName, skipStartOptions);
Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha);
Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha);
@@ -174,8 +180,8 @@ public class RepositoryCommitsClientTests
StartPage = 2
};
var firstCommit = await _fixture.GetAll(22718025, startOptions);
var secondCommit = await _fixture.GetAll(22718025, skipStartOptions);
var firstCommit = await _fixture.GetAll(reactiveGitRepositoryId, startOptions);
var secondCommit = await _fixture.GetAll(reactiveGitRepositoryId, skipStartOptions);
Assert.NotEqual(firstCommit[0].Sha, secondCommit[0].Sha);
Assert.NotEqual(firstCommit[1].Sha, secondCommit[1].Sha);
@@ -188,7 +194,7 @@ public class RepositoryCommitsClientTests
public async Task CanGetListOfCommitsBySha()
{
var request = new CommitRequest { Sha = "08b363d45d6ae8567b75dfa45c032a288584afd4" };
var list = await _fixture.GetAll("octokit", "octokit.net", request);
var list = await _fixture.GetAll(octokitNetRepositoryOwner, octokitNetRepositorName, request);
Assert.NotEmpty(list);
}
@@ -196,7 +202,7 @@ public class RepositoryCommitsClientTests
public async Task CanGetListOfCommitsByShaWithRepositoryId()
{
var request = new CommitRequest { Sha = "08b363d45d6ae8567b75dfa45c032a288584afd4" };
var list = await _fixture.GetAll(7528679, request);
var list = await _fixture.GetAll(octokitNetRepositoryId, request);
Assert.NotEmpty(list);
}
@@ -204,7 +210,7 @@ public class RepositoryCommitsClientTests
public async Task CanGetListOfCommitsByPath()
{
var request = new CommitRequest { Path = "Octokit.Reactive/IObservableGitHubClient.cs" };
var list = await _fixture.GetAll("octokit", "octokit.net", request);
var list = await _fixture.GetAll(octokitNetRepositoryOwner, octokitNetRepositorName, request);
Assert.NotEmpty(list);
}
@@ -212,7 +218,7 @@ public class RepositoryCommitsClientTests
public async Task CanGetListOfCommitsByPathWithRepositoryId()
{
var request = new CommitRequest { Path = "Octokit.Reactive/IObservableGitHubClient.cs" };
var list = await _fixture.GetAll(7528679, request);
var list = await _fixture.GetAll(octokitNetRepositoryId, request);
Assert.NotEmpty(list);
}
@@ -220,7 +226,7 @@ public class RepositoryCommitsClientTests
public async Task CanGetListOfCommitsByAuthor()
{
var request = new CommitRequest { Author = "kzu" };
var list = await _fixture.GetAll("octokit", "octokit.net", request);
var list = await _fixture.GetAll(octokitNetRepositoryOwner, octokitNetRepositorName, request);
Assert.NotEmpty(list);
}
@@ -228,7 +234,7 @@ public class RepositoryCommitsClientTests
public async Task CanGetListOfCommitsByAuthorWithRepositoryId()
{
var request = new CommitRequest { Author = "kzu" };
var list = await _fixture.GetAll(7528679, request);
var list = await _fixture.GetAll(octokitNetRepositoryId, request);
Assert.NotEmpty(list);
}
@@ -240,7 +246,7 @@ public class RepositoryCommitsClientTests
var until = new DateTimeOffset(2014, 1, 8, 0, 0, 0, offset);
var request = new CommitRequest { Since = since, Until = until };
var list = await _fixture.GetAll("octokit", "octokit.net", request);
var list = await _fixture.GetAll(octokitNetRepositoryOwner, octokitNetRepositorName, request);
Assert.NotEmpty(list);
}
@@ -252,14 +258,14 @@ public class RepositoryCommitsClientTests
var until = new DateTimeOffset(2014, 1, 8, 0, 0, 0, offset);
var request = new CommitRequest { Since = since, Until = until };
var list = await _fixture.GetAll(7528679, request);
var list = await _fixture.GetAll(octokitNetRepositoryId, request);
Assert.NotEmpty(list);
}
[IntegrationTest]
public async Task CanGetCommitWithRenamedFiles()
{
var commit = await _fixture.Get("octokit", "octokit.net", "997e955f38eb0c2c36e55b1588455fa857951dbf");
var commit = await _fixture.Get(octokitNetRepositoryOwner, octokitNetRepositorName, "997e955f38eb0c2c36e55b1588455fa857951dbf");
Assert.True(commit.Files
.Where(file => file.Status == "renamed")
@@ -269,7 +275,7 @@ public class RepositoryCommitsClientTests
[IntegrationTest]
public async Task CanGetCommitWithRenamedFilesWithRepositoryId()
{
var commit = await _fixture.Get(7528679, "997e955f38eb0c2c36e55b1588455fa857951dbf");
var commit = await _fixture.Get(octokitNetRepositoryId, "997e955f38eb0c2c36e55b1588455fa857951dbf");
Assert.True(commit.Files
.Where(file => file.Status == "renamed")
@@ -279,7 +285,7 @@ public class RepositoryCommitsClientTests
[IntegrationTest]
public async Task CanGetSha1()
{
var sha1 = await _fixture.GetSha1("octokit", "octokit.net", "master");
var sha1 = await _fixture.GetSha1(octokitNetRepositoryOwner, octokitNetRepositorName, "master");
Assert.NotNull(sha1);
}
@@ -287,7 +293,7 @@ public class RepositoryCommitsClientTests
[IntegrationTest]
public async Task CanGetSha1WithRepositoryId()
{
var sha1 = await _fixture.GetSha1(7528679, "master");
var sha1 = await _fixture.GetSha1(octokitNetRepositoryId, "master");
Assert.NotNull(sha1);
}