예제 #1
0
        public async Task GetExchange_OnCall_Success()
        {
            // Arrange
            var exchange = new GetExchangeResponse {
                BuyPrice = 30.0M, SellPrice = 40.0M
            };

            _mockExternalService.GetExchangeAsync(_target.CurrencyName)
            .Returns(Task.FromResult(exchange));

            // Act
            var result = await _target.GetExchange();

            // Assert
            Assert.IsNotNull(result);
        }
        public async Task GetExchangeAsync_OnDollar_Success()
        {
            // Arrange
            _currencyCode = "dolar";

            // Act
            var result = await _target.GetExchangeAsync(_currencyCode);

            // Assert
            Assert.IsNotNull(result);
        }
예제 #3
0
        public async Task <GetExchangeResponse> GetExchange()
        {
            GetExchangeResponse result = null;

            try
            {
                result = await _externalService.GetExchangeAsync(CurrencyName);
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, "Unhandled exception");
            }
            return(result);
        }