Esempio n. 1
0
        public async Task Returns_current_quotes_for_a_given_cryptocurrency_code()
        {
            var request = new CryptocurrencyQuotesRequest {
                CryptocurrencyCode = BTC
            };
            var expectedResponse = new CryptocurrencyQuotesResponse
            {
                BaseCryptocurrencyCode = BTC,
                Quotes = QuoteCurrencyDetailsOf(
                    (USD, BTC_to_USD),
                    (EUR, BTC_to_EUR),
                    (BRL, BTC_to_BRL),
                    (GBP, BTC_to_GBP),
                    (AUD, BTC_to_AUD))
            };

            _fakeExchangeRatesService.Setup(service =>
                                            service.GetQuotesFor(CurrencyCode.Of(BTC)))
            .ReturnsAsync(
                QuoteCurrenciesOf(
                    (USD, BTC_to_USD),
                    (EUR, BTC_to_EUR),
                    (BRL, BTC_to_BRL),
                    (GBP, BTC_to_GBP),
                    (AUD, BTC_to_AUD)));

            var response = await _useCase.Execute(request);

            response.Should().BeEquivalentTo(expectedResponse);
        }
        public async Task <CryptocurrencyQuotesResponse> Execute(CryptocurrencyQuotesRequest request)
        {
            if (request is null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            var baseCryptocurrencyCode = CurrencyCode.Of(request.CryptocurrencyCode);
            var quotes = await _exchangeRatesService.GetQuotesFor(baseCryptocurrencyCode);

            return(CryptocurrencyQuotesResponse.From(baseCryptocurrencyCode, quotes));
        }