public void ParsingError_Test()
        {
            var json    = File.ReadAllText("Data/bad-data.json");
            var jObject = (JObject)JsonConvert.DeserializeObject(json);

            var parser = new StockDataParser();

            Assert.Throws <StocksParsingException>(() => parser.ParseTimeSeries(jObject));
        }
示例#2
0
        private async Task <StockTimeSeries> RequestTimeSeriesAsync(
            ApiFunction function,
            Dictionary <string, string> query)
        {
            var jObject = await _coreClient.RequestApiAsync(_apiKey, function, query);

            var timeSeries = _parser.ParseTimeSeries(jObject);

            return(timeSeries);
        }
        public void WeeklyAdjusted_ParsingTest()
        {
            var json    = File.ReadAllText("Data/weekly-adjusted.json");
            var jObject = (JObject)JsonConvert.DeserializeObject(json);

            var parser = new StockDataParser();
            var result = parser.ParseTimeSeries(jObject);

            Assert.NotNull(result);
            Assert.Equal(TimeSeriesType.Weekly, result.Type);
            Assert.True(result.IsAdjusted);
            Assert.Equal(3, result.DataPoints.Count);
            foreach (var resultDataPoint in result.DataPoints)
            {
                Assert.IsType <StockAdjustedDataPoint>(resultDataPoint);
            }
        }
示例#4
0
        public void DailyNotAdjusted_ParsingTest()
        {
            var json    = File.ReadAllText("Data/daily-not-adjusted.json");
            var jObject = (JObject)JsonConvert.DeserializeObject(json);

            var parser = new StockDataParser();
            var result = parser.ParseTimeSeries(jObject);

            Assert.NotNull(result);
            Assert.Equal(TimeSeriesType.Daily, result.Type);
            Assert.False(result.IsAdjusted);
            Assert.Equal(3, result.DataPoints.Count);
            foreach (var resultDataPoint in result.DataPoints)
            {
                Assert.IsType(typeof(StockDataPoint), resultDataPoint);
                Assert.IsNotType(typeof(StockAdjustedDataPoint), resultDataPoint);
            }
        }