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 GetTrendRangeById_ReturnsNull_IfThereIsNoTrendlineWithSuchId()
        {
            //Arrange
            EFTrendlineRepository repository = new EFTrendlineRepository();

            TrendRangeDto[] ranges = getDefaultTrendRangeDtosArray();
            clearTrendRangesTables();
            repository.UpdateTrendRanges(ranges);

            //Act
            TrendRangeDto resultDto = repository.GetTrendRangeById(50);

            //Assert
            Assert.IsNull(resultDto);
        }
        public void UpdateTrendRanges_WorksProperly_IfItemsAreOnlyAdded()
        {
            //Arrange
            EFTrendlineRepository repository = new EFTrendlineRepository();

            TrendRangeDto[] trendRanges = getDefaultTrendRangeDtosArray();

            //Act
            clearTrendRangesTables();
            repository.UpdateTrendRanges(trendRanges);
            IEnumerable <TrendRangeDto> actualRecords = repository.GetTrendRanges(1);

            //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 GetTrendRanges_returnProperDtoCollection()
        {
            //Arrange
            EFTrendlineRepository repository = new EFTrendlineRepository();

            TrendRangeDto[] ranges = getDefaultTrendRangeDtosArray();
            clearTrendRangesTables();
            repository.UpdateTrendRanges(ranges);

            //Act
            IEnumerable <TrendRangeDto> dtos = repository.GetTrendRanges(1).ToArray();

            //Assert
            IEnumerable <TrendRangeDto> expected = new TrendRangeDto[] { ranges[0], ranges[1], ranges[2] };
            bool areEqualArrays = expected.HasEqualItems(dtos);

            Assert.IsTrue(areEqualArrays);
        }
        public void GetTrendRangeById_ReturnsProperTrendlineDto_IfExists()
        {
            //Arrange
            EFTrendlineRepository repository  = new EFTrendlineRepository();
            List <TrendRangeDto>  trendBreaks = new List <TrendRangeDto>();
            TrendRangeDto         expectedDto = getDefaultTrendRangeDto();

            trendBreaks.AddRange(new TrendRangeDto[] { expectedDto });
            clearTrendRangesTables();
            repository.UpdateTrendRanges(trendBreaks);

            //Act
            TrendRangeDto resultDto = repository.GetTrendRangeById(expectedDto.Id);

            //Assert
            var areEqual = expectedDto.Equals(resultDto);

            Assert.IsTrue(areEqual);
        }