diff --git a/src/GitHubApiStatus.Extensions.UnitTests/MockGitHubApiStatusService.cs b/src/GitHubApiStatus.Extensions.UnitTests/MockGitHubApiStatusService.cs index 556be17..7bd63d3 100644 --- a/src/GitHubApiStatus.Extensions.UnitTests/MockGitHubApiStatusService.cs +++ b/src/GitHubApiStatus.Extensions.UnitTests/MockGitHubApiStatusService.cs @@ -4,13 +4,8 @@ namespace GitHubApiStatus.Extensions; -public class MockGitHubApiStatusService : IGitHubApiStatusService +public class MockGitHubApiStatusService(HttpClient httpClient) : IGitHubApiStatusService { - public MockGitHubApiStatusService(HttpClient httpClient) - { - - } - public bool IsProductHeaderValueValid => true; public bool IsAuthenticationHeaderValueSet => true; diff --git a/src/GitHubApiStatus.UnitTests/Tests/GetApiRateLimitsTests_NoCancellationToken.cs b/src/GitHubApiStatus.UnitTests/Tests/GetApiRateLimitsTests_NoCancellationToken.cs index e85dcb9..b7e8b03 100644 --- a/src/GitHubApiStatus.UnitTests/Tests/GetApiRateLimitsTests_NoCancellationToken.cs +++ b/src/GitHubApiStatus.UnitTests/Tests/GetApiRateLimitsTests_NoCancellationToken.cs @@ -134,7 +134,9 @@ public async Task GetApiRateLimits_ValidSearchApiRequest() Assert.AreEqual(searchApiStatus_Initial.RateLimit, searchApiStatus_Final.RateLimit); Assert.IsTrue(searchApiStatus_Initial.RateLimitReset_DateTime == searchApiStatus_Final.RateLimitReset_DateTime || searchApiStatus_Initial.RateLimitReset_DateTime == searchApiStatus_Final.RateLimitReset_DateTime.Subtract(TimeSpan.FromSeconds(1))); + #if NET8_0_OR_GREATER Assert.GreaterOrEqual(searchApiStatus_Initial.RateLimitReset_TimeRemaining.TotalMilliseconds, searchApiStatus_Final.RateLimitReset_TimeRemaining.TotalMilliseconds); + #endif Assert.AreEqual(searchApiStatus_Initial.RateLimitReset_UnixEpochSeconds, searchApiStatus_Final.RateLimitReset_UnixEpochSeconds); Assert.GreaterOrEqual(searchApiStatus_Initial.RemainingRequestCount, searchApiStatus_Final.RemainingRequestCount); } diff --git a/src/GitHubApiStatus.UnitTests/Tests/GetApiRateLimitsTests_WithCancellationToken.cs b/src/GitHubApiStatus.UnitTests/Tests/GetApiRateLimitsTests_WithCancellationToken.cs index 410f582..dca5209 100644 --- a/src/GitHubApiStatus.UnitTests/Tests/GetApiRateLimitsTests_WithCancellationToken.cs +++ b/src/GitHubApiStatus.UnitTests/Tests/GetApiRateLimitsTests_WithCancellationToken.cs @@ -101,7 +101,7 @@ public async Task GetApiRateLimits_ValidGraphQLApiRequest() public async Task GetApiRateLimits_ValidSearchApiRequest() { //Arrange - RateLimitStatus searchApiStatus_Initial, codeScanningApiStatus_Final; + RateLimitStatus searchApiStatus_Initial, searchApiStatus_Final; GitHubApiRateLimits gitHubApiRateLimits_Initial, gitHubApiRateLimits_Final; var startTime = DateTimeOffset.UtcNow; @@ -114,7 +114,7 @@ public async Task GetApiRateLimits_ValidSearchApiRequest() await SendValidSearchApiRequest().ConfigureAwait(false); gitHubApiRateLimits_Final = await GitHubApiStatusService.GetApiRateLimits(cancellationTokenSource.Token).ConfigureAwait(false); - codeScanningApiStatus_Final = gitHubApiRateLimits_Final.SearchApi; + searchApiStatus_Final = gitHubApiRateLimits_Final.SearchApi; //Assert Assert.IsNotNull(searchApiStatus_Initial); @@ -125,19 +125,19 @@ public async Task GetApiRateLimits_ValidSearchApiRequest() Assert.GreaterOrEqual(searchApiStatus_Initial.RateLimitReset_DateTime, startTime); Assert.GreaterOrEqual(searchApiStatus_Initial.RateLimitReset_UnixEpochSeconds, startTime.ToUnixTimeSeconds()); - Assert.IsNotNull(codeScanningApiStatus_Final); - Assert.AreEqual(30, codeScanningApiStatus_Final.RateLimit); - Assert.GreaterOrEqual(codeScanningApiStatus_Final.RemainingRequestCount, 0); - Assert.LessOrEqual(codeScanningApiStatus_Final.RemainingRequestCount, codeScanningApiStatus_Final.RateLimit); - Assert.AreEqual(codeScanningApiStatus_Final.RateLimitReset_DateTime.ToUnixTimeSeconds(), codeScanningApiStatus_Final.RateLimitReset_UnixEpochSeconds); - Assert.GreaterOrEqual(codeScanningApiStatus_Final.RateLimitReset_DateTime, startTime); - Assert.GreaterOrEqual(codeScanningApiStatus_Final.RateLimitReset_UnixEpochSeconds, startTime.ToUnixTimeSeconds()); - - Assert.AreEqual(searchApiStatus_Initial.RateLimit, codeScanningApiStatus_Final.RateLimit); - Assert.AreEqual(searchApiStatus_Initial.RateLimitReset_DateTime, codeScanningApiStatus_Final.RateLimitReset_DateTime); - Assert.GreaterOrEqual(searchApiStatus_Initial.RateLimitReset_TimeRemaining, codeScanningApiStatus_Final.RateLimitReset_TimeRemaining); - Assert.AreEqual(searchApiStatus_Initial.RateLimitReset_UnixEpochSeconds, codeScanningApiStatus_Final.RateLimitReset_UnixEpochSeconds); - Assert.GreaterOrEqual(searchApiStatus_Initial.RemainingRequestCount, codeScanningApiStatus_Final.RemainingRequestCount); + Assert.IsNotNull(searchApiStatus_Final); + Assert.AreEqual(30, searchApiStatus_Final.RateLimit); + Assert.GreaterOrEqual(searchApiStatus_Final.RemainingRequestCount, 0); + Assert.LessOrEqual(searchApiStatus_Final.RemainingRequestCount, searchApiStatus_Final.RateLimit); + Assert.AreEqual(searchApiStatus_Final.RateLimitReset_DateTime.ToUnixTimeSeconds(), searchApiStatus_Final.RateLimitReset_UnixEpochSeconds); + Assert.GreaterOrEqual(searchApiStatus_Final.RateLimitReset_DateTime, startTime); + Assert.GreaterOrEqual(searchApiStatus_Final.RateLimitReset_UnixEpochSeconds, startTime.ToUnixTimeSeconds()); + + Assert.AreEqual(searchApiStatus_Initial.RateLimit, searchApiStatus_Final.RateLimit); + Assert.AreEqual(searchApiStatus_Initial.RateLimitReset_DateTime, searchApiStatus_Final.RateLimitReset_DateTime); + Assert.GreaterOrEqual(searchApiStatus_Initial.RateLimitReset_TimeRemaining, searchApiStatus_Final.RateLimitReset_TimeRemaining); + Assert.AreEqual(searchApiStatus_Initial.RateLimitReset_UnixEpochSeconds, searchApiStatus_Final.RateLimitReset_UnixEpochSeconds); + Assert.GreaterOrEqual(searchApiStatus_Initial.RemainingRequestCount, searchApiStatus_Final.RemainingRequestCount); } [Test]