using System.Threading.Tasks; using Octokit; using Octokit.Tests.Integration; using Xunit; public class MiscellaneousClientTests { public class TheGetEmojisMethod { [IntegrationTest] public async Task GetsAllTheEmojis() { var github = Helper.GetAuthenticatedClient(); var emojis = await github.Miscellaneous.GetAllEmojis(); Assert.True(emojis.Count > 1); } } public class TheRenderRawMarkdownMethod { [IntegrationTest] public async Task CanRenderGitHubFlavoredMarkdown() { var github = Helper.GetAuthenticatedClient(); var result = await github.Miscellaneous.RenderRawMarkdown("This is\r\n a **test**"); Assert.Equal("
This is\na test
\n", result); } } public class TheGetGitIgnoreTemplatesMethod { [IntegrationTest] public async Task ReturnsListOfGitIgnoreTemplates() { var github = Helper.GetAuthenticatedClient(); var result = await github.Miscellaneous.GetAllGitIgnoreTemplates(); Assert.True(result.Count > 2); } } public class TheGetLicensesMethod { [IntegrationTest] public async Task CanRetrieveListOfLicenses() { var github = Helper.GetAuthenticatedClient(); var result = await github.Miscellaneous.GetAllLicenses(); Assert.True(result.Count > 2); Assert.Contains(result, license => license.Key == "mit"); } [IntegrationTest] public async Task CanRetrieveListOfLicensesWithPagination() { var github = Helper.GetAuthenticatedClient(); var options = new ApiOptions { PageCount = 1, PageSize = 5, }; var result = await github.Miscellaneous.GetAllLicenses(options); Assert.Equal(5, result.Count); } [IntegrationTest] public async Task CanRetrieveDistinctListOfLicensesBasedOnPageStart() { var github = Helper.GetAuthenticatedClient(); var startOptions = new ApiOptions { PageSize = 1, PageCount = 1 }; var firstPage = await github.Miscellaneous.GetAllLicenses(startOptions); var skipStartOptions = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 2 }; var secondPage = await github.Miscellaneous.GetAllLicenses(skipStartOptions); Assert.NotEqual(firstPage[0].Key, secondPage[0].Key); } } public class TheGetLicenseMethod { [IntegrationTest] public async Task CanRetrieveListOfLicenses() { var github = Helper.GetAuthenticatedClient(); var result = await github.Miscellaneous.GetLicense("mit"); Assert.Equal("mit", result.Key); Assert.Equal("MIT License", result.Name); } [IntegrationTest] public async Task ReportsErrorWhenInvalidLicenseProvided() { var github = Helper.GetAuthenticatedClient(); await Assert.ThrowsAsync