public void TestFolderFoundArgs() { int ix = 0; DirectoryInfo[] expected = new DirectoryInfo(TestFolder).GetDirectories(); FindFile.FoldersIn(TestFolder, e => { Assert.AreEqual(expected[ix].Attributes, e.Attributes); Assert.AreEqual(expected[ix].FullName, e.FullPath); Assert.AreEqual(expected[ix].Extension, e.Extension); Assert.AreEqual(expected[ix].Name, e.Name); Assert.AreEqual(0, e.Length); Assert.AreEqual(expected[ix].CreationTimeUtc, e.CreationTimeUtc); Assert.AreEqual(expected[ix].LastAccessTimeUtc, e.LastAccessTimeUtc); Assert.AreEqual(expected[ix].LastWriteTimeUtc, e.LastWriteTimeUtc); Assert.AreEqual(FindFile.UncPrefix + expected[ix].FullName, e.FullPathUnc); Assert.AreEqual(Path.GetDirectoryName(expected[ix].FullName).TrimEnd('\\'), e.ParentPath.TrimEnd('\\')); Assert.AreEqual(FindFile.UncPrefix + Path.GetDirectoryName(expected[ix].FullName).TrimEnd('\\'), e.ParentPathUnc.TrimEnd('\\')); Assert.AreEqual(false, e.CancelEnumeration); Assert.AreEqual(false, e.IsCompressed); Assert.AreEqual(true, e.IsDirectory); Assert.AreEqual(false, e.IsEncrypted); Assert.AreEqual(false, e.IsHidden); Assert.AreEqual(false, e.IsOffline); Assert.AreEqual(false, e.IsReadOnly); Assert.AreEqual(false, e.IsReparsePoint); Assert.AreEqual(false, e.IsSystem); ix++; }); Assert.AreEqual(expected.Length, ix); }
public void TestFilesAndFolders() { int files = 0, folders = 0, total = 0; string dir = TestFolder; FindFile.FilesIn(dir, e => { Assert.IsTrue(File.Exists(e.FullPath)); files++; }); FindFile.FoldersIn(dir, e => { Assert.IsTrue(Directory.Exists(e.FullPath)); folders++; }); FindFile.FilesAndFoldersIn(dir, e => { Assert.IsTrue(File.Exists(e.FullPath) || Directory.Exists(e.FullPath)); total++; }); Assert.AreEqual(3, files); Assert.AreEqual(1, folders); Assert.AreEqual(4, total); }