/// <summary> /// In case of empty apiKey parameter the API key is retrieved from the config. /// </summary> public async void SuccessfulLoadDailyTest(string apiKey, string symbol) { var apiConfig = new ApiConfig { AlphaVantageApiKey = string.IsNullOrWhiteSpace(apiKey) ? _apiConfig.AlphaVantageApiKey : apiKey, MaxRetries = _apiConfig.MaxRetries, InitialDelay = _apiConfig.InitialDelay }; var service = new ExternalStockService(_httpClient, apiConfig, _logger); var result = await service.GetDailyStockData(symbol); Assert.NotEmpty(result); var first = result.First(); Assert.Equal(symbol, first.Symbol); Assert.True(first.Open > 0); Assert.True(first.High > 0); Assert.True(first.Low > 0); Assert.True(first.Close > 0); Assert.True(first.Volume > 0); }
/// <summary> /// In case of empty apiKey parameter the API key is retrieved from the config. /// </summary> public async void FailedLoadDailyTest(string apiKey, string symbol) { var apiConfig = new ApiConfig { AlphaVantageApiKey = string.IsNullOrWhiteSpace(apiKey) ? _apiConfig.AlphaVantageApiKey : apiKey, MaxRetries = 1, InitialDelay = 0 }; var service = new ExternalStockService(_httpClient, apiConfig, _logger); await Assert.ThrowsAsync <Exception>( async() => await service.GetDailyStockData(symbol) ); }