/// <inheritdoc/> public async Task <double> ObterTaxaAtual() { try { var taxaJurosApi = ComunicacaoAPIFactory.ObterComunicacaoComApi <IConsultaTaxaDeJuros>("TaxaJurosUrl"); var consultaJuros = await taxaJurosApi.Get(); if (consultaJuros.IsSuccessStatusCode) { var juros = consultaJuros.Content; return(juros); } else { throw consultaJuros.Error; } } catch (Exception ex) { Log.Error("Houve um erro ao consultar a taxa de juros atual.", ex); throw; } }
public async void ChamarEndpointInexistente() { var calculaJurosApi = ComunicacaoAPIFactory.ObterComunicacaoComApi <ICalculoDeJurosParaTestes>("CalculaJurosUrl"); var jurosCalculadoResponse = await calculaJurosApi.NaoEncontrado(); jurosCalculadoResponse.StatusCode.Should().Be(HttpStatusCode.NotFound); }
public async void CalcularJurosParametrosInvalidos(double valorInicial, int meses, string erroValidacao) { var calculaJurosApi = ComunicacaoAPIFactory.ObterComunicacaoComApi <ICalculoDeJuros>("CalculaJurosUrl"); var jurosCalculadoResponse = await calculaJurosApi.GetCalculaJuros(valorInicial, meses); jurosCalculadoResponse.StatusCode.Should().Be(HttpStatusCode.BadRequest); var mensagemErro = jurosCalculadoResponse.Error.Content; mensagemErro.Should().Be(erroValidacao); }
public async void CalcularJuros(double valorInicial, int meses, double jurosEsperado) { var calculaJurosApi = ComunicacaoAPIFactory.ObterComunicacaoComApi <ICalculoDeJuros>("CalculaJurosUrl"); var jurosCalculadoResponse = await calculaJurosApi.GetCalculaJuros(valorInicial, meses); jurosCalculadoResponse.StatusCode.Should().Be(HttpStatusCode.OK); var jurosCalculado = jurosCalculadoResponse.Content; jurosCalculado.Should().Be(jurosEsperado); }
public async void ObterTaxaDeJuros(double taxaEsperada) { var taxaJurosApi = ComunicacaoAPIFactory.ObterComunicacaoComApi <IConsultaTaxaDeJuros>("TaxaJurosUrl"); var consultaTaxa = await taxaJurosApi.Get(); consultaTaxa.StatusCode.Should().Be(HttpStatusCode.OK); var taxaEncontrada = consultaTaxa.Content; taxaEncontrada.Should().Be(taxaEsperada); }
public async void ObterUrlGithub() { var urlEsperada = "https://github.com/DanielSR0/CalculoDeJurosSoftplan"; var showMeTheCodeApi = ComunicacaoAPIFactory.ObterComunicacaoComApi <ICalculoDeJuros>("CalculaJurosUrl"); var consultaUrl = await showMeTheCodeApi.GetShowMeTheCode(); consultaUrl.StatusCode.Should().Be(HttpStatusCode.OK); var urlEncontrada = consultaUrl.Content; urlEncontrada.Should().Be(urlEsperada); }