Esempio n. 1
0
        public void testSimpleIterate()
        {
            var top = new FileTreeIterator(trash);

            Assert.IsTrue(top.first());
            Assert.IsFalse(top.eof());
            Assert.IsTrue(FileMode.RegularFile == top.EntryFileMode);
            Assert.AreEqual(Paths[0], NameOf(top));
            Assert.AreEqual(Paths[0].Length, top.getEntryLength());
            Assert.AreEqual(_mtime[0], top.getEntryLastModified());

            top.next(1);
            Assert.IsFalse(top.first());
            Assert.IsFalse(top.eof());
            Assert.IsTrue(FileMode.RegularFile == top.EntryFileMode);
            Assert.AreEqual(Paths[1], NameOf(top));
            Assert.AreEqual(Paths[1].Length, top.getEntryLength());
            Assert.AreEqual(_mtime[1], top.getEntryLastModified());

            top.next(1);
            Assert.IsFalse(top.first());
            Assert.IsFalse(top.eof());
            Assert.IsTrue(FileMode.Tree == top.EntryFileMode);

            AbstractTreeIterator sub = top.createSubtreeIterator(db);

            Assert.IsTrue(sub is FileTreeIterator);
            var subfti = (FileTreeIterator)sub;

            Assert.IsTrue(sub.first());
            Assert.IsFalse(sub.eof());
            Assert.AreEqual(Paths[2], NameOf(sub));
            Assert.AreEqual(Paths[2].Length, subfti.getEntryLength());
            Assert.AreEqual(_mtime[2], subfti.getEntryLastModified());

            sub.next(1);
            Assert.IsTrue(sub.eof());

            top.next(1);
            Assert.IsFalse(top.first());
            Assert.IsFalse(top.eof());
            Assert.IsTrue(FileMode.RegularFile == top.EntryFileMode);
            Assert.AreEqual(Paths[3], NameOf(top));
            Assert.AreEqual(Paths[3].Length, top.getEntryLength());
            Assert.AreEqual(_mtime[3], top.getEntryLastModified());

            top.next(1);
            Assert.IsTrue(top.eof());
        }
        public override void popEntriesEqual()
        {
            AbstractTreeIterator ch = CurrentHead;

            for (int i = 0; i < Trees.Length; i++)
            {
                AbstractTreeIterator t = Trees[i];
                if (t.Matches == ch)
                {
                    if (t.MatchShift == 0)
                    {
                        t.next(1);
                    }
                    else
                    {
                        t.back(t.MatchShift);
                        t.MatchShift = 0;
                    }
                    t.Matches = null;
                }
            }
        }