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"); }
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()); }
public void testComputeFileObjectId() { var top = new FileTreeIterator(trash); MessageDigest md = Constants.newMessageDigest(); md.Update(Constants.encodeASCII(Constants.TYPE_BLOB)); md.Update((byte)' '); md.Update(Constants.encodeASCII(Paths[0].Length)); md.Update(0); md.Update(Constants.encode(Paths[0])); ObjectId expect = ObjectId.FromRaw(md.Digest()); Assert.AreEqual(expect, top.getEntryObjectId()); // Verify it was cached by removing the File and getting it again. File.Delete(Path.Combine(trash.FullName, Paths[0])); Assert.AreEqual(expect, top.getEntryObjectId()); }
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()); }