示例#1
0
        public async Task Initialize()
        {
            await _databaseFixture.Reset(new[] { "TS_USUARIO" });

            Usuario = new()
            {
                Usuario = UtilFaker.FakerHub.Person.FirstName,
                Senha   = UtilFaker.FakerHub.Random.AlphaNumeric(8)
            };
            Login = new()
            {
                Usuario = Usuario.Usuario,
                Senha   = Usuario.Senha
            };

            await _httpClient.PostAsync(_endpointUsuario, Usuario.AsHttpContent());

            var responseLogin = await _httpClient.PostAsync(_endpointLogin, Login.AsHttpContent());

            var jsonResponseLogin = await responseLogin.Content.ReadAsStringAsync();

            LoginToken = JsonConvert.DeserializeObject <LoginResult>(jsonResponseLogin);
        }

        public HttpClient GetAuthHttpClient()
        {
            var client = GetHttpClient();

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", LoginToken.Token);
            return(client);
        }