コード例 #1
0
ファイル: CopyFileTest.cs プロジェクト: davidduffett/dropkick
        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);
        }
コード例 #2
0
ファイル: CopyFileTest.cs プロジェクト: davidduffett/dropkick
        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);
        }
コード例 #3
0
ファイル: CopyFileTest.cs プロジェクト: GorelH/dropkick
        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);
        }