public async Task Deve_Falhar_Registar_Taxa_Quando_TaxaCobrancaRepository_Lancar_Excecao() { const string INTERNAL_PROCESS_ERROR = "InternalProcessError"; //arrange var sut = CreateSut(); var command = FakeData.RegistrarNovaTaxaCommandVarejoValorUm; taxaCobrancaRepository.ObterTaxaCobrancaPorSegmento(Arg.Any <string>()).Returns(_ => Task.FromException(new Exception())); //act var resultado = await sut.Handle(command, CancellationToken.None); //assert resultado.IsFailure.Should().BeTrue(); resultado.ErrorResponse.Should().NotBeNull(); resultado.ErrorResponse.Error.Should().NotBeNull(); resultado.ErrorResponse.Error.Code.Should().Be(INTERNAL_PROCESS_ERROR); }
private async Task <TaxaResponse> ObterTaxaCobrancaPorSegmento(ObterTaxaCobrancaPorSegmentoQuery request, ObterTaxaCobrancaPorSegmentoResponse response, TipoSegmento tipoSegmento) { var taxaCobranca = await _taxaCobrancaRepository.ObterTaxaCobrancaPorSegmento(tipoSegmento.Id); if (string.IsNullOrEmpty(taxaCobranca.TaxaCobrancaId)) { response.AddError(Errors.General.NotFound(nameof(TaxaCobranca), request.TipoSegmento)); Logger.LogWarning($"{response.ErrorResponse}"); return(default);
private async Task VerficarSegmentoJaRegistrado(RegistrarNovaTaxaCommand request, RegistrarNovaTaxaResponse response) { try { TaxaCobranca = await _taxaCobrancaRepository.ObterTaxaCobrancaPorSegmento(TipoSegmento.Id); if (!string.IsNullOrEmpty(TaxaCobranca.TaxaCobrancaId)) { response.AddError(Errors.RegistrarNovaTaxaErros.TaxaParaSegmentoJaRegistrada(TipoSegmento.Id)); return; } } catch (Exception ex) { response.AddError(Errors.General.InternalProcessError("VerficarSegmentoJaRegistrado", ex.Message)); return; } }
public async Task ObterTaxaCobrancaPorSegmento() { var result = await _taxaCobrancaRepository.ObterTaxaCobrancaPorSegmento("VAREJO"); Debug.WriteLine(result.TaxaCobrancaId); }