public void GetLastAnalyzedIndexes_ReturnsEmptyDictionary_IfNothingIsFound() { //Arrange Mock <ISimulationRepository> mockedRepository = new Mock <ISimulationRepository>(); mockedRepository.Setup(m => m.GetAnalysisTimestampsForSimulation(DEFAULT_SIMULATION_ID)).Returns(new List <AnalysisTimestampDto>()); //Act AnalysisTimestampService service = new AnalysisTimestampService(mockedRepository.Object); //Assert var result = service.GetLastAnalyzedIndexes(DEFAULT_ASSET_ID, DEFAULT_TIMEFRAME_ID, DEFAULT_SIMULATION_ID); Assert.AreEqual(0, result.Count); }
public void GetLastAnalyzedIndexes_ReturnsDictionaryWithProperItems() { //Arrange Mock <ISimulationRepository> mockedRepository = new Mock <ISimulationRepository>(); int lastQuotationIndex = 100; int lastPriceIndex = 84; int lastMacdIndex = 72; List <AnalysisTimestampDto> list = new List <AnalysisTimestampDto>(); list.Add(new AnalysisTimestampDto() { AssetId = 1, TimeframeId = 1, AnalysisTypeId = (int)AnalysisType.Quotations, Id = 7, SimulationId = DEFAULT_SIMULATION_ID, LastAnalysedItem = new DateTime(2017, 6, 4, 13, 0, 0), LastAnalysedIndex = lastQuotationIndex }); list.Add(new AnalysisTimestampDto() { AssetId = 1, TimeframeId = 2, AnalysisTypeId = (int)AnalysisType.Quotations, Id = 10, SimulationId = DEFAULT_SIMULATION_ID, LastAnalysedItem = new DateTime(2017, 6, 4, 15, 0, 0), LastAnalysedIndex = lastQuotationIndex + 2 }); list.Add(new AnalysisTimestampDto() { AssetId = 1, TimeframeId = 1, AnalysisTypeId = (int)AnalysisType.Prices, Id = 54, SimulationId = DEFAULT_SIMULATION_ID, LastAnalysedItem = new DateTime(2017, 6, 4, 11, 0, 0), LastAnalysedIndex = lastPriceIndex }); list.Add(new AnalysisTimestampDto() { AssetId = 1, TimeframeId = 1, AnalysisTypeId = (int)AnalysisType.Macd, Id = 57, SimulationId = DEFAULT_SIMULATION_ID, LastAnalysedItem = new DateTime(2017, 6, 4, 10, 0, 0), LastAnalysedIndex = lastMacdIndex }); mockedRepository.Setup(m => m.GetAnalysisTimestampsForSimulation(DEFAULT_SIMULATION_ID)).Returns(list); //Act AnalysisTimestampService service = new AnalysisTimestampService(mockedRepository.Object); //Assert var result = service.GetLastAnalyzedIndexes(DEFAULT_ASSET_ID, DEFAULT_TIMEFRAME_ID, DEFAULT_SIMULATION_ID); Assert.AreEqual(3, result.Count); int?returnedQuotationIndex; int?returnedPriceIndex; int?returnedMacdIndex; result.TryGetValue(AnalysisType.Quotations, out returnedQuotationIndex); result.TryGetValue(AnalysisType.Prices, out returnedPriceIndex); result.TryGetValue(AnalysisType.Macd, out returnedMacdIndex); Assert.AreEqual(lastQuotationIndex, returnedQuotationIndex); Assert.AreEqual(lastPriceIndex, returnedPriceIndex); Assert.AreEqual(lastMacdIndex, returnedMacdIndex); }