public async Task ShouldUseExistingTokenWhenNotExpired() { var tokenStore = new UnexpiredTokenStore(); var client = new IGDB.IGDBClient(GDB_CLIENT_ID, IGDB_CLIENT_SECRET, // Environment.GetEnvironmentVariable("IGDB_CLIENT_ID"), // Environment.GetEnvironmentVariable("IGDB_CLIENT_SECRET"), tokenStore ); await client.QueryAsync <Game>("games"); await client.QueryAsync <Game>("games"); Assert.True(tokenStore.Acquired); }
public async Task ShouldHandleExpiredTokenAndAcquireNewOne() { var tokenStore = new ExpiredTokenStore(); var client = new IGDB.IGDBClient(GDB_CLIENT_ID, IGDB_CLIENT_SECRET, // Environment.GetEnvironmentVariable("IGDB_CLIENT_ID"), // Environment.GetEnvironmentVariable("IGDB_CLIENT_SECRET"), tokenStore ); await client.QueryAsync <Game>("games"); await client.QueryAsync <Game>("games"); Assert.NotEqual(0, tokenStore.CurrentToken.ExpiresIn); Assert.True(tokenStore.Expired); }
public async Task ShouldHandleInvalidTokenAndRetryRequest() { var tokenStore = new InvalidTokenStore(); var invalidTokenClient = new IGDB.IGDBClient(GDB_CLIENT_ID, IGDB_CLIENT_SECRET, // Environment.GetEnvironmentVariable("IGDB_CLIENT_ID"), // Environment.GetEnvironmentVariable("IGDB_CLIENT_SECRET"), tokenStore ); var games = await invalidTokenClient.QueryAsync <Game>("games"); Assert.True(games.Count > 0); Assert.True(tokenStore.Invalidated); }