public void GetDataSetsWithInitialCollection_ReturnsNullArray_IfNullArrayWasPassedAndThereWereNoDataToBeAppended() { //Arrange IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { AnalysisType.Quotations, AnalysisType.Prices }; AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(UTDefaulter.DEFAULT_ASSET_ID, UTDefaulter.DEFAULT_TIMEFRAME_ID) { AnalysisTypes = analysisTypes }; Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); IEnumerable <PriceDto> priceDtos = utf.getDefaultPriceDtosCollection(); quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(new List <QuotationDto>()); priceRepository.Setup(p => p.GetPrices(queryDef)).Returns(priceDtos); //Act DataSet[] previous = new DataSet[] { }; IDataSetService service = new DataSetService(); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); var dataSets = service.GetDataSets(queryDef, previous).ToArray(); //Assert var isEmpty = (dataSets.Length == 0 || (dataSets.Length == 1 && dataSets[0] == null)); Assert.IsTrue(isEmpty); }
public void GetDataSets_ReturnsEmptyCollection_IfThereIsNoQuotationForGivenDateRange() { //Arrange IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { AnalysisType.Quotations, AnalysisType.Prices }; AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(UTDefaulter.DEFAULT_ASSET_ID, UTDefaulter.DEFAULT_TIMEFRAME_ID) { AnalysisTypes = analysisTypes }; Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); IEnumerable <PriceDto> priceDtos = utf.getDefaultPriceDtosCollection(); quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(new List <QuotationDto>()); priceRepository.Setup(q => q.GetPrices(queryDef)).Returns(priceDtos); //Act IDataSetService service = new DataSetService(); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); var dataSets = service.GetDataSets(queryDef); //Assert var isEmpty = (dataSets.Count() == 0); Assert.IsTrue(isEmpty); }
public void Clone_Afterward_NewInstanceHasEqualAllProperties() { //Arrange AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(DEFAULT_ASSET_ID, DEFAULT_TIMEFRAME_ID) { Limit = 100, StartIndex = 10, EndIndex = 150, SimulationId = 1, AnalysisTypes = new AnalysisType[] { AnalysisType.Prices } }; //Act AnalysisDataQueryDefinition clone = queryDef.Clone(); //Assert Assert.IsTrue(queryDef.AssetId == clone.AssetId); Assert.IsTrue(queryDef.TimeframeId == clone.TimeframeId); Assert.IsTrue(queryDef.SimulationId == clone.SimulationId); Assert.IsTrue(queryDef.Limit == clone.Limit); Assert.IsTrue(queryDef.StartDate == clone.StartDate); Assert.IsTrue(queryDef.StartIndex == clone.StartIndex); Assert.IsTrue(queryDef.EndDate == clone.EndDate); Assert.IsTrue(queryDef.EndIndex == clone.EndIndex); Assert.IsTrue(queryDef.AnalysisTypes.HasEqualItems(clone.AnalysisTypes)); }
public void GetDataSetsWithInitialCollection_ReturnsArrayWithoutChanges_IfNonEmptyArrayWasPassedAndThereWereNoDataToBeAppended() { //Arrange IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { AnalysisType.Quotations, AnalysisType.Prices }; AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(UTDefaulter.DEFAULT_ASSET_ID, UTDefaulter.DEFAULT_TIMEFRAME_ID) { AnalysisTypes = analysisTypes }; Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); IEnumerable <PriceDto> priceDtos = utf.getDefaultPriceDtosCollection(); quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(new List <QuotationDto>()); priceRepository.Setup(p => p.GetPrices(queryDef)).Returns(priceDtos); //Act DataSet[] baseDataSets = new DataSet[11]; baseDataSets[7] = utf.getDataSet(7); baseDataSets[8] = utf.getDataSet(8); baseDataSets[9] = utf.getDataSet(9); baseDataSets[10] = utf.getDataSet(10); IDataSetService service = new DataSetService(); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); var dataSets = service.GetDataSets(queryDef, baseDataSets).ToArray(); //Assert var areEqual = baseDataSets.HasEqualItemsInTheSameOrder(dataSets); Assert.IsTrue(areEqual); }
public void GetDataSets_DoesntOverrideExistingObjectsWithNulls_IfTheyAreNotInSpecificRepositories() { //Arrange:QueryDef IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { AnalysisType.Prices }; AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(UTDefaulter.DEFAULT_ASSET_ID, UTDefaulter.DEFAULT_TIMEFRAME_ID) { AnalysisTypes = analysisTypes }; //Arrange:Quotations Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); IEnumerable <QuotationDto> quotationDtos = new QuotationDto[] { utf.getQuotationDto(1), utf.getQuotationDto(2), utf.getQuotationDto(3), utf.getQuotationDto(4) }; quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(quotationDtos); //Arrange:Prices Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); IEnumerable <PriceDto> priceDtos = new PriceDto[] { utf.getPriceDto(1), utf.getPriceDto(2), utf.getPriceDto(3), utf.getPriceDto(4) }; priceRepository.Setup(p => p.GetPrices(queryDef)).Returns(priceDtos); //Act IDataSetService service = new DataSetService(); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); var dataSets = service.GetDataSets(queryDef); if (dataSets == null) { throw new Exception("Collection should not be null"); } DataSet baseDataSet = dataSets.SingleOrDefault(ds => ds.IndexNumber == 2); if (baseDataSet == null) { throw new Exception("Base data set shouldn't be null"); } Price basePrice = (baseDataSet == null ? null : baseDataSet.GetPrice()); if (basePrice == null) { throw new Exception("Base price shouldn't be null"); } priceRepository.Setup(q => q.GetPrices(queryDef)).Returns(new PriceDto[] { }); service.InjectPriceRepository(priceRepository.Object); dataSets = service.GetDataSets(queryDef); DataSet comparedDataSet = dataSets.SingleOrDefault(ds => ds.IndexNumber == 2); Price comparedPrice = (comparedDataSet == null ? null : comparedDataSet.GetPrice()); //Assert var areTheSameObject = (basePrice == comparedPrice); Assert.IsTrue(areTheSameObject); }
public void Clone_Afterward_NewInstanceIsDifferentObjectThanOriginal() { //Arrange AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(DEFAULT_ASSET_ID, DEFAULT_TIMEFRAME_ID); //Act AnalysisDataQueryDefinition clone = queryDef.Clone(); //Assert Assert.IsFalse(queryDef == clone); }
public void GetDataSets_ReturnsCollectionWithQuotationsOnly_IfGivenAnalysisTypesParameterIsInvalid() { //Arrange:QueryDef IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { }; AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(UTDefaulter.DEFAULT_ASSET_ID, UTDefaulter.DEFAULT_TIMEFRAME_ID) { AnalysisTypes = analysisTypes }; //Arrange:Quotations Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); IEnumerable <QuotationDto> quotationDtos = utf.getDefaultQuotationDtosCollection(); quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(quotationDtos); //Arrange:Prices Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); IEnumerable <PriceDto> priceDtos = utf.getDefaultPriceDtosCollection(); priceRepository.Setup(p => p.GetPrices(queryDef)).Returns(priceDtos); //Act IDataSetService service = new DataSetService(); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); var dataSets = service.GetDataSets(queryDef); //Assert DataSet ds1 = utf.getDataSet(1); ds1.SetQuotation(utf.getQuotation(ds1)); DataSet ds2 = utf.getDataSet(2); ds2.SetQuotation(utf.getQuotation(ds2)); DataSet ds3 = utf.getDataSet(3); ds3.SetQuotation(utf.getQuotation(ds3)); DataSet ds4 = utf.getDataSet(4); ds4.SetQuotation(utf.getQuotation(ds4)); IEnumerable <DataSet> expectedDataSets = new DataSet[] { ds1, ds2, ds3, ds4 }; var areEqual = expectedDataSets.HasEqualItems(dataSets); Assert.IsTrue(areEqual); }
public void GetDataSets_UseAlwaysExistingInstancesOfObjects_EvenIfThereIsAnotherOneInRepository() { //Arrange:QueryDef IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { AnalysisType.Prices }; AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(1, 1) { AnalysisTypes = analysisTypes }; //Arrange:Quotations Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); IEnumerable <QuotationDto> quotationDtos = new QuotationDto[] { utf.getQuotationDto(1), utf.getQuotationDto(2), utf.getQuotationDto(3), utf.getQuotationDto(4) }; quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(quotationDtos); //Arrange:Prices Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); IEnumerable <PriceDto> priceDtos = new PriceDto[] { utf.getPriceDto(1), utf.getPriceDto(2), utf.getPriceDto(3), utf.getPriceDto(4) }; priceRepository.Setup(p => p.GetPrices(queryDef)).Returns(priceDtos); //Act IDataSetService service = new DataSetService(); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); var dataSets = service.GetDataSets(queryDef); DataSet baseDataSet = dataSets.SingleOrDefault(ds => ds.IndexNumber == 2); Quotation stubQuotation = utf.getQuotation(2); stubQuotation.Open = stubQuotation.Open + 3; IEnumerable <Quotation> quotations = new Quotation[] { utf.getQuotation(1), stubQuotation, utf.getQuotation(3), utf.getQuotation(4) }; quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(quotationDtos); service.InjectQuotationRepository(quotationRepository.Object); dataSets = service.GetDataSets(queryDef); DataSet comparedDataSet = dataSets.SingleOrDefault(ds => ds.IndexNumber == 2); //Assert var areTheSameObject = (baseDataSet.GetQuotation() == comparedDataSet.GetQuotation()); Assert.IsTrue(areTheSameObject); }
public void GetDataSets_ReturnsCollectionWithoutSomeAnalysisType_IfThereIsNoDataForThisType() { //Arrange:QueryDef IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { AnalysisType.Prices }; AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(UTDefaulter.DEFAULT_ASSET_ID, UTDefaulter.DEFAULT_TIMEFRAME_ID) { AnalysisTypes = analysisTypes }; //Arrange:Quotations Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); IEnumerable <QuotationDto> quotationDtos = new QuotationDto[] { utf.getQuotationDto(2), utf.getQuotationDto(3), utf.getQuotationDto(4) }; quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(quotationDtos); //Arrange:Prices Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); IEnumerable <PriceDto> priceDtos = new PriceDto[] { utf.getPriceDto(3), utf.getPriceDto(4), utf.getPriceDto(5), utf.getPriceDto(6) }; priceRepository.Setup(p => p.GetPrices(queryDef)).Returns(priceDtos); //Act IDataSetService service = new DataSetService(); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); var dataSets = service.GetDataSets(queryDef); //Assert DataSet ds2 = utf.getDataSet(2); ds2.SetQuotation(utf.getQuotation(ds2)); DataSet ds3 = utf.getDataSet(3); ds3.SetQuotation(utf.getQuotation(ds3)).SetPrice(utf.getPrice(ds3)); DataSet ds4 = utf.getDataSet(4); ds4.SetQuotation(utf.getQuotation(ds4)).SetPrice(utf.getPrice(ds4)); IEnumerable <DataSet> expectedDataSets = new DataSet[] { ds2, ds3, ds4 }; var areEqual = expectedDataSets.HasEqualItems(dataSets); Assert.IsTrue(areEqual); }
public void UpdateTrendRanges_WorksProperly_IfItemsAreAddedAndUpdated() { //Arrange AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(1, 1); EFTrendlineRepository repository = new EFTrendlineRepository(); TrendRangeDto[] trendRanges = getDefaultTrendRangeDtosArray(); clearTrendRangesTables(); repository.UpdateTrendRanges(new TrendRangeDto[] { trendRanges[0], trendRanges[1] }); //Act trendRanges[0].NextBreakGuid = System.Guid.NewGuid().ToString(); trendRanges[1].NextBreakGuid = System.Guid.NewGuid().ToString(); repository.UpdateTrendRanges(trendRanges); //Assert Assert.IsTrue(repository.GetTrendRanges(1).HasEqualItems(new TrendRangeDto[] { trendRanges[0], trendRanges[1], trendRanges[2] })); Assert.IsTrue(repository.GetTrendRanges(2).HasEqualItems(new TrendRangeDto[] { trendRanges[3] })); }
public void GetDataSetsWithInitialCollection_ReturnsProperlyFilledAndIndexedArray_IfNullArrayWasPassedAndSomeDataWereAppended() { //Arrange IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { AnalysisType.Quotations, AnalysisType.Prices }; AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(UTDefaulter.DEFAULT_ASSET_ID, UTDefaulter.DEFAULT_TIMEFRAME_ID) { AnalysisTypes = analysisTypes }; Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); //Act IDataSetService service = new DataSetService(); IEnumerable <QuotationDto> quotationDtos = new QuotationDto[] { utf.getQuotationDto(101), utf.getQuotationDto(102), utf.getQuotationDto(103) }; quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(quotationDtos); IEnumerable <PriceDto> priceDtos = new PriceDto[] { utf.getPriceDto(101), utf.getPriceDto(102), utf.getPriceDto(103) }; priceRepository.Setup(q => q.GetPrices(queryDef)).Returns(priceDtos); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); DataSet[] result = service.GetDataSets(queryDef, new List <DataSet>()).ToArray(); //Assert DataSet[] expectedDataSets = new DataSet[104]; DataSet ds101 = utf.getDataSet(101); ds101.SetQuotation(utf.getQuotation(ds101)).SetPrice(utf.getPrice(ds101)); DataSet ds102 = utf.getDataSet(102); ds102.SetQuotation(utf.getQuotation(ds102)).SetPrice(utf.getPrice(ds102)); DataSet ds103 = utf.getDataSet(103); ds103.SetQuotation(utf.getQuotation(ds103)).SetPrice(utf.getPrice(ds103)); expectedDataSets[101] = ds101; expectedDataSets[102] = ds102; expectedDataSets[103] = ds103; var areEqual = expectedDataSets.HasEqualItemsInTheSameOrder(result); Assert.IsTrue(areEqual); }
public void UpdateAnalysisTimestamps_WorksProperly_IfItemsAreAddedAndUpdated() { //Arrange AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(1, 1); EFSimulationRepository repository = new EFSimulationRepository(); List <AnalysisTimestampDto> timestamps = new List <AnalysisTimestampDto>(); AnalysisTimestampDto dto1 = new AnalysisTimestampDto() { Id = 1, AssetId = 1, TimeframeId = 1, SimulationId = 1, AnalysisTypeId = 2, LastAnalysedItem = new DateTime(2017, 2, 4, 14, 15, 0), LastAnalysedIndex = 100 }; AnalysisTimestampDto dto2 = new AnalysisTimestampDto() { Id = 2, AssetId = 1, TimeframeId = 1, SimulationId = 1, AnalysisTypeId = 3, LastAnalysedItem = null, LastAnalysedIndex = null }; AnalysisTimestampDto dto3 = new AnalysisTimestampDto() { Id = 3, AssetId = 1, TimeframeId = 2, SimulationId = 1, AnalysisTypeId = 3, LastAnalysedItem = null, LastAnalysedIndex = null }; AnalysisTimestampDto dto4 = new AnalysisTimestampDto() { Id = 4, AssetId = 1, TimeframeId = 2, SimulationId = 1, AnalysisTypeId = 2, LastAnalysedItem = new DateTime(2017, 2, 4, 14, 15, 0), LastAnalysedIndex = 100 }; timestamps.AddRange(new AnalysisTimestampDto[] { dto1, dto2, dto3 }); clearSimulationsTables(); repository.UpdateAnalysisTimestamps(timestamps); //Act dto3.AnalysisTypeId += 4; dto2.SimulationId++; IEnumerable <AnalysisTimestampDto> expectedRecords = new AnalysisTimestampDto[] { dto1, dto2, dto3, dto4 }; repository.UpdateAnalysisTimestamps(expectedRecords); IEnumerable <AnalysisTimestampDto> actualRecords = repository.GetAnalysisTimestamps(); //Assert bool areEqual = expectedRecords.HasEqualItems(actualRecords); Assert.IsTrue(areEqual); }
public void UpdateSimulations_WorksProperly_IfItemsAreAddedAndUpdated() { //Arrange AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(1, 1); EFSimulationRepository repository = new EFSimulationRepository(); List <SimulationDto> simulations = new List <SimulationDto>(); SimulationDto dto1 = new SimulationDto() { Id = 1, Name = "a" }; SimulationDto dto2 = new SimulationDto() { Id = 2, Name = "b" }; SimulationDto dto3 = new SimulationDto() { Id = 3, Name = "c" }; SimulationDto dto4 = new SimulationDto() { Id = 4, Name = "d" }; simulations.AddRange(new SimulationDto[] { dto1, dto2, dto3 }); clearSimulationsTables(); repository.UpdateSimulations(simulations); //Act dto1.Name = "x"; dto2.Name += "b"; IEnumerable <SimulationDto> expectedRecords = new SimulationDto[] { dto1, dto2, dto3, dto4 }; repository.UpdateSimulations(expectedRecords); IEnumerable <SimulationDto> actualRecords = repository.GetSimulations(); //Assert bool areEqual = expectedRecords.HasEqualItems(actualRecords); Assert.IsTrue(areEqual); }
public void GetDataSets_ReturnsCollectionWithExistingItems() { //Arrange:QueryDef IEnumerable <AnalysisType> analysisTypes = new AnalysisType[] { AnalysisType.Prices }; DateTime startDate = new DateTime(2016, 1, 15, 22, 30, 0); DateTime endDate = new DateTime(2016, 1, 15, 22, 50, 0); AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(1, 1) { AnalysisTypes = analysisTypes, StartDate = startDate, EndDate = endDate }; //Arrange:Quotations Mock <IQuotationRepository> quotationRepository = new Mock <IQuotationRepository>(); IEnumerable <QuotationDto> quotationDtos = new QuotationDto[] { utf.getQuotationDto(1), utf.getQuotationDto(2), utf.getQuotationDto(3), utf.getQuotationDto(4) }; quotationRepository.Setup(q => q.GetQuotations(queryDef)).Returns(quotationDtos); //Arrange:Prices Mock <IPriceRepository> priceRepository = new Mock <IPriceRepository>(); IEnumerable <PriceDto> priceDtos = new PriceDto[] { utf.getPriceDto(1), utf.getPriceDto(2), utf.getPriceDto(3), utf.getPriceDto(4) }; priceRepository.Setup(p => p.GetPrices(queryDef)).Returns(priceDtos); //Act IDataSetService service = new DataSetService(); service.InjectQuotationRepository(quotationRepository.Object); service.InjectPriceRepository(priceRepository.Object); var dataSets = service.GetDataSets(queryDef); DataSet baseDataSet = dataSets.SingleOrDefault(ds => ds.IndexNumber == 1); queryDef.StartDate = new DateTime(2016, 1, 15, 22, 25, 0); dataSets = service.GetDataSets(queryDef); DataSet comparedDataSet = dataSets.SingleOrDefault(ds => ds.IndexNumber == 1); //Assert var areTheSameObject = (baseDataSet == comparedDataSet); Assert.IsTrue(areTheSameObject); }
public void UpdateTrendlines_WorksProperly_IfItemsAreAddedAndUpdated() { //Arrange AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(1, 1); EFTrendlineRepository repository = new EFTrendlineRepository(); List <TrendlineDto> trendlines = new List <TrendlineDto>(); TrendlineDto dto1 = new TrendlineDto() { Id = 1, AssetId = 1, TimeframeId = 1, SimulationId = 1, StartIndex = 5, StartLevel = 1.2345, FootholdIndex = 26, FootholdLevel = 1.3456, Value = 1.234, LastUpdateIndex = 31 }; TrendlineDto dto2 = new TrendlineDto() { Id = 2, AssetId = 1, TimeframeId = 1, SimulationId = 1, StartIndex = 6, StartLevel = 1.4567, FootholdIndex = 23, FootholdLevel = 1.5678, Value = 1.345, LastUpdateIndex = 29 }; TrendlineDto dto3 = new TrendlineDto() { Id = 3, AssetId = 1, TimeframeId = 1, SimulationId = 2, StartIndex = 12, StartLevel = 1.5678, FootholdIndex = 45, FootholdLevel = 1.6789, Value = 1.567, LastUpdateIndex = 47 }; TrendlineDto dto4 = new TrendlineDto() { Id = 4, AssetId = 1, TimeframeId = 1, SimulationId = 2, StartIndex = 8, StartLevel = 1.6789, FootholdIndex = 21, FootholdLevel = 1.7891, Value = 1.678, LastUpdateIndex = 29 }; trendlines.AddRange(new TrendlineDto[] { dto1, dto2 }); clearTrendlinesTables(); repository.UpdateTrendlines(trendlines); //Act dto1.Value = 2.345; dto2.LastUpdateIndex += 2; dto2.Value += 0.250; dto2.LastUpdateIndex = 32; repository.UpdateTrendlines(new TrendlineDto[] { dto1, dto2, dto3, dto4 }); //Assert Assert.IsTrue(repository.GetTrendlines(1, 1, 1).HasEqualItems(new TrendlineDto[] { dto1, dto2 })); Assert.IsTrue(repository.GetTrendlines(1, 1, 2).HasEqualItems(new TrendlineDto[] { dto3, dto4 })); }
public void UpdateTrendBreaks_WorksProperly_IfItemsAreOnlyUpdated() { //Arrange AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(1, 1); EFTrendlineRepository repository = new EFTrendlineRepository(); List <TrendBreakDto> trendBreaks = new List <TrendBreakDto>(); TrendBreakDto dto1 = new TrendBreakDto() { Id = 1, Guid = "AC180C9B-E6D2-4138-8E0A-BE31FCE8626D", TrendlineId = 1, IndexNumber = 2, PreviousRangeGuid = null, NextRangeGuid = "89BFF378-F310-4A28-B753-00A0FF9A852C" }; TrendBreakDto dto2 = new TrendBreakDto() { Id = 2, Guid = "89BFF378-F310-4A28-B753-00A0FF9A852C", TrendlineId = 1, IndexNumber = 9, PreviousRangeGuid = "AC180C9B-E6D2-4138-8E0A-BE31FCE8626D", NextRangeGuid = "A62DB207-FDDA-45B4-94F6-AE16F4CA9A58" }; TrendBreakDto dto3 = new TrendBreakDto() { Id = 3, Guid = "A62DB207-FDDA-45B4-94F6-AE16F4CA9A58", TrendlineId = 1, IndexNumber = 18, PreviousRangeGuid = "89BFF378-F310-4A28-B753-00A0FF9A852C", NextRangeGuid = "89BFF378-F310-4A28-B753-00A0FF9A852C" }; TrendBreakDto dto4 = new TrendBreakDto() { Id = 4, Guid = "562BED90-29F8-423E-8D00-DE699C1D14C3", TrendlineId = 2, IndexNumber = 21, PreviousRangeGuid = "A62DB207-FDDA-45B4-94F6-AE16F4CA9A58", NextRangeGuid = null }; trendBreaks.AddRange(new TrendBreakDto[] { dto1, dto2, dto3, dto4 }); clearTrendBreaksTables(); repository.UpdateTrendBreaks(trendBreaks); //Act dto1.NextRangeGuid = System.Guid.NewGuid().ToString(); dto2.NextRangeGuid = System.Guid.NewGuid().ToString(); dto3.NextRangeGuid = System.Guid.NewGuid().ToString(); repository.UpdateTrendBreaks(new TrendBreakDto[] { dto1, dto2, dto3, dto4 }); //Assert Assert.IsTrue(repository.GetTrendBreaks(1).HasEqualItems(new TrendBreakDto[] { dto1, dto2, dto3 })); Assert.IsTrue(repository.GetTrendBreaks(2).HasEqualItems(new TrendBreakDto[] { dto4 })); }
public void UpdateTrendHits_WorksProperly_IfItemsAreAddedAndUpdated() { //Arrange AnalysisDataQueryDefinition queryDef = new AnalysisDataQueryDefinition(1, 1); EFTrendlineRepository repository = new EFTrendlineRepository(); List <TrendHitDto> trendlines = new List <TrendHitDto>(); TrendHitDto dto1 = new TrendHitDto() { Id = 1, Guid = "AC180C9B-E6D2-4138-8E0A-BE31FCE8626D", TrendlineId = 1, IndexNumber = 2, ExtremumType = 1, Value = 1.234, DistanceToLine = 0.0004, PreviousRangeGuid = null, NextRangeGuid = "89BFF378-F310-4A28-B753-00A0FF9A852C" }; TrendHitDto dto2 = new TrendHitDto() { Id = 2, Guid = "89BFF378-F310-4A28-B753-00A0FF9A852C", TrendlineId = 1, IndexNumber = 9, ExtremumType = 2, Value = 1.345, DistanceToLine = 0.0007, PreviousRangeGuid = "AC180C9B-E6D2-4138-8E0A-BE31FCE8626D", NextRangeGuid = "A62DB207-FDDA-45B4-94F6-AE16F4CA9A58" }; TrendHitDto dto3 = new TrendHitDto() { Id = 3, Guid = "A62DB207-FDDA-45B4-94F6-AE16F4CA9A58", TrendlineId = 1, IndexNumber = 18, ExtremumType = 2, Value = 1.567, DistanceToLine = 0.0002, PreviousRangeGuid = "89BFF378-F310-4A28-B753-00A0FF9A852C", NextRangeGuid = "89BFF378-F310-4A28-B753-00A0FF9A852C" }; TrendHitDto dto4 = new TrendHitDto() { Id = 4, Guid = "562BED90-29F8-423E-8D00-DE699C1D14C3", TrendlineId = 2, IndexNumber = 21, ExtremumType = 3, Value = 1.678, DistanceToLine = 0.0001, PreviousRangeGuid = "A62DB207-FDDA-45B4-94F6-AE16F4CA9A58", NextRangeGuid = null }; trendlines.AddRange(new TrendHitDto[] { dto1, dto2, dto3, dto4 }); clearTrendHitsTables(); repository.UpdateTrendHits(trendlines); //Act dto1.Value = 2.345; dto1.DistanceToLine += 0.002; dto2.Value += 0.250; dto1.DistanceToLine -= 0.002; repository.UpdateTrendHits(new TrendHitDto[] { dto1, dto2, dto3, dto4 }); //Assert Assert.IsTrue(repository.GetTrendHits(1).HasEqualItems(new TrendHitDto[] { dto1, dto2, dto3 })); Assert.IsTrue(repository.GetTrendHits(2).HasEqualItems(new TrendHitDto[] { dto4 })); }
public IEnumerable <ExtremumDto> GetExtrema(AnalysisDataQueryDefinition queryDef) { return(null); }
public IEnumerable <PriceDto> GetPrices(AnalysisDataQueryDefinition queryDef) { return(null); }
public IEnumerable <QuotationDto> GetQuotations(AnalysisDataQueryDefinition queryDef) { return(null); }