public void InsertNewQuotesToDbTest() { this.BuildCalcuatorFactory(); var latestDataPointDate = monday.AddDays(1); this.dataPointRepo.Setup(m => m.FindLatestDataPointDateForSymbol("SGP.L")).Returns(latestDataPointDate); this.yahooServiceClient.Setup(m => m.GetQuotes("SGP.L")).Returns(TestQuotes); var service = new DataPointManagementService(this.dataPointRepo.Object, this.yahooServiceClient.Object, this.calculatorFactory.Object); service.InsertNewQuotesToDb("SGP.L"); var expectedDataPoints = TestQuotes.Where(q => q.Date > latestDataPointDate).Select(DataPoints.CreateFromQuote).ToList(); for (var i = 0; i <= 4; i++) { this.dataPointRepo.Verify(m => m.InsertAll(It.Is<List<DataPoints>>(d => d[i].Equals(expectedDataPoints[i])))); } }
public void QuotesFoundButUpToDateDbTest() { this.dataPointRepo.Setup(m => m.FindLatestDataPointDateForSymbol("SGP.L")).Returns(monday.AddDays(6)); this.yahooServiceClient.Setup(m => m.GetQuotes("SGP.L")).Returns(TestQuotes); var service = new DataPointManagementService(this.dataPointRepo.Object, this.yahooServiceClient.Object, this.calculatorFactory.Object); service.InsertNewQuotesToDb("SGP.L"); this.dataPointRepo.Verify(m => m.InsertAll(It.IsAny<IEnumerable<DataPoints>>()), Times.Never); }
public void TestUpdate() { this.BuildCalcuatorFactory(); this.dataPointRepo.Setup(f => f.FindAll("SGP.L")).Returns(TestDataPoints); var service = new DataPointManagementService(this.dataPointRepo.Object, this.yahooServiceClient.Object, this.calculatorFactory.Object); service.FillInMissingProcessedData("SGP.L"); var expectedDatapointsUpdated = new List<DataPoints> { new DataPoints { Symbol = "SGP.L", Date = monday.AddDays(7), Open = 1m, Close = 2m, High = 3m, Low = 1m, Volume = 100, MovingAverageTwoHundredDay = 6m, MovingAverageFiftyDay = 7, MovingAverageTwentyDay = 8, LowerBollingerBandTwoDeviation = 9, UpperBollingerBandTwoDeviation = 10, ForceIndexOnePeriod = 11m, ForceIndexThirteenPeriod = 12m, IsProcessed = 1 }, new DataPoints { Symbol = "SGP.L", Date = monday.AddDays(8), Open = 1m, Close = 2m, High = 3m, Low = 1m, Volume = 100, MovingAverageTwoHundredDay = 7m, MovingAverageFiftyDay = 8m, MovingAverageTwentyDay = 9, LowerBollingerBandTwoDeviation = 10, UpperBollingerBandTwoDeviation = 11, ForceIndexOnePeriod = 12m, ForceIndexThirteenPeriod = 13m, IsProcessed = 1 }, }; this.dataPointRepo.Verify(f => f.UpdateAll(It.Is<List<DataPoints>>(c => c.Count == 2))); this.dataPointRepo.Verify(f => f.UpdateAll(It.Is<List<DataPoints>>(c => c[0].Equals(expectedDatapointsUpdated[0])))); this.dataPointRepo.Verify(f => f.UpdateAll(It.Is<List<DataPoints>>(c => c[1].Equals(expectedDatapointsUpdated[1])))); }