public async Task Deve_Retornar_Taxa()
        {
            // Arrange
            var taxaApiSettings = Options.Create(new TaxaApiSettings());

            taxaApiSettings.Value.Url = "http://teste.com";

            var handlerMock = new Mock <HttpMessageHandler>();
            var response    = new HttpResponseMessage
            {
                StatusCode = HttpStatusCode.OK,
                Content    = new StringContent(@"{ ""taxa"": 0.01 }"),
            };

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

            var httpClient = new HttpClient(handlerMock.Object);

            var taxaServices = new TaxaJurosServices
                                   (httpClient, taxaApiSettings);

            // Act
            var resultado = await taxaServices.BuscaTaxa(CancellationToken.None);

            // Assert
            Assert.True(resultado.IsSuccess);
            Assert.Equal(0.01m, resultado.Value);
        }
        public async void Validar_Retorno_TaxaJuros()
        {
            mockTaxaJurosRepository.Setup(x => x.GetTaxaJuros()).Returns(Task.FromResult(new TaxaJuros()));
            TaxaJurosServices taxaJurosServices = new TaxaJurosServices(mockTaxaJurosRepository.Object, mockMemoryCache.Object);

            await taxaJurosServices.GetTaxaJuros();

            mockTaxaJurosRepository.Verify(mock => mock.GetTaxaJuros(), Times.Once());
        }
Пример #3
0
        public void ValidaTipoGetTaxaJuros()
        {
            Juros taxaJuros = new Juros()
            {
                TaxaJuros = "0,01"
            };

            TaxaJurosServices objGetTaxaJuros = new TaxaJurosServices();

            Assert.IsType <Juros>(objGetTaxaJuros.GetTaxaJuros());
        }
Пример #4
0
        public void RetornarGetTaxaJuros()
        {
            Juros taxaJuros = new Juros()
            {
                TaxaJuros = "0,01"
            };

            TaxaJurosServices objGetTaxaJuros = new TaxaJurosServices();

            Assert.Equal(taxaJuros.TaxaJuros, objGetTaxaJuros.GetTaxaJuros().TaxaJuros);
        }