public void CopyFileToFileWithSameName() { var t = new CopyFileTask(_sourceFilePath, _destinationFolderPath, "test.txt", new DotNetPath()); t.Execute(); string s = File.ReadAllText(_path.Combine(_destinationFolderPath, "test.txt")); Assert.AreEqual("the test\r\n", s); }
public void CopyFileToUncPath() { var sourceUncPath = PathConverter.Convert(Environment.MachineName, _path.GetFullPath(_sourceFilePath)); var destinationUncPath = PathConverter.Convert(Environment.MachineName, _path.GetFullPath(_destinationFolderPath)); var t = new CopyFileTask(sourceUncPath, destinationUncPath, null, new DotNetPath()); t.Execute(); string s = File.ReadAllText(_path.Combine(destinationUncPath, "test.txt")); Assert.AreEqual("the test\r\n", s); }
public void CopyFileToFileWithSameNameAndOverwriteReadOnly() { var dest = _path.Combine(_destinationFolderPath, "test.txt"); File.WriteAllLines(dest, new[] { "bad file" }); var destFile = new FileInfo(dest); //destFile.Attributes = (destFile.Attributes & FileAttributes.ReadOnly); destFile.IsReadOnly = true; Assert.IsTrue(destFile.IsReadOnly,"Expected the destination file to be readonly"); var t = new CopyFileTask(_sourceFilePath, _destinationFolderPath, "test.txt", new DotNetPath()); t.Execute(); string s = File.ReadAllText(_path.Combine(_destinationFolderPath, "test.txt")); Assert.AreEqual("the test\r\n", s); }