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()); Assert.IsTrue(fti.eof()); }
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 void testEmptyIfRootIsEmpty() { string path = Path.Combine(trash.FullName, "not-existing-File"); var di = new DirectoryInfo(path); Assert.IsFalse(di.Exists); di.Create(); di.Refresh(); Assert.IsTrue(di.Exists); var fti = new FileTreeIterator(di); Assert.IsTrue(fti.first()); Assert.IsTrue(fti.eof()); }