public async Task ReturnsValuesThatExistInSQL_ButNotInCache(string expectedKey, string expectedValue) { _cache.GetAsync(expectedKey).Returns <byte[]>(x => null); _tokenDb.GetToken(expectedKey).Returns(new Models.Token() { Key = expectedKey, Value = expectedValue }); var expectedToken = await _sut.GetToken(expectedKey); Assert.IsType <Models.Token>(expectedToken); Assert.Equal(expectedKey, expectedToken.Key); Assert.Equal(expectedValue, expectedToken.Value); await _cache.Received(1).GetAsync(expectedKey); await _tokenDb.Received(1).GetToken(expectedKey); }
private async Task <Token> GetTokenFromDb(string key) { var retrievedToken = await _tokenDb.GetToken(key); if (retrievedToken == null) { _logger.LogError("Could not retrieve token"); return(null); } if (string.IsNullOrEmpty(retrievedToken.Key) || string.IsNullOrEmpty(retrievedToken.Value)) { // Add logs return(null); } _logger.LogInformation("Retrieved token from persistent storage"); return(retrievedToken); }