示例#1
0
        public void DeveRetornarParametro()
        {
            var expectativa = 0.01;
            var resultado   = _taxaJurosServico.RetorneTaxaJuros();

            Assert.AreEqual(expectativa, resultado);
        }
示例#2
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>());
        }