public void MapContentsToTrades_Always_ReturnExpectedResult() { var lines = new[] { "Date,Open,High,Low,Close,Volume,Adj Close", "9/8/2011,10,11,12,13,14,15", "9/7/2011,11,12,13,14,15,16" }; var result = sut.MapContentsToTrades(lines).ToList(); result.Should().BeEquivalentTo(new List <StockQuote> { new StockQuote { Date = new DateTime(2011, 9, 8), Open = 10, High = 11, Low = 12, Close = 13 }, new StockQuote { Date = new DateTime(2011, 9, 7), Open = 11, High = 12, Low = 13, Close = 14 } }); }
public void MapContentsToTrades_Always_ReturnExpectedResult() { var jsonBlob = "[{\"Date\":\"1/2/2019\",\"Open\":1,\"High\":2,\"Low\":1,\"Close\":2},{\"Date\":\"1/1/2019\",\"Open\":3,\"High\":3,\"Low\":3,\"Close\":3}]"; var result = sut.MapContentsToTrades(jsonBlob); result.Should().BeEquivalentTo( new List <StockQuote> { new StockQuote { Date = new DateTime(2019, 1, 2), Open = 1, High = 2, Low = 1, Close = 2 }, new StockQuote { Date = new DateTime(2019, 1, 1), Open = 3, High = 3, Low = 3, Close = 3 }, }); }
public IEnumerable <StockQuote> GetStockQuotes(string sourcePath) { if (!fileWrapper.Exists(sourcePath)) { throw new InvalidOperationException("File does not exist"); } var lines = fileWrapper.ReadAllLines(sourcePath); return(contentMapper.MapContentsToTrades(lines).ToList()); }
public IEnumerable <StockQuote> GetStockQuotes(string sourcePath) { Func <string, Task <string> > download = async url => await GetJsonBlobAsync(url); Func <string, Func <Task <string> > > downloadCurry = download.Curry(); //var jsonBlob = download.Partial(sourcePath).WithRetry().Result; var jsonBlob = downloadCurry(sourcePath).WithRetry().Result; if (string.IsNullOrWhiteSpace(jsonBlob)) { throw new ArgumentNullException("Source is empty!"); } return(contentMapper.MapContentsToTrades(jsonBlob)); }