mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
* Added StringEnum<TEnum> * Added tests * Make sure the serializer can work with StringEnum * Use StringEnum for EventInfo.Event * Add convention test to assert that all Response models use StringEnum<> to wrap enum properties * Add Stringnum<> to all response types failing convention test * Handle StringEnum to Enum conversion when Issue response model populates IssueUpdate request model * Fix unit test * Refactor SimpleJsonSerializer to expose the DeserializeEnum strategy so it can be used in StringEnum class * Need to expose/use SerializeEnum functionality too, so we use the correct string representation of enum values that have custom properties (eg ReactionType Plus1 to "+1") * fix unit tests, since the string is now the "correct" upstream api value * Add a couple of tests for the Enum serialize/deserialize when underscores, hyphens and custom property attributes are present * Compare parsed values for equality * add convention test to ensure enum members all have Parameter property set * update test to cover implicit conversions too * this test should work but fails at the moment due to magic hyphen removal in deserializer causing a one way trip from utf-8 to EncodingType.Utf8 with no way to get back * (unsuccesfully) expand event info test to try to catch more cases of unknown event types * fix broken integration test while im here * Fixed build errors after .NET Core merge * Value -> StringValue, ParsedValue -> Value * Don't allow StringValue to be null * Ignore enums not used in request/response models * Added ParameterAttribute to almost all enum values * Ignore Language enum * Fix failing tests * Fix milestone sort parameter and tests * whitespace * fix milestone unit tests * Fix StringEnum.Equals ... This could've been embarrassing! * Change SimpleJsonSerializer Enum handling to only use `[Parameter()]` attributes (no more magic removal of hyphen/underscores from strings) * Tidy up this integration test while im here * Only test request/response enums in convention test * Keep skipping Language * Remove unused method * Remove excluded enum types * Removed unnecessary ParameterAttributes * Remove unused enum * Add StringEnum test for string-comparison of two invalid values * Bring back IssueCommentSort and use it in IssueCommentRequest This reverts commit 38a4a291d1476ef8c992fe0f76956974b6f32a49. * Use assembly instead of namespace for Octokit check * Add failing test to reproduce the issue where only the first enum paramter/value was added to the cache * Fix deserializer enum cache to include all enum members rather than only the first member encountered * Use a static SimpleJsonSerializer in StringEnum * Remove serializer instance in StringEnum * Add some documentation on StringEnum<TEnum> * Fix parameter value to resolve failing integration test
123 lines
3.9 KiB
C#
123 lines
3.9 KiB
C#
using System.Threading.Tasks;
|
|
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("<p>This is\na <strong>test</strong></p>\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");
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
public class TheGetResourceRateLimitsMethod
|
|
{
|
|
[IntegrationTest]
|
|
public async Task CanRetrieveResourceRateLimits()
|
|
{
|
|
var github = Helper.GetAuthenticatedClient();
|
|
|
|
var result = await github.Miscellaneous.GetRateLimits();
|
|
|
|
// Test the core limits
|
|
Assert.True(result.Resources.Core.Limit > 0);
|
|
Assert.True(result.Resources.Core.Remaining > -1);
|
|
Assert.True(result.Resources.Core.Remaining <= result.Resources.Core.Limit);
|
|
Assert.True(result.Resources.Core.ResetAsUtcEpochSeconds > 0);
|
|
Assert.NotNull(result.Resources.Core.Reset);
|
|
|
|
// Test the search limits
|
|
Assert.True(result.Resources.Search.Limit > 0);
|
|
Assert.True(result.Resources.Search.Remaining > -1);
|
|
Assert.True(result.Resources.Search.Remaining <= result.Resources.Search.Limit);
|
|
Assert.True(result.Resources.Search.ResetAsUtcEpochSeconds > 0);
|
|
Assert.NotNull(result.Resources.Search.Reset);
|
|
|
|
// Test the depreciated rate limits
|
|
Assert.True(result.Rate.Limit > 0);
|
|
Assert.True(result.Rate.Remaining > -1);
|
|
Assert.True(result.Rate.Remaining <= result.Rate.Limit);
|
|
Assert.True(result.Resources.Search.ResetAsUtcEpochSeconds > 0);
|
|
Assert.NotNull(result.Resources.Search.Reset);
|
|
}
|
|
}
|
|
|
|
public class TheGetMetadataMethod
|
|
{
|
|
[IntegrationTest]
|
|
public async Task CanRetrieveMetadata()
|
|
{
|
|
var github = Helper.GetAnonymousClient();
|
|
|
|
var result = await github.Miscellaneous.GetMetadata();
|
|
|
|
Assert.True(result.VerifiablePasswordAuthentication);
|
|
Assert.NotEmpty(result.GitHubServicesSha);
|
|
Assert.True(result.Hooks.Count > 0);
|
|
Assert.True(result.Git.Count > 0);
|
|
Assert.True(result.Pages.Count > 0);
|
|
Assert.True(result.Importer.Count > 0);
|
|
}
|
|
}
|
|
} |