public void EnumerateDirectories_searchPattern_nomatch()
 {
     string path = new DirectoryWrap().GetCurrentDirectory();
     IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
     var subdirectories = directoryInfoWrap.EnumerateDirectories("XXX");
     Assert.AreEqual(0, subdirectories.Count());
 }
 public void EnumerateDirectories_searchPattern_match()
 {
     string path = new DirectoryWrap().GetCurrentDirectory();
     IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
     var subdirectories = directoryInfoWrap.Parent.EnumerateDirectories(directoryInfoWrap.Name);
     Assert.AreEqual(1, subdirectories.Count());
     Assert.AreEqual(directoryInfoWrap.Name, subdirectories.First().Name);
 }
 public void EnumerateDirectories_searchPatternOption_all()
 {
     string path = new DirectoryWrap().GetCurrentDirectory();
     IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
     var subdirectories = directoryInfoWrap.Parent.Parent.EnumerateDirectories(directoryInfoWrap.Name, System.IO.SearchOption.AllDirectories);
     Assert.AreEqual(2, subdirectories.Count()); // 2: bin\Debug and obj\Debug
     Assert.IsTrue(subdirectories.All(dir => dir.Name.Equals(directoryInfoWrap.Name)));
 }
 public void EnumerateDirectories_searchPatternOption_top()
 {
     string path = new DirectoryWrap().GetCurrentDirectory();
     IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
     var subdirectories = directoryInfoWrap.Parent.EnumerateDirectories(directoryInfoWrap.Name, System.IO.SearchOption.TopDirectoryOnly);
     Assert.AreEqual(1, subdirectories.Count());
     Assert.AreEqual(directoryInfoWrap.Name, subdirectories.First().Name);
 }
Esempio n. 5
0
 private static IDirectoryInfo[] ConvertDirectoryInfoArrayIntoIDirectoryInfoWrapArray(DirectoryInfo[] directoryInfos)
 {
     IDirectoryInfo[] directoryInfoWraps = new DirectoryInfoWrap[directoryInfos.Length];
     for (int i = 0; i < directoryInfos.Length; i++)
     {
         directoryInfoWraps[i] = new DirectoryInfoWrap(directoryInfos[i]);
     }
     return(directoryInfoWraps);
 }
        public void Create_two_directories_and_then_delete_them()
        {
            string path = new DirectoryWrap().GetCurrentDirectory();
            IDirectoryInfoWrap directoryInfoWrap = new DirectoryInfoWrap(path);
            IDirectoryInfoWrap[] directoriesBefore = directoryInfoWrap.GetDirectories();

            directoryInfoWrap.CreateSubdirectory("Dir1");
            directoryInfoWrap.CreateSubdirectory("Dir2");
            IDirectoryInfoWrap[] directoriesAfterCreate = directoryInfoWrap.GetDirectories();

            Assert.AreEqual("Dir1", directoriesAfterCreate[0].Name);
            Assert.AreEqual("Dir2", directoriesAfterCreate[1].Name);
            directoriesAfterCreate[0].Delete();
            directoriesAfterCreate[1].Delete();

            var directoriesAfterDelete = directoryInfoWrap.GetDirectories();
            Assert.AreEqual(directoriesBefore.Length, directoriesAfterDelete.Length);
        }
 private static IDirectoryInfo[] ConvertDirectoryInfoArrayIntoIDirectoryInfoWrapArray(DirectoryInfo[] directoryInfos)
 {
     IDirectoryInfo[] directoryInfoWraps = new DirectoryInfoWrap[directoryInfos.Length];
     for (int i = 0; i < directoryInfos.Length; i++)
         directoryInfoWraps[i] = new DirectoryInfoWrap(directoryInfos[i]);
     return directoryInfoWraps;
 }
 /// <summary>
 /// Returns information about files in a given location
 /// </summary>
 /// <param name="directoryPath">The path to check</param>
 /// <returns>Details about files in the given location</returns>
 public IEnumerable<IFileInfo> GetFilesInDirectory(string directoryPath)
 {
     var directoryInfo = new DirectoryInfoWrap(directoryPath);
     return directoryInfo.GetFiles();
 }
 public void GetFiles_must_have_files_in_Debug_folder()
 {
     IDirectoryInfoWrap directoryWrap = new DirectoryInfoWrap(new DirectoryWrap().GetCurrentDirectory());
     IFileInfoWrap[] fileInfoWraps = directoryWrap.GetFiles();
     Assert.IsTrue(fileInfoWraps.Length > 0);
 }
        public void EnumerateFileSystemInfos_searchPatternOption_top()
        {
            string path = new DirectoryWrap().GetCurrentDirectory();
            IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
            var infos = directoryInfoWrap.EnumerateFileSystemInfos("*a*", System.IO.SearchOption.TopDirectoryOnly);

            Assert.IsTrue(infos.Any(i => i is IFileInfo));
            Assert.IsTrue(infos.Any(i => i is IDirectoryInfo));
        }
        public void EnumerateFileSystemInfos_searchPatternOption_all()
        {
            string path = new DirectoryWrap().GetCurrentDirectory();
            IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
            var infos = directoryInfoWrap.EnumerateFileSystemInfos("*BinaryReader*", System.IO.SearchOption.AllDirectories);

            Assert.IsTrue(infos.Any(i => i is IFileInfo));
            Assert.IsFalse(infos.Any(i => i is IDirectoryInfo));
        }
 public void EnumerateFiles_test()
 {
     string path = new DirectoryWrap().GetCurrentDirectory();
     IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
     var files = directoryInfoWrap.Parent.Parent.EnumerateFiles();
     Assert.Greater(files.Count(), 0);
 }
 public void EnumerateFiles_searchPattern_match()
 {
     string path = new DirectoryWrap().GetCurrentDirectory();
     IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
     var files = directoryInfoWrap.EnumerateFiles(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name);
     Assert.AreEqual(1, files.Count());
 }
 public void EnumerateFiles_searchPatternOption_all()
 {
     string path = new DirectoryWrap().GetCurrentDirectory();
     IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
     var files = directoryInfoWrap.Parent.Parent.Parent.Parent.EnumerateFiles(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.IO.SearchOption.AllDirectories);
     Assert.Greater(files.Count(), 0);
 }
        public void EnumerateFileSystemInfos_test()
        {
            string path = new DirectoryWrap().GetCurrentDirectory();
            IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
            var infos = directoryInfoWrap.EnumerateFileSystemInfos();

            Assert.IsTrue(infos.Any(i => i is IFileInfo));
            Assert.IsTrue(infos.Any(i => i is IDirectoryInfo));
        }
        public void EnumerateFileSystemInfos_searchPattern_nomatch()
        {
            string path = new DirectoryWrap().GetCurrentDirectory();
            IDirectoryInfo directoryInfoWrap = new DirectoryInfoWrap(path);
            var infos = directoryInfoWrap.EnumerateFileSystemInfos("*NOT_FOUND*");

            Assert.AreEqual(0, infos.Count());
        }