public void Moving_Should_Include_SubFolders_And_Files()
        {
            var sourceContents = source.GetFolderContents();

            source.Move(targetPath);
            var target         = VirtualFolder.Create(FileSystem, targetPath);
            var targetContents = target.GetFolderContents();

            Assert.AreEqual(sourceContents.Files.Count(), targetContents.Files.Count());
            Assert.AreEqual(sourceContents.Folders.Count(), targetContents.Folders.Count());

            //check first file
            Assert.AreEqual(sourceContents.Files.First().MetaData.Length, targetContents.Files.First().MetaData.Length);
            Assert.AreEqual(sourceContents.Files.First().MetaData.Name, targetContents.Files.First().MetaData.Name);
            Assert.AreEqual(sourceContents.Files.First().MetaData.ContentType, targetContents.Files.First().MetaData.ContentType);
            Assert.AreEqual(sourceContents.Files.First().MetaData.Length, targetContents.Files.First().MetaData.Length);

            //check second file
            Assert.AreEqual(sourceContents.Files.Last().MetaData.Length, targetContents.Files.Last().MetaData.Length);
            Assert.AreEqual(sourceContents.Files.Last().MetaData.Name, targetContents.Files.Last().MetaData.Name);
            Assert.AreEqual(sourceContents.Files.Last().MetaData.ContentType, targetContents.Files.Last().MetaData.ContentType);
            Assert.AreEqual(sourceContents.Files.Last().MetaData.Length, targetContents.Files.Last().MetaData.Length);

            //check first/second folder name
            Assert.AreEqual(sourceContents.Folders.First().MetaData.Name, targetContents.Folders.First().MetaData.Name);
            Assert.AreEqual(sourceContents.Folders.Last().MetaData.Name, targetContents.Folders.Last().MetaData.Name);
        }
Exemplo n.º 2
0
        public void Copying_Should_Include_SubFolders_And_Files()
        {
            var target = source.Copy(targetPath);

            var sourceContents = source.GetFolderContents();
            var targetContents = target.GetFolderContents();

            Assert.AreNotEqual(sourceContents.ParentFolderPath, targetContents.ParentFolderPath);

            Assert.AreEqual(sourceContents.Files.Count(), targetContents.Files.Count());
            Assert.AreEqual(sourceContents.Folders.Count(), targetContents.Folders.Count());

            //check first file
            Assert.AreEqual(sourceContents.Files.First().MetaData.Length, targetContents.Files.First().MetaData.Length);
            Assert.AreEqual(sourceContents.Files.First().MetaData.Name, targetContents.Files.First().MetaData.Name);
            Assert.AreEqual(sourceContents.Files.First().MetaData.ContentType, targetContents.Files.First().MetaData.ContentType);
            Assert.AreEqual(sourceContents.Files.First().MetaData.Length, targetContents.Files.First().MetaData.Length);

            //check second file
            Assert.AreEqual(sourceContents.Files.Last().MetaData.Length, targetContents.Files.Last().MetaData.Length);
            Assert.AreEqual(sourceContents.Files.Last().MetaData.Name, targetContents.Files.Last().MetaData.Name);
            Assert.AreEqual(sourceContents.Files.Last().MetaData.ContentType, targetContents.Files.Last().MetaData.ContentType);
            Assert.AreEqual(sourceContents.Files.Last().MetaData.Length, targetContents.Files.Last().MetaData.Length);

            //check first/second folder name
            Assert.AreEqual(sourceContents.Folders.First().MetaData.Name, targetContents.Folders.First().MetaData.Name);
            Assert.AreEqual(sourceContents.Folders.Last().MetaData.Name, targetContents.Folders.Last().MetaData.Name);
        }
    private static void RecurseFS(VirtualFolder parent, Action<VirtualFolder, VirtualFile> fileTest, Action<VirtualFolder, VirtualFolder> folderTest)
    {
      var contents = parent.GetFolderContents();

      contents.Files.Do(vf => fileTest(parent, vf));
      contents.Folders.Do(vf => folderTest(parent, vf));

      contents.Folders.Do(vf => RecurseFS(vf, fileTest, folderTest));
    }
Exemplo n.º 4
0
        private static void RecurseFS(VirtualFolder parent, Action <VirtualFolder, VirtualFile> fileTest, Action <VirtualFolder, VirtualFolder> folderTest)
        {
            var contents = parent.GetFolderContents();

            contents.Files.Do(vf => fileTest(parent, vf));
            contents.Folders.Do(vf => folderTest(parent, vf));

            contents.Folders.Do(vf => RecurseFS(vf, fileTest, folderTest));
        }
        public void Requesting_Contents_With_Search_Pattern_Should_Return_All_Matching_Files_And_Folders()
        {
            string pattern = "*r*";

            var results = testFolder.GetFolderContents(pattern);

            CheckResults(results.Files.Select(f => f.MetaData),
                         testFolder.GetFiles(pattern).Select(f => f.MetaData.Name).ToArray());

            CheckResults(results.Folders.Select(f => f.MetaData),
                         testFolder.GetFolders(pattern).Select(f => f.MetaData.Name).ToArray());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Recursively browses the file system and performs tests on either
        /// files, folders, or both. The submitted parent folder is not tested.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="fileTest"></param>
        /// <param name="folderTest"></param>
        protected static void RecurseFileSystem(VirtualFolder parent, Action <VirtualFolder, VirtualFile> fileTest, Action <VirtualFolder, VirtualFolder> folderTest)
        {
            var contents = parent.GetFolderContents();

            if (fileTest != null)
            {
                contents.Files.Do(vf => fileTest(parent, vf));
            }

            if (folderTest != null)
            {
                contents.Folders.Do(vf => folderTest(parent, vf));
            }

            contents.Folders.Do(vf => RecurseFileSystem(vf, fileTest, folderTest));
        }
    private void BrowseFolder(VirtualFolder parentFolder, DirectoryInfo parentDir)
    {
      var contents = parentFolder.GetFolderContents();
      var folders = parentFolder.GetFolders();
      var files = parentFolder.GetFiles();

      Assert.AreEqual(contents.Folders.Count(), folders.Count());
      Assert.AreEqual(contents.Files.Count(), files.Count());


      Assert.AreEqual(parentDir.GetDirectories().Count(), contents.Folders.Count());
      Assert.AreEqual(parentDir.GetFiles().Count(), contents.Files.Count());

      foreach (var file in files)
      {
        //make sure contents matches the files collection
        VirtualFile virtualFile = file;
        Assert.AreEqual(contents.Files.Single(f => f.MetaData.FullName == virtualFile.MetaData.FullName).MetaData.Length, file.MetaData.Length);

        FileInfo fi = parentDir.GetFiles(file.MetaData.Name).Single();
        Assert.AreEqual(file.MetaData.Length, fi.Length);
      }

      foreach (var folder in contents.Folders)
      {
        //make sure contents matches the folders collection
        VirtualFolder virtualFolder = folder;
        Assert.AreEqual(contents.Folders.Single(f => f.MetaData.FullName == virtualFolder.MetaData.FullName).MetaData.Name, folder.MetaData.Name);


        DirectoryInfo dir = parentDir.GetDirectories(folder.MetaData.Name).Single();
        Assert.True(dir.Exists);

        //browse recursively
        BrowseFolder(folder, dir);
      }
    }
        private void BrowseFolder(VirtualFolder parentFolder, DirectoryInfo parentDir)
        {
            var contents = parentFolder.GetFolderContents();
            var folders  = parentFolder.GetFolders();
            var files    = parentFolder.GetFiles();

            Assert.AreEqual(contents.Folders.Count(), folders.Count());
            Assert.AreEqual(contents.Files.Count(), files.Count());


            Assert.AreEqual(parentDir.GetDirectories().Count(), contents.Folders.Count());
            Assert.AreEqual(parentDir.GetFiles().Count(), contents.Files.Count());

            foreach (var file in files)
            {
                //make sure contents matches the files collection
                VirtualFile virtualFile = file;
                Assert.AreEqual(contents.Files.Single(f => f.MetaData.FullName == virtualFile.MetaData.FullName).MetaData.Length, file.MetaData.Length);

                FileInfo fi = parentDir.GetFiles(file.MetaData.Name).Single();
                Assert.AreEqual(file.MetaData.Length, fi.Length);
            }

            foreach (var folder in contents.Folders)
            {
                //make sure contents matches the folders collection
                VirtualFolder virtualFolder = folder;
                Assert.AreEqual(contents.Folders.Single(f => f.MetaData.FullName == virtualFolder.MetaData.FullName).MetaData.Name, folder.MetaData.Name);


                DirectoryInfo dir = parentDir.GetDirectories(folder.MetaData.Name).Single();
                Assert.True(dir.Exists);

                //browse recursively
                BrowseFolder(folder, dir);
            }
        }
Exemplo n.º 9
0
        public void Returned_Items_Should_Provide_The_Parent_Folder_Path()
        {
            var contents = testFolder.GetFolderContents();

            Assert.AreEqual(testFolder.MetaData.FullName, contents.ParentFolderPath);
        }
Exemplo n.º 10
0
    /// <summary>
    /// Recursively browses the file system and performs tests on either
    /// files, folders, or both. The submitted parent folder is not tested.
    /// </summary>
    /// <param name="parent"></param>
    /// <param name="fileTest"></param>
    /// <param name="folderTest"></param>
    protected static void RecurseFileSystem(VirtualFolder parent, Action<VirtualFolder, VirtualFile> fileTest, Action<VirtualFolder, VirtualFolder> folderTest)
    {
      var contents = parent.GetFolderContents();

      if (fileTest != null)
      {
        contents.Files.Do(vf => fileTest(parent, vf));
      }

      if (folderTest != null)
      {
        contents.Folders.Do(vf => folderTest(parent, vf));
      }

      contents.Folders.Do(vf => RecurseFileSystem(vf, fileTest, folderTest));
    }