示例#1
0
 public CoinMarketCapExchangeRatesWebService(
     IHttpClientFactory httpClientFactory,
     CoinMarketCapWebServiceConfiguration configuration)
 {
     _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
     _configuration     = configuration ?? throw new ArgumentNullException(nameof(configuration));
     _configuration.Validate();
 }
        public void Fails_the_validation_when_base_URL_is_absent()
        {
            var configuration = new CoinMarketCapWebServiceConfiguration
            {
                ApiKey = SampleApiKeyValue
            };

            Action validateConfiguration = () => configuration.Validate();

            validateConfiguration.Should().ThrowExactly <InvalidOperationException>();
        }
        public void Passes_the_validation_when_all_values_are_valid()
        {
            var configuration = new CoinMarketCapWebServiceConfiguration
            {
                BaseUrl = CoinMarketCapExchangeRatesWebServiceBaseUrl,
                ApiKey  = SampleApiKeyValue
            };

            Action validateConfiguration = () => configuration.Validate();

            validateConfiguration.Should().NotThrow();
        }
        public void Fails_the_validation_when_API_key_is_blank(string apiKey)
        {
            var configuration = new CoinMarketCapWebServiceConfiguration
            {
                BaseUrl = CoinMarketCapExchangeRatesWebServiceBaseUrl,
                ApiKey  = apiKey
            };

            Action validateConfiguration = () => configuration.Validate();

            validateConfiguration.Should().ThrowExactly <InvalidOperationException>();
        }
示例#5
0
        public CoinMarketCapExchangeRatesWebServiceTests()
        {
            _mockServer = WireMockServer.Start();

            var configuration = new CoinMarketCapWebServiceConfiguration
            {
                BaseUrl = new Uri(_mockServer.Urls.First()),
                ApiKey  = SampleApiKeyValue
            };

            _exchangeRatesService = QuotesServicesFactory.Infrastructure.ExchangeRatesService
                                    .CreateCoinMarketCapExchangeRatesWebService(CreateHttpClientFactory(), configuration);
        }
示例#6
0
 public IExchangeRatesService CreateCoinMarketCapExchangeRatesWebService(
     IHttpClientFactory httpClientFactory,
     CoinMarketCapWebServiceConfiguration configuration) =>
 new CoinMarketCapExchangeRatesWebService(httpClientFactory, configuration);