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)); }
public void Is_successfully_created_from_base_cryptocurrency_code_and_quotes_when_both_values_are_present() { var expectedCryptocurrencyQuotesResponse = new CryptocurrencyQuotesResponse { BaseCryptocurrencyCode = BTC, Quotes = new List <QuoteCurrencyDetails> { new QuoteCurrencyDetails { Code = USD, ExchangeRate = BTC_to_USD } } }; var cryptocurrencyQuotesResponse = CryptocurrencyQuotesResponse.From( CurrencyCode.Of(BTC), QuoteCurrenciesOf((USD, BTC_to_USD))); cryptocurrencyQuotesResponse.Should().BeEquivalentTo(expectedCryptocurrencyQuotesResponse); }
public void Requires_quotes_when_created_from_base_cryptocurrency_code_and_quotes() { Action createCryptocurrencyQuotesResponseFromBaseCryptocurrencyCodeAndQuotes = () => CryptocurrencyQuotesResponse.From(CurrencyCode.Of(BTC), null); createCryptocurrencyQuotesResponseFromBaseCryptocurrencyCodeAndQuotes.Should() .ThrowExactly <ArgumentNullException>() .Which.ParamName.Should().Be("quotes"); }
public void Requires_base_cryptocurrency_code_when_created_from_base_cryptocurrency_code_and_quotes() { Action createCryptocurrencyQuotesResponseFromBaseCryptocurrencyCodeAndQuotes = () => CryptocurrencyQuotesResponse.From(null, Enumerable.Empty <QuoteCurrency>()); createCryptocurrencyQuotesResponseFromBaseCryptocurrencyCodeAndQuotes.Should() .ThrowExactly <ArgumentNullException>() .Which.ParamName.Should().Be("baseCryptocurrencyCode"); }