Esempio n. 1
0
        public void CopyTest()
        {
            string fileContents = "testing";
            File   file         = CreateFileInTempDirectory();

            System.IO.File.WriteAllText(file.Path, fileContents);

            // Test that copying to an unused location succeeds.
            File destination = CreateFileInTempDirectory();

            file.Copy(destination);
            Assert.IsTrue(System.IO.File.Exists(destination.Path), "File should exist");
            Assert.AreEqual(fileContents,
                            System.IO.File.ReadAllLines(destination.Path)[0],
                            "File contents should have been copied.");

            // Test that copying to an existing location succeeds.
            System.IO.File.Delete(destination.Path);
            System.IO.File.Create(destination.Path).Dispose();
            file.Copy(destination);
            Assert.AreEqual(fileContents,
                            System.IO.File.ReadAllLines(destination.Path)[0],
                            "File contents should have been copied.");
        }