示例#1
0
        public void Core_Data_EntityReader_GetByPage()
        {
            var reader      = new EntityReader <CustomerInfo>(new ConnectionStringFactory().GetDefaultConnection());
            var item        = new CustomerInfo();
            var pageCount   = 3;
            var pageCurrent = 1;
            var testKeys    = reader.GetAll().Take(10).Select(x => x.Key);
            var firstSet    = reader.GetByPage(x => testKeys.Contains(x.Key), y => y.Id, pageCount, pageCurrent).ToList();

            Assert.IsTrue(firstSet.Count() == pageCount);
            Assert.IsTrue(firstSet.First().Id <= firstSet.Last().Id);
            pageCurrent += 1;
            var secondSet = reader.GetByPage(x => testKeys.Contains(x.Key), y => y.Id, pageCount, pageCurrent).ToList();

            Assert.IsTrue(secondSet.Count() == pageCount);
            Assert.IsTrue(secondSet.First().Id <= secondSet.Last().Id);
            Assert.IsTrue(firstSet.Last().Id <= secondSet.First().Id);
        }