public async Task When_setting_one_action()
        {
            bool onRegistered = false,
                onAuthenticated = false,
                onLogout = false;

            IIdSiteAsyncResultListener listener = new InlineIdSiteAsyncResultListener(
                onAuthenticated: null,
                onLogout: (result, ct) =>
                {
                    onLogout = true;
                    return Task.FromResult(true);
                },
                onRegistered: null);

            var dummyAccountResult = Substitute.For<IAccountResult>();

            await listener.OnAuthenticatedAsync(dummyAccountResult, CancellationToken.None);
            await listener.OnLogoutAsync(dummyAccountResult, CancellationToken.None);
            await listener.OnRegisteredAsync(dummyAccountResult, CancellationToken.None);

            onRegistered.ShouldBeFalse();
            onAuthenticated.ShouldBeFalse();
            onLogout.ShouldBeTrue();
        }
        public async Task Handle_response(string id_, string jwtResponse, string expectedStatus, bool isNewAccount, string expectedState)
        {
            IAccountResult accountResultFromListener = null;

            var listener = new InlineIdSiteAsyncResultListener(
                onAuthenticated: (result, ct) =>
                {
                    if (expectedStatus == IdSiteResultStatus.Authenticated)
                    {
                        accountResultFromListener = result;
                    }
                    else
                    {
                        throw new InvalidOperationException("This method should not have been executed");
                    }

                    return Task.FromResult(true);
                },
                onLogout: (result, ct) =>
                {
                    if (expectedStatus == IdSiteResultStatus.Logout)
                    {
                        accountResultFromListener = result;
                    }
                    else
                    {
                        throw new InvalidOperationException("This method should not have been executed");
                    }

                    return Task.FromResult(true);
                },
                onRegistered: (result, ct) =>
                {
                    if (expectedStatus == IdSiteResultStatus.Registered)
                    {
                        accountResultFromListener = result;
                    }
                    else
                    {
                        throw new InvalidOperationException("This method should not have been executed");
                    }

                    return Task.FromResult(true);
                });

            var testApiKey = ClientApiKeys.Builder()
                .SetId("2EV70AHRTYF0JOA7OEFO3SM29")
                .SetSecret("goPUHQMkS4dlKwl5wtbNd91I+UrRehCsEDJrIrMruK8")
                .Build();
            var fakeRequestExecutor = Substitute.For<IRequestExecutor>();
            fakeRequestExecutor.ApiKey.Returns(testApiKey);

            this.dataStore = TestDataStore.Create(fakeRequestExecutor, Caches.NewInMemoryCacheProvider().Build());

            var request = new DefaultHttpRequest(HttpMethod.Get, new CanonicalUri($"https://foo.bar?{IdSiteClaims.JwtResponse}={jwtResponse}"));

            IIdSiteAsyncCallbackHandler callbackHandler = new DefaultIdSiteAsyncCallbackHandler(this.dataStore, request);
            callbackHandler.SetResultListener(listener);

            var accountResult = await callbackHandler.GetAccountResultAsync(CancellationToken.None);

            // Validate result
            (accountResult as DefaultAccountResult).Account.Href.ShouldBe("https://api.stormpath.com/v1/accounts/7Ora8KfVDEIQP38KzrYdAs");
            (accountResultFromListener as DefaultAccountResult).Account.Href.ShouldBe("https://api.stormpath.com/v1/accounts/7Ora8KfVDEIQP38KzrYdAs");

            accountResult.IsNewAccount.ShouldBe(isNewAccount);
            accountResultFromListener.IsNewAccount.ShouldBe(isNewAccount);

            accountResult.State.ShouldBe(expectedState);
            accountResultFromListener.State.ShouldBe(expectedState);

            var expectedResultStatus = IdSiteResultStatus.Parse(expectedStatus);
            accountResult.Status.ShouldBe(expectedResultStatus);
            accountResultFromListener.Status.ShouldBe(expectedResultStatus);
        }