Ejemplo n.º 1
0
        public void Directory_Delete()
        {
            var tmpSrc = GetNewFileNameOnTempPath("");

            Directory.CreateDirectory(tmpSrc);
            const string fileName = @"temp.txt";

            FileSystem.WriteText(FileSystem.CombinePath(tmpSrc, fileName), "test");

            Assert.Throws <IOException>(() => FileSystem.DeleteDirectory(tmpSrc));
            FileSystem.DeleteDirectory(tmpSrc, recursive: true);
            Assert.IsFalse(FileSystem.DirectoryExists(tmpSrc));

            var tmpSrc2 = GetNewFileNameOnTempPath("");

            Directory.CreateDirectory(tmpSrc2);
            FileSystem.DeleteDirectory(tmpSrc2);
            Assert.IsFalse(FileSystem.DirectoryExists(tmpSrc2));
        }