示例#1
0
        public virtual void testCreateSubtreeIterator()
        {
            EmptyTreeIterator    etp = new EmptyTreeIterator();
            AbstractTreeIterator sub = etp.createSubtreeIterator(db);

            Assert.IsNotNull(sub);
            Assert.IsTrue(sub.first());
            Assert.IsTrue(sub.eof());
            Assert.IsTrue(sub is EmptyTreeIterator);
        }
示例#2
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());
        }