mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-01 02:18:44 +00:00
Moved GetReadme and GetReadmeHtml to Contents
This commit is contained in:
committed by
Haacked
parent
790c07da30
commit
bed18b9980
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user