예제 #1
0
        public void MovingBetweenTokens()
        {
            var           query = new TagQuery();
            TagQueryToken token;

            query.SetQuery("/first/second/third/fourth/fifth/sixth");
            Assert.AreEqual(6, query.Count());
            Assert.AreEqual(6, query.TokensLeft());
            token = query.Previous();
            Assert.IsNull(token);
            Assert.AreEqual(6, query.TokensLeft());
            token = query.Next();
            Assert.AreEqual("first", token.Name);
            Assert.AreEqual(5, query.TokensLeft());
            token = query.Next();
            Assert.AreEqual("second", token.Name);
            Assert.AreEqual(4, query.TokensLeft());
            token = query.Next();
            Assert.AreEqual("third", token.Name);
            Assert.AreEqual(3, query.TokensLeft());
            token = query.Previous();
            Assert.AreEqual("second", token.Name);
            Assert.AreEqual(4, query.TokensLeft());
            token = query.Next();
            Assert.AreEqual("third", token.Name);
            Assert.AreEqual(3, query.TokensLeft());
            token = query.Peek();
            Assert.AreEqual("fourth", token.Name);
            Assert.AreEqual(3, query.TokensLeft());
            token = query.Next();
            Assert.AreEqual("fourth", token.Name);
            Assert.AreEqual(2, query.TokensLeft());
            token = query.Next();
            Assert.AreEqual("fifth", token.Name);
            Assert.AreEqual(1, query.TokensLeft());
            token = query.Next();
            Assert.AreEqual("sixth", token.Name);
            Assert.AreEqual(0, query.TokensLeft());
            token = query.Next();
            Assert.IsNull(token);
            Assert.AreEqual(0, query.TokensLeft());
            token = query.Previous();
            Assert.AreEqual("fifth", token.Name);
            Assert.AreEqual(1, query.TokensLeft());
            query.MoveFirst();
            Assert.AreEqual(6, query.TokensLeft());
            token = query.Next();
            Assert.AreEqual("first", token.Name);
            Assert.AreEqual(5, query.TokensLeft());
        }