Exemplo n.º 1
0
        public void testEmptyIfRootIsFile()
        {
            string path = Path.Combine(trash.FullName, Paths[0]);
            var di = new DirectoryInfo(path);
            var fi = new FileInfo(path);
            Assert.IsTrue(fi.Exists);

            var fti = new FileTreeIterator(di);
            Assert.IsTrue(fti.first());

            AssertHelper.IgnoreOn(AssertedPlatform.Mono, () => Assert.IsTrue(fti.eof()), "Test fails under mono due to http://bugzilla.novell.com/show_bug.cgi?id=539791,Fixed upstream");
        }
Exemplo n.º 2
0
        public void testEmptyIfRootDoesNotExist()
        {
            string path = Path.Combine(trash.FullName, "not-existing-File");
            var di = new DirectoryInfo(path);
            Assert.IsFalse(di.Exists);

            var fti = new FileTreeIterator(di);
            Assert.IsTrue(fti.first());
            Assert.IsTrue(fti.eof());
        }
Exemplo n.º 3
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());
        }