public IActionResult TaxCalculate(TaxesCommand command) { var validator = command.Validate(); if (!validator.IsValid) { return(BadRequest(validator.Errors)); } return(Ok(_taxService.TaxCalculate(command))); }
public void TestInitialize() { _service = new Mock <ITaxService>(); _service.Setup(x => x.TaxCalculate(It.IsAny <TaxesCommand>())).Returns(TaxCalculate); _command = new TaxesCommand() { Tempo = 5, ValorInicial = 100 }; }
/// <summary> /// Calcula os juros compostos /// </summary> /// <param name="taxCommand">Comando com os parametros necessários para calcular os juros compostos</param> /// <returns>Retorna o resultado do calculo de juros compostos</returns> public string TaxCalculate(TaxesCommand taxCommand) { var taxaJuros = Task.Run(async() => { return(await GetTaxFromApiOne()); }).Result; if (taxaJuros == null) { return("Não foi possível calcular os juros compostos"); } double valorFinal = taxCommand.ValorInicial * Math.Pow((1 + Double.Parse(taxaJuros, _culture)), taxCommand.Tempo); return(string.Format(_culture, "{0:0.00}", valorFinal)); }
public void TestInitialize() { _httpClientServie = new Mock <IHttpClientService>(); _httpClient = new Mock <HttpClient>(); _response = new HttpRequestMessage(); _command = new TaxesCommand() { Tempo = 5, ValorInicial = 100 }; _httpClientServie.Setup(x => x.GetAsync(It.IsAny <string>())).Returns(GetAsync); _httpClientServie.Setup(x => x.CreateClient()).Returns(CreateClient); _service = new TaxService(_httpClientServie.Object); }