public void UpdateTrendBreaks_WorksProperly_IfItemsAreOnlyAdded() { //Arrange 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 }); //Act clearTrendBreaksTables(); repository.UpdateTrendBreaks(trendBreaks); IEnumerable <TrendBreakDto> actualRecords = repository.GetTrendBreaks(1); //Assert Assert.IsTrue(repository.GetTrendBreaks(1).HasEqualItems(new TrendBreakDto[] { dto1, dto2, dto3 })); Assert.IsTrue(repository.GetTrendBreaks(2).HasEqualItems(new TrendBreakDto[] { dto4 })); }
public void UpdateTrendBreaks_WorksProperly_IfItemsAreAddedAndUpdated() { //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 }); clearTrendBreaksTables(); repository.UpdateTrendBreaks(trendBreaks); //Act dto1.NextRangeGuid = System.Guid.NewGuid().ToString(); dto2.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 GetTrendBreaks_returnProperDtoCollection() { //Arrange EFTrendlineRepository repository = new EFTrendlineRepository(); TrendBreakDto[] breaks = getDefaultTrendBreakDtosArray(); clearTrendBreaksTables(); repository.UpdateTrendBreaks(breaks); //Act IEnumerable <TrendBreakDto> dtos = repository.GetTrendBreaks(1).ToArray(); //Assert IEnumerable <TrendBreakDto> expected = new TrendBreakDto[] { breaks[0], breaks[1], breaks[2] }; bool areEqualArrays = expected.HasEqualItems(dtos); Assert.IsTrue(areEqualArrays); }