Пример #1
0
        public async Task IncludeAllFilesInSubFolderBaseFolderAsIFolder()
        {
            var          sys            = new MemoryFileSystemFake();
            const string fileNameToFind = "FileInSubFolder.txt";
            string       filePathToFind = PortablePath.Combine("b", fileNameToFind);

            sys.AddFiles(x => x
                         .File("FileInRoot.txt")
                         .Folder("a", a => a
                                 .File("FileInFolder.txt")
                                 .File("AnotherFileInFolder.txt")
                                 .Folder("b", b => b
                                         .File(fileNameToFind)))
                         .Folder("c", c => c
                                 .File("FileInFolder.txt")));
            IFolder baseFolder = await sys.GetFolderFromPathAsync("/a");

            var fs = new FileSet(sys, baseFolder);

            fs.Include(PortablePath.Combine("b", "*"));
            List <string> files = (await fs.GetFilesAsync()).ToList();

            Assert.That(files.Count, Is.EqualTo(1));
            Assert.That(files, Has.Member(filePathToFind));
        }
Пример #2
0
        private static FileSet CreateFileSetForMultipleIncludesAndAnExclusions(
            out string filePathToFind1, out string filePathToFind2,
            out string filePathNotFound1, out string filePathNotFound2)
        {
            var          sys             = new MemoryFileSystemFake();
            const string fileNameToFind1 = "FileInRoot.zzz";
            const string fileNotFound1   = "FileInFolder.yyy";
            const string fileNameToFind2 = "FileInSubFolder.yyy";
            const string fileNotFound2   = "FileInFolder.zzz";

            filePathToFind1   = PortablePath.Combine(fileNameToFind1);
            filePathNotFound1 = PortablePath.Combine("a", fileNotFound1);
            filePathToFind2   = PortablePath.Combine("a", "b", fileNameToFind2);
            filePathNotFound2 = PortablePath.Combine("c", fileNotFound2);
            sys.AddFiles(x => x
                         .File(fileNameToFind1)
                         .Folder("a", a => a
                                 .File(fileNotFound1)
                                 .File("AnotherFileInFolder.txt")
                                 .Folder("b", b => b
                                         .File(fileNameToFind2)))
                         .Folder("c", c => c
                                 .File(fileNotFound2)));
            var fs = new FileSet(sys, "/");

            fs.Include("**/*.zzz");
            fs.Include("**/*.yyy");
            fs.Exclude("**/*eInF*z*");
            fs.Exclude("a/*.yyy");
            return(fs);
        }
Пример #3
0
        public async Task IncludeAllAndMultipleExcludesWithQuestionMarkWildcard()
        {
            var          sys            = new MemoryFileSystemFake();
            const string fileNameToFind = "FileInFolder.yyy";
            string       filePathToFind = PortablePath.Combine("a", fileNameToFind);

            sys.AddFiles(x => x
                         .File("FileInRoot.bzz")
                         .Folder("a", a => a
                                 .File(fileNameToFind)
                                 .File("AnotherFileInFolder.txt")
                                 .Folder("b", b => b
                                         .File("FileInSubFolder.txt")))
                         .Folder("c", c => c
                                 .File("FileInFolder.azz")));
            var fs = new FileSet(sys, "/");

            fs.Include(@"**\*");
            fs.Exclude(@"?\?\*");
            fs.Exclude(@"**\Another*");
            fs.Exclude(@"**\*?zz");
            List <string> files = (await fs.GetFilesAsync()).ToList();

            Assert.That(files.Count, Is.EqualTo(1));
            Assert.That(files, Has.Member(filePathToFind));
        }
Пример #4
0
        public async Task IncludeAllFilesInAnyFolderWithASpecificExtensionWithRootedFileSpec()
        {
            var          sys             = new MemoryFileSystemFake();
            const string fileNameToFind1 = "FileInRoot.zzz";
            const string fileNameToFind2 = "FileInSubFolder.zzz";
            const string fileNameToFind3 = "FileInFolder.zzz";
            string       filePathToFind1 = PortablePath.Combine(fileNameToFind1);
            string       filePathToFind2 = PortablePath.Combine("a", "b", fileNameToFind2);
            string       filePathToFind3 = PortablePath.Combine("c", fileNameToFind3);

            sys.AddFiles(x => x
                         .File(fileNameToFind1)
                         .Folder("a", a => a
                                 .File("FileInFolder.txt")
                                 .File("AnotherFileInFolder.txt")
                                 .Folder("b", b => b
                                         .File(fileNameToFind2)))
                         .Folder("c", c => c
                                 .File(fileNameToFind3)));
            var fs = new FileSet(sys, "/");

            fs.Include("**/*.zzz");
            List <string> files = (await fs.GetFilesAsync()).ToList();

            Assert.That(files.Count, Is.EqualTo(3));
            Assert.That(files, Has.Member(filePathToFind1));
            Assert.That(files, Has.Member(filePathToFind2));
            Assert.That(files, Has.Member(filePathToFind3));
        }
Пример #5
0
        public void SpecifyInvalidBasePathIteratingFolders()
        {
            var sys = new MemoryFileSystemFake();

            sys.AddFiles(x => x
                         .File("FileInRoot.txt")
                         .Folder("a", a => a
                                 .File("FileInFolder.txt")
                                 .File("AnotherFileInFolder.txt")
                                 .Folder("b", b => b
                                         .File("FileInSubFolder.txt")))
                         .Folder("c", c => c
                                 .File("FileInFolder.txt")));
            var fs = new FileSet(sys, "/DoesNotExist");

            fs.Include(@"**\*");
            Assert.That(() => fs.GetFolders().ToList(), Throws.TypeOf <InvalidOperationException>());
        }