Beispiel #1
0
        public void DataSourceRealTimeWithInternetPriceTest(Country country, string stockId)
        {
            IConfiguration config = TestServiceProvider.GetTestConfiguration();
            IStockQuoteDataSourceOperations operations = new StockQuoteDataSourceOperations();
            IStockQuoteParser      parser = new AlphaVantageParser();
            AlphaVantageDataSource source = new AlphaVantageDataSource(config, operations, parser);

            IStockQuoteFromDataSource quote = source.GetMostRecentQuoteAsync(country, stockId, WriteToErrorLogAction).Result;

            Assert.NotNull(quote);
            Assert.True(quote.IsValid);
        }
        public void GetMostRecentQuoteTest(Country country, string stockId)
        {
            IConfiguration        config      = TestServiceProvider.GetTestConfiguration();
            IStockQuoteProvider   provider    = new StockQuoteSourceProvider(config, country);
            IStockQuoteDataSource yahooSource = provider.GetStockDataSources().FirstOrDefault(a => a.Source == Contracts.StockQuoteSource.Yahoo);

            Assert.NotNull(yahooSource);

            IStockQuoteFromDataSource result = yahooSource.GetMostRecentQuoteAsync(country, stockId, WriteToErrorLogAction).Result;

            Assert.NotNull(result);
            Assert.True(result.IsValid);
        }
Beispiel #3
0
        public void DataSourceDailyFullOutputWithInternetTest(Country country, string stockId)
        {
            IConfiguration config = TestServiceProvider.GetTestConfiguration();

            DateTime start = DateTime.Now.AddDays(-600);
            DateTime end   = DateTime.Now.AddDays(-300);

            IStockQuoteDataSourceOperations operations = new StockQuoteDataSourceOperations();
            IStockQuoteParser      parser = new AlphaVantageParser();
            AlphaVantageDataSource source = new AlphaVantageDataSource(config, operations, parser);
            IReadOnlyList <IStockQuoteFromDataSource> quotes = source.GetHistoricalQuotesAsync(country, stockId, start, end, WriteToErrorLogAction).Result;

            Assert.NotNull(quotes);
            Assert.True(quotes.Count >= 206);

            foreach (IStockQuoteFromDataSource quote in quotes)
            {
                Assert.True(quote.IsValid);
            }
        }
        public void GetHistoricalQuotesTest(Country country, string stockId)
        {
            IConfiguration        config      = TestServiceProvider.GetTestConfiguration();
            IStockQuoteProvider   provider    = new StockQuoteSourceProvider(config, country);
            IStockQuoteDataSource yahooSource = provider.GetStockDataSources().FirstOrDefault(a => a.Source == Contracts.StockQuoteSource.Yahoo);

            Assert.NotNull(yahooSource);

            DateTime start = new DateTime(2018, 3, 12);
            DateTime end   = new DateTime(2018, 3, 16);

            IReadOnlyList <IStockQuoteFromDataSource> results = yahooSource.GetHistoricalQuotesAsync(country, stockId, start, end, WriteToErrorLogAction).Result;

            Assert.NotNull(results);
            Assert.Equal(5, results.Count);

            foreach (IStockQuoteFromDataSource data in results)
            {
                Assert.True(data.IsValid);
            }
        }