public async Task Successful_token_request_should_trigger_TokenAcquired_event()
        {
            var eventsMock = new TokenEventsMock();
            var client     = HostFactory.CreateClient(
                b => b.AddOidcRefreshToken(o =>
            {
                _options(o);
                o.Events = eventsMock.CreateEvents();
            }),
                TokenEndpointHandler.ValidBearerToken("access-token", TimeSpan.MaxValue));

            await client.GetAsync("https://default");

            Check.That(eventsMock.LatestTokenAcquired).IsNotNull();
            Check.That(eventsMock.LatestTokenAcquired.AccessToken).IsEqualTo("access-token");
        }
        public async Task Token_request_error_should_trigger_TokenRequestFailed_event()
        {
            var eventsMock = new TokenEventsMock();
            var client     = HostFactory.CreateClient(
                b => b.AddOidcRefreshToken(o =>
            {
                _options(o);
                o.Events = eventsMock.CreateEvents();
            }),
                TokenEndpointHandler.OidcProtocolError("invalid_grant"));

            await client.GetAsync("https://default");

            Check.That(eventsMock.LatestTokenRequestFailed).IsNotNull();
            Check.That(eventsMock.LatestTokenRequestFailed.ErrorType).IsEqualTo(ResponseErrorType.Protocol);
            Check.That(eventsMock.LatestTokenRequestFailed.Error).IsEqualTo("invalid_grant");
        }