Skip to content

Commit

Permalink
Fix Failing Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brminnick committed May 26, 2024
1 parent 60f9cff commit 4ce0ae5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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]
Expand Down

0 comments on commit 4ce0ae5

Please sign in to comment.