Exemplo n.º 1
0
        public void Directory_ContentsRecursive()
        {
            var tmpSrc     = GetNewFileNameOnTempPath("");
            var tmpSrcInfo = FileSystem.DirectoryFromPath(tmpSrc);

            // make test file
            const string fileName = @"temp.txt";
            var          newFile  = FileSystem.CombinePath(tmpSrc, fileName);

            FileSystem.WriteText(newFile, "test");

            // make subdirectory
            const string dirName = @"subDir";
            var          newDir  = FileSystem.CombinePath(tmpSrc, dirName);

            Directory.CreateDirectory(newDir);

            // make another test file in subdirectory
            const string subdirFileName = @"tempSubdir.txt";
            var          newSubdirFile  = FileSystem.CombinePath(newDir, subdirFileName);

            FileSystem.WriteText(newSubdirFile, "testSubdir");

            var contents = FileSystem.GetDirectoryContents(tmpSrcInfo, "*.*", true);

            Assert.AreEqual(new[] { newFile, newSubdirFile }, contents["files"]);
            Assert.AreEqual(new[] { newDir }, contents["directories"]);
        }
Exemplo n.º 2
0
        public void Directory_Contents()
        {
            var          tmpSrc     = GetNewFileNameOnTempPath("");
            var          tmpSrcInfo = FileSystem.DirectoryFromPath(tmpSrc);
            const string fileName   = @"temp.txt";
            var          newFile    = FileSystem.CombinePath(tmpSrc, fileName);

            FileSystem.WriteText(newFile, "test");

            const string dirName = @"subDir";
            var          newDir  = FileSystem.CombinePath(tmpSrc, dirName);

            Directory.CreateDirectory(newDir);

            var contents = FileSystem.GetDirectoryContents(tmpSrcInfo);

            Assert.AreEqual(new[] { newFile }, contents["files"]);
            Assert.AreEqual(new[] { newDir }, contents["directories"]);
        }