예제 #1
0
        public void MoveTest()
        {
            string fname    = "test123.txt";
            string filePath = Path.Combine(_testDirectory, fname);
            string newDir   = Path.Combine(_testDirectory, "testDir");
            string newFile  = Path.Combine(newDir, fname);

            File target = new File(filePath);

            if (!System.IO.Directory.Exists(newDir))
            {
                System.IO.Directory.CreateDirectory(newDir);
            }

            target.Create();

            System.IO.File.Delete(newFile);

            target.Move(new File(newFile));
            Assert.IsTrue(System.IO.File.Exists(newFile), "File has not been moved");

            //check pathname is correct
            Assert.AreEqual(newFile, target.Path, "Filename has not been updated internally");
            // And parent directory too
            Assert.That(target.ParentDirectory.Path, Is.EqualTo(newDir + "\\"));

            System.IO.File.Delete(newFile);
        }
예제 #2
0
        public void CreateTest()
        {
            string filePath = Path.Combine(_testDirectory, "test123.txt");

            System.IO.File.Delete(filePath);

            File target = new File(filePath);

            target.Create();
            Assert.IsTrue(System.IO.File.Exists(filePath), "File should exist");
        }
예제 #3
0
        public void CopyToDirectoryTest()
        {
            string fname    = "test123.txt";
            string filePath = Path.Combine(_testDirectory, fname);
            File   source   = new File(filePath);

            source.Create();

            File destination = new File(new Directory(Path.Combine(_testDirectory, "CopyToDirectory")), fname);

            destination.ParentDirectory.Delete();
            destination.ParentDirectory.Create();
            source.CopyToDirectory(destination.ParentDirectory);
            Assert.AreEqual(true, destination.Exists);
        }
예제 #4
0
        public void RenameTest()
        {
            string fname    = "test123.txt";
            string filePath = Path.Combine(_testDirectory, fname);
            File   target   = new File(filePath);

            target.Create();

            string fname2    = "test123d.txt";
            string filePath2 = Path.Combine(_testDirectory, fname2);

            target.Rename(filePath2);

            Assert.IsTrue(System.IO.File.Exists(filePath2), "File should exist");
            Assert.IsFalse(System.IO.File.Exists(filePath), "File should not exist");
            Assert.AreEqual(target.Path, filePath2, "File name should be equal");
        }