Exemplo n.º 1
0
        public void FilesAreEnumerated()
        {
            using (var scenario = new DisposableFileSystem()
                                  .CreateFile("alpha.txt"))
            {
                var contents = new DirectoryInfoWrapper(scenario.DirectoryInfo).EnumerateFileSystemInfos();
                var alphaTxt = contents.OfType <FileInfoBase>().Single();

                Assert.Equal(1, contents.Count());
                Assert.Equal("alpha.txt", alphaTxt.Name);
            }
        }
Exemplo n.º 2
0
        public void FoldersAreEnumerated()
        {
            using (var scenario = new DisposableFileSystem()
                                  .CreateFolder("beta"))
            {
                var contents1 = new DirectoryInfoWrapper(scenario.DirectoryInfo).EnumerateFileSystemInfos();
                var beta      = contents1.OfType <DirectoryInfoBase>().Single();
                var contents2 = beta.EnumerateFileSystemInfos();

                Assert.Equal(1, contents1.Count());
                Assert.Equal("beta", beta.Name);
                Assert.Equal(0, contents2.Count());
            }
        }
Exemplo n.º 3
0
        public void SubFoldersAreEnumerated()
        {
            using (var scenario = new DisposableFileSystem()
                                  .CreateFolder("beta")
                                  .CreateFile(Path.Combine("beta", "alpha.txt")))
            {
                var contents1 = new DirectoryInfoWrapper(scenario.DirectoryInfo).EnumerateFileSystemInfos();
                var beta      = contents1.OfType <DirectoryInfoBase>().Single();
                var contents2 = beta.EnumerateFileSystemInfos();
                var alphaTxt  = contents2.OfType <FileInfoBase>().Single();

                Assert.Equal(1, contents1.Count());
                Assert.Equal("beta", beta.Name);
                Assert.Equal(1, contents2.Count());
                Assert.Equal("alpha.txt", alphaTxt.Name);
            }
        }