public void FeedRangeCompositeContinuation_IsDone_MultipleRanges()
        {
            const string containerRid            = "containerRid";
            FeedRangeCompositeContinuation token = new FeedRangeCompositeContinuation(
                containerRid,
                Mock.Of <FeedRangeInternal>(),
                new List <Documents.Routing.Range <string> >()
            {
                new Documents.Routing.Range <string>("A", "B", true, false),
                new Documents.Routing.Range <string>("B", "C", true, false),
                new Documents.Routing.Range <string>("C", "D", true, false)
            }, continuation: null);

            // First range has continuation
            token.ReplaceContinuation(Guid.NewGuid().ToString());
            Assert.IsFalse(token.IsDone);

            // Second range is done
            token.ReplaceContinuation(null);
            Assert.IsFalse(token.IsDone);

            // Third range is done
            token.ReplaceContinuation(null);
            Assert.IsFalse(token.IsDone);

            // First range has continuation
            token.ReplaceContinuation(Guid.NewGuid().ToString());
            Assert.IsFalse(token.IsDone);

            // MoveNext should skip the second and third
            // Finish first one
            token.ReplaceContinuation(null);
            Assert.IsTrue(token.IsDone);
        }
        public void FeedRangeCompositeContinuation_MoveToNextTokenCircles()
        {
            const string containerRid = "containerRid";
            List <Documents.Routing.Range <string> > keyRanges = new List <Documents.Routing.Range <string> >()
            {
                new Documents.Routing.Range <string>("A", "B", true, false),
                new Documents.Routing.Range <string>("D", "E", true, false),
            };
            FeedRangeCompositeContinuation token = new FeedRangeCompositeContinuation(containerRid, Mock.Of <FeedRangeInternal>(), keyRanges);

            Assert.AreEqual(keyRanges[0].Min, token.CompositeContinuationTokens.Peek().Range.Min);
            token.ReplaceContinuation("something");
            Assert.AreEqual(keyRanges[1].Min, token.CompositeContinuationTokens.Peek().Range.Min);
            token.ReplaceContinuation("something");
            Assert.AreEqual(keyRanges[0].Min, token.CompositeContinuationTokens.Peek().Range.Min);
            token.ReplaceContinuation("something");
            Assert.AreEqual(keyRanges[1].Min, token.CompositeContinuationTokens.Peek().Range.Min);
        }
        public void FeedRangeCompositeContinuation_IsDone()
        {
            const string containerRid            = "containerRid";
            FeedRangeCompositeContinuation token = new FeedRangeCompositeContinuation(
                containerRid,
                Mock.Of <FeedRangeInternal>(),
                new List <Documents.Routing.Range <string> >()
            {
                new Documents.Routing.Range <string>("A", "B", true, false)
            }, continuation: Guid.NewGuid().ToString());

            Assert.IsFalse(token.IsDone);

            token.ReplaceContinuation(null);
            Assert.IsTrue(token.IsDone);
        }