示例#1
0
        private Task <LoginResponse> LoginAsync()
        {
            var loginRequest = new LoginRequest {
                ApiKey = apiKey
            };

            return(httpClient.PostResponseAsync <LoginResponse>("login", loginRequest));
        }
示例#2
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");
        }
示例#3
0
        public async Task <T> PostAsync <T>(Request request, object postData)
        {
            await authenticator.AuthenticateIfNecessaryAsync().ConfigureAwait(false);

            return(await httpClient.PostResponseAsync <T>(request.BuildRequest(), postData).ConfigureAwait(false));
        }