private Task <LoginResponse> LoginAsync() { var loginRequest = new LoginRequest { ApiKey = apiKey }; return(httpClient.PostResponseAsync <LoginResponse>("login", loginRequest)); }
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"); }
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)); }