Moved GetReadme and GetReadmeHtml to Contents

This commit is contained in:
Kristian Hellang
2014-03-18 20:12:13 +01:00
committed by Haacked
parent 790c07da30
commit bed18b9980
23 changed files with 295 additions and 78 deletions
@@ -323,54 +323,6 @@ namespace Octokit.Tests.Clients
}
}
public class TheGetReadmeMethod
{
[Fact]
public async Task ReturnsReadme()
{
string encodedContent = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello world"));
var readmeInfo = new ReadmeResponse
{
Content = encodedContent,
Encoding = "base64",
Name = "README.md",
Url = "https://github.example.com/readme.md",
HtmlUrl = "https://github.example.com/readme"
};
var connection = Substitute.For<IApiConnection>();
connection.Get<ReadmeResponse>(Args.Uri, null).Returns(Task.FromResult(readmeInfo));
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
var reposEndpoint = new RepositoriesClient(connection);
var readme = await reposEndpoint.GetReadme("fake", "repo");
Assert.Equal("README.md", readme.Name);
connection.Received().Get<ReadmeResponse>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"),
null);
connection.DidNotReceive().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme.md"),
null);
var htmlReadme = await readme.GetHtmlContent();
Assert.Equal("<html>README</html>", htmlReadme);
connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "https://github.example.com/readme.md"), null);
}
}
public class TheGetReadmeHtmlMethod
{
[Fact]
public async Task ReturnsReadmeHtml()
{
var connection = Substitute.For<IApiConnection>();
connection.GetHtml(Args.Uri, null).Returns(Task.FromResult("<html>README</html>"));
var reposEndpoint = new RepositoriesClient(connection);
var readme = await reposEndpoint.GetReadmeHtml("fake", "repo");
connection.Received().GetHtml(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/readme"), null);
Assert.Equal("<html>README</html>", readme);
}
}
public class TheGetAllBranchesMethod
{
[Fact]