Esempio n. 1
0
        public async void AttemptsAuthenticationWhenNecessary()
        {
            authenticationToken.IsAuthenticated.Returns(false);
            httpClient
            .PostResponseAsync <LoginResponse>("login", GetLoginRequest())
            .Returns(x => new LoginResponse()
            {
                Token = "JwtToken"
            });
            authenticationToken
            .When(x => x.SetToken("JwtToken"))
            .Do(x => authenticationToken.IsAuthenticated.Returns(true));

            await authenticator.AuthenticateIfNecessaryAsync();

            authenticationToken.Received(1).SetToken("JwtToken");
        }
Esempio n. 2
0
        public async Task <T> GetAsync <T>(Request request)
        {
            await authenticator.AuthenticateIfNecessaryAsync().ConfigureAwait(false);

            return(await httpClient.GetResponseAsync <T>(request.BuildRequest()).ConfigureAwait(false));
        }