public async Task InsertToken(string key, string value)
        {
            if (string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value))
            {
                var errorMessage = $"Neither Key or Value can be null or empty: key = {key} and value = {value}";

                _logger.LogWarning(errorMessage);

                throw new ArgumentException(errorMessage);
            }

            await _tokenDb.InsertToken(key, value);

            // This log is here for example sake. Do not send plaintext values to Logs
            _logger.LogInformation("Token key: {key} added to persistent store");

            await InsertTokenToCache(key, value);
        }
コード例 #2
0
        public async Task DoesNotSwallowTokenDbExceptions()
        {
            _tokenDb.InsertToken("foo", "bar").ThrowsForAnyArgs(new Exception());

            await Assert.ThrowsAsync <Exception>(() => _sut.InsertToken("foo", "bar"));
        }