Exemplo n.º 1
0
        public async void RaceLogin_Should_Call_IApiRequestProvider_CreatePostRequest()
        {
            _requestProvider.CreatePostRequest(Arg.Any <string>(), Arg.Any <Dictionary <string, string> >(), Arg.Any <MazebotLoginRequest>(), Arg.Any <Dictionary <string, string> >());

            var request = new MazebotLoginRequest();
            await _client.RaceLogin(request);

            _requestProvider.Received(1).CreatePostRequest($"{_noopsUrl}/mazebot/race/start", Arg.Any <Dictionary <string, string> >(), request, Arg.Any <Dictionary <string, string> >());
        }
        public async Task <MazebotLoginResponse> RaceLogin(MazebotLoginRequest login)
        {
            var url = $"{_apiUrl}/mazebot/race/start";

            try
            {
                var request = _requestProvider.CreatePostRequest(url, content: login);

                var response = await _client.SendAsync(request, async r =>
                {
                    r.EnsureSuccessStatusCode();
                    var content = await r.Content.ReadAsStringAsync();
                    return(JsonConvert.DeserializeAnonymousType(content, new MazebotLoginResponse()));
                });

                return(response);
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"An error has occurred while trying to call the mazebot API {url}.");
                return(null);
            }
        }
Exemplo n.º 3
0
 private async Task <MazebotLoginResponse> RaceLogin(MazebotLoginRequest request)
 {
     return(await _apiClient.RaceLogin(request));
 }