public void Directory_Exists() { var tmp = GetNewFileNameOnTempPath(""); Assert.IsFalse(FileSystem.DirectoryExists(tmp), "Directory hasn't been created yet."); Directory.CreateDirectory(tmp); Assert.IsTrue(FileSystem.DirectoryExists(tmp), "Directory has been created."); }
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)); }
public void Directory_Copy() { var tmpSrc = GetNewFileNameOnTempPath(""); var tmpSrcInfo = FileSystem.DirectoryFromPath(tmpSrc); const string fileName = @"temp.txt"; FileSystem.WriteText(FileSystem.CombinePath(tmpSrc, fileName), "test"); var tmpDest = GetNewFileNameOnTempPath(""); FileSystem.CopyDirectory(tmpSrcInfo, tmpDest); Assert.IsTrue(FileSystem.DirectoryExists(tmpSrc)); Assert.IsTrue(FileSystem.DirectoryExists(tmpDest)); var destFileName = FileSystem.CombinePath(tmpDest, fileName); Assert.IsTrue(FileSystem.FileExists(destFileName)); Assert.AreEqual("test", FileSystem.ReadText(FileSystem.FileFromPath(destFileName))); }