public void GetTrendHits_returnProperDtoCollection() { //Arrange EFTrendlineRepository repository = new EFTrendlineRepository(); List <TrendHitDto> trendHits = new List <TrendHitDto>(); TrendHitDto dto1 = new TrendHitDto() { Id = 1, Guid = "0BF8E6BD-0C8D-43B4-A9A0-C8B2745502B0", TrendlineId = 1, IndexNumber = 10, ExtremumType = 1, DistanceToLine = 0.0005, PreviousRangeGuid = null, NextRangeGuid = "07ACE1F3-89B4-49C5-A6F9-155B78E33836" }; TrendHitDto dto2 = new TrendHitDto() { Id = 2, Guid = "07ACE1F3-89B4-49C5-A6F9-155B78E33836", TrendlineId = 1, IndexNumber = 31, ExtremumType = 2, DistanceToLine = 0.0003, PreviousRangeGuid = "0BF8E6BD-0C8D-43B4-A9A0-C8B2745502B0", NextRangeGuid = "15AB46D1-615A-46FA-9533-A2DC3EA4F340" }; TrendHitDto dto3 = new TrendHitDto() { Id = 3, Guid = "15AB46D1-615A-46FA-9533-A2DC3EA4F340", TrendlineId = 1, IndexNumber = 31, ExtremumType = 2, DistanceToLine = 0.0003, PreviousRangeGuid = "07ACE1F3-89B4-49C5-A6F9-155B78E33836", NextRangeGuid = "B49C3C3E-0D42-451F-B2FD-F28A1679BF50" }; TrendHitDto dto4 = new TrendHitDto() { Id = 4, Guid = "B49C3C3E-0D42-451F-B2FD-F28A1679BF50", TrendlineId = 2, IndexNumber = 31, ExtremumType = 2, DistanceToLine = 0.0003, PreviousRangeGuid = "15AB46D1-615A-46FA-9533-A2DC3EA4F341", NextRangeGuid = null }; trendHits.AddRange(new TrendHitDto[] { dto1, dto2, dto3, dto4 }); clearTrendHitsTables(); repository.UpdateTrendHits(trendHits); //Act IEnumerable <TrendHitDto> dtos = repository.GetTrendHits(1).ToArray(); //Assert IEnumerable <TrendHitDto> expected = new TrendHitDto[] { dto1, dto2, dto3 }; bool areEqualArrays = expected.HasEqualItems(dtos); Assert.IsTrue(areEqualArrays); }
public void UpdateTrendHits_WorksProperly_IfItemsAreOnlyAdded() { //Arrange 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 }); //Act clearTrendHitsTables(); repository.UpdateTrendHits(trendlines); IEnumerable <TrendHitDto> actualRecords = repository.GetTrendHits(1); //Assert Assert.IsTrue(repository.GetTrendHits(1).HasEqualItems(new TrendHitDto[] { dto1, dto2, dto3 })); Assert.IsTrue(repository.GetTrendHits(2).HasEqualItems(new TrendHitDto[] { dto4 })); }
public void GetTrendHitById_ReturnsNull_IfThereIsNoTrendlineWithSuchId() { //Arrange EFTrendlineRepository repository = new EFTrendlineRepository(); List <TrendHitDto> trendHits = new List <TrendHitDto>(); trendHits.AddRange(new TrendHitDto[] { getDefaultTrendHitDto() }); clearTrendHitsTables(); repository.UpdateTrendHits(trendHits); //Act TrendHitDto resultDto = repository.GetTrendHitById(DEFAULT_ID + 1); //Assert Assert.IsNull(resultDto); }
public void GetTrendHitById_ReturnsProperTrendlineDto_IfExists() { //Arrange EFTrendlineRepository repository = new EFTrendlineRepository(); List <TrendHitDto> trendHits = new List <TrendHitDto>(); TrendHitDto expectedDto = getDefaultTrendHitDto(); trendHits.AddRange(new TrendHitDto[] { expectedDto }); clearTrendHitsTables(); repository.UpdateTrendHits(trendHits); //Act TrendHitDto resultDto = repository.GetTrendHitById(expectedDto.Id); //Assert var areEqual = expectedDto.Equals(resultDto); Assert.IsTrue(areEqual); }