public async Task GetTokenFromCache()
        {
            var cache = CreateMockedCache(_cacheKey, new TokenReply { access_token = "accessToken" });
            var tokenHelper = new TokenHelper(cache.Object);

            var token = await tokenHelper.ReadOrRetrieveToken(_settings);

            Assert.Equal("accessToken", token.access_token);
        }
        public async Task SetTokenInCache()
        {
            var cacheEntry = new TestCacheEntry();
            var mockedCache = CreateEmptyMockedCache(cacheEntry);

            var tokenHelper = new TokenHelper(mockedCache.Object);
            tokenHelper._client = CreateClient();

            var token = await tokenHelper.ReadOrRetrieveToken(_settings);

            Assert.Equal("accessToken", ((TokenReply)cacheEntry.Value).access_token);
        }
        public async Task ThrowsExceptionWhenCallFailed()
        {
            var cacheEntry = new TestCacheEntry();
            var mockedCache = CreateEmptyMockedCache(cacheEntry);

            var tokenHelper = new TokenHelper(mockedCache.Object);
            tokenHelper._client = CreateClient();

            _settings.OAuthPathAddition = "";

            await Assert.ThrowsAsync<Exception>(async () => await tokenHelper.ReadOrRetrieveToken(_settings));
        }