Ejemplo n.º 1
0
        public void MaxRowsToGet_InitialCounterEqualsReadedRows_ReturnZero()
        {
            var initialCounter = 250;

            var result = RowsHelper.MaxRowsToGet(250, ref initialCounter);

            result.Should().Be(0);
            initialCounter.Should().Be(250);
        }
Ejemplo n.º 2
0
        public void MaxRowsToGet_ReadedRowsGreaterThanInitialCounter_ReturnRecsToTake()
        {
            var initialCounter = 250;

            var result = RowsHelper.MaxRowsToGet(300, ref initialCounter);

            result.Should().Be(50);
            initialCounter.Should().Be(300);
        }
Ejemplo n.º 3
0
        public void MaxRowsToGet_InitialCounterGreaterThanReadedRows_ReturnZero()
        {
            var initialCounter = 250;

            var result = RowsHelper.MaxRowsToGet(100, ref initialCounter);

            result.Should().Be(0);
            initialCounter.Should().Be(100);
        }
Ejemplo n.º 4
0
        private List <NotificationMessage> GetDataFromDb()
        {
            var ret = new List <NotificationMessage>();
            var paramsInitialCounter = _params.InitialCounter;
            var recsToTake           = RowsHelper.MaxRowsToGet(Count, ref paramsInitialCounter);

            _params.InitialCounter = paramsInitialCounter;
            if (recsToTake.Equals(0))
            {
                _counterReader.Save(_params.InitialCounter);
                return(ret);
            }
            _container.Clear();

            foreach (var r in _db[_params.Schema][_params.TableName].All().Take(recsToTake).OrderByDescending(_db[_params.Schema][_params.TableName][_params.OrderByColumnName]))
            {
                _container.Clear();
                GetColumnsByColumnsNames(r);

                if (_validator?.Validate(_container) == true)
                {
                    continue;
                }
                if (_aggregator?.AggregateIfPossible(ret, _container) != false)
                {
                    continue;
                }

                ret.Add(CreateMessage());
            }

            _counterReader.Save(_params.InitialCounter);

            ret.Reverse();
            return(ret);
        }