Пример #1
0
        public async Task ShouldResult()
        {
            var response = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent("9.9"),
            };

            _mockHttpMessageHandler
            .Protected()
            .Setup <Task <HttpResponseMessage> >(
                "SendAsync",
                ItExpr.IsAny <HttpRequestMessage>(),
                ItExpr.IsAny <CancellationToken>())
            .ReturnsAsync(response);

            var baseFakeUrl = "http://localhost";
            var httpClient  = new HttpClient(_mockHttpMessageHandler.Object);

            _taxaJurosServico = new TaxaJurosServico(baseFakeUrl, httpClient);

            var resultado = await _taxaJurosServico.RetorneTaxaJuros();

            Assert.NotNull(resultado);

            _mockHttpMessageHandler
            .Protected()
            .Verify(
                "SendAsync",
                Times.Exactly(1),
                ItExpr.Is <HttpRequestMessage>(req => req.Method == HttpMethod.Get),
                ItExpr.IsAny <CancellationToken>());
        }
Пример #2
0
        public void ConsigoSelecionarTaxaDeJuros()
        {
            ITaxaJurosServico taxaJurosServico = new TaxaJurosServico();
            TaxaJurosDTO      taxaJurosDTO     = taxaJurosServico.ObterTaxaJuros();

            Assert.NotNull(taxaJurosDTO);
            Assert.True(taxaJurosDTO.TaxaJuros > 0);
        }
        public void ConsigoCalcularValorTotal()
        {
            ITaxaJurosServico    taxaServico    = new TaxaJurosServico();
            CalculoJurosDTO      calculoDTO     = new CalculoJurosDTO(100, 5, taxaServico.ObterTaxaJuros());
            ICalculoJurosServico calculoServico = new CalculoJurosServico();
            string valorJurosFormatado          = calculoServico.ObterValorCalculado(calculoDTO);

            Assert.Equal("105,10", valorJurosFormatado);
        }
        public void SistemaIncluiuEUtilizouCalculoEmMemoria()
        {
            ITaxaJurosServico    taxaServico    = new TaxaJurosServico();
            CalculoJurosDTO      calculoDTO     = new CalculoJurosDTO(100, 5, taxaServico.ObterTaxaJuros());
            ICalculoJurosServico calculoServico = new CalculoJurosServico();
            string valorJurosFormatado          = calculoServico.ObterValorCalculado(calculoDTO);

            Assert.Equal("105,10", valorJurosFormatado);
            Assert.Single(Banco.SelecionarCalculos());
            valorJurosFormatado = calculoServico.ObterValorCalculado(calculoDTO);
            Assert.Equal("105,10", valorJurosFormatado);
            Assert.Single(Banco.SelecionarCalculos());
        }
Пример #5
0
        public void Setup()
        {
            _fixture             = new Fixture();
            _valorTaxaDeJuros    = _fixture.Create <decimal>();
            _baseUrlApiTaxaJuros = _fixture.Create <string>();
            _taxaJuros           = _fixture.Build <dto.TaxaJuros>()
                                   .With(t => t.Valor, _valorTaxaDeJuros)
                                   .Create();

            _httpHelper        = new Mock <HttpHelper>(MockBehavior.Strict);
            _taxaDeJurosConfig = new Mock <TaxaJurosConfig>(MockBehavior.Strict);
            _taxaDeJurosConfig.SetupGet(t => t.BaseUrl)
            .Returns(_baseUrlApiTaxaJuros);

            _taxaJurosServico = new TaxaJurosServico(_taxaDeJurosConfig.Object, _httpHelper.Object);
        }
Пример #6
0
 public void Setup()
 {
     _taxaJurosServico = new TaxaJurosServico();
 }