public async Task AcquireAccessToken_HttpError_Fail()
        {
            var tokenClient = new TokenClient(new HttpClient(new TestHttpMessageHandler(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new FailingHttpContent(typeof(HttpRequestException))
            })), new TokenClientOptions()
            {
                Address = "https://example.com"
            });

            var acquirer = new DefaultAccessTokenAcquirer(new TestLogger <DefaultAccessTokenAcquirer>(), tokenClient, Options.Create(new AuditTrailClientOptions()));

            await Assert.ThrowsAsync <HttpRequestException>(() => acquirer.AcquireAccessTokenAsync());
        }
        public async Task AcquireAccessToken_Twice_Success()
        {
            var tokenClient = new TokenClient(new HttpClient(new TestHttpMessageHandler(new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(@"{
                   ""access_token"":""2YotnFZFEjr1zCsicMWpAA"",
                   ""token_type"":""example"",
                   ""expires_in"":3600,
                   ""refresh_token"":""tGzv3JOkF0XG5Qx2TlKWIA""
                }")
            })), new TokenClientOptions()
            {
                Address = "https://example.com"
            });

            var acquirer = new DefaultAccessTokenAcquirer(new TestLogger <DefaultAccessTokenAcquirer>(), tokenClient, Options.Create(new AuditTrailClientOptions()));
            await acquirer.AcquireAccessTokenAsync();

            var token = await acquirer.AcquireAccessTokenAsync();

            // May also assert the http client is not used
            Assert.Equal("2YotnFZFEjr1zCsicMWpAA", token);
        }
        public async Task AcquireAccessToken_ProtocolError_Fail()
        {
            var tokenClient = new TokenClient(new HttpClient(new TestHttpMessageHandler(new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(@"{
                   ""error"":""invalid_request""
                }")
            })), new TokenClientOptions()
            {
                Address = "https://example.com"
            });

            var acquirer = new DefaultAccessTokenAcquirer(new TestLogger <DefaultAccessTokenAcquirer>(), tokenClient, Options.Create(new AuditTrailClientOptions()));

            await Assert.ThrowsAsync <HttpRequestException>(() => acquirer.AcquireAccessTokenAsync());
        }