public void Empty()
        {
            var list = new BatchingEnumeration <object, object>(
                new List <object>(),
                10,
                (l) => {
                Assert.Fail("Nothing should be fetched");
                return(l);
            });


            Assert.That(list, Is.Empty);
            Assert.That(list.GetEnumerator().MoveNext(), Is.False);
        }
        public void TestListOrder()
        {
            var fetches   = 0;
            var batchSize = 10;
            var list      = CreateList(100);

            var enumeration = new BatchingEnumeration <int, int>(
                list,
                batchSize,
                (l) =>
            {
                Assert.That(l.First(), Is.EqualTo(batchSize * fetches));
                fetches++;
                return(l);
            });
        }
        public void TestNumberOfFetches(int batchSize, int listSize, int expectedFetches)
        {
            var fetches = 0;
            var list    = CreateList(listSize);

            var enumeration = new BatchingEnumeration <int, int>(
                list,
                batchSize,
                (l) => {
                fetches++;
                return(l);
            });

            var doAll = enumeration.All(t => true);

            Assert.That(fetches, Is.EqualTo(expectedFetches));
        }
示例#4
0
        public BatchingEntityEnumeration(IEnumerable <IEntityRef> list, int batchSize, params IEntityRef[] fields)
        {
            Func <IEnumerable <IEntityRef>, IEnumerable <T> > f = (fetchList) => Entity.Get <T>(fetchList.Select(r => r.Id), fields);  // I don't like the convertion from a IEntityRef to a EntityRef

            _enumeration = new BatchingEnumeration <IEntityRef, T>(list, batchSize, f);
        }