Exemplo n.º 1
0
        public void File_ReadText()
        {
            const string contents = "test";
            var          fn       = GetNewFileNameOnTempPath(".txt");

            System.IO.File.WriteAllText(fn, contents);
            var fnInfo = FileSystem.FileFromPath(fn);

            Assert.AreEqual(contents, FileSystem.ReadText(fnInfo));
        }
Exemplo n.º 2
0
 public void Image_ReadFromFile()
 {
     foreach (var file in GetTestImageFiles())
     {
         Image.ReadFromFile(FileSystem.FileFromPath(file));
         Assert.DoesNotThrow(
             () =>
         {
             using (System.IO.File.OpenRead(file)) { }     //Check that it's not locked
         },
             "File is locked after being read!");
     }
 }
Exemplo n.º 3
0
        public void File_Move()
        {
            const string contents = "test";
            var          fn       = GetNewFileNameOnTempPath(".txt");

            System.IO.File.WriteAllText(fn, contents);
            Assert.IsTrue(System.IO.File.Exists(fn));

            var dest     = GetNewFileNameOnTempPath(".txt");
            var destInfo = FileSystem.FileFromPath(dest);

            FileSystem.MoveFile(fn, dest);
            Assert.IsTrue(System.IO.File.Exists(dest));
            Assert.IsFalse(System.IO.File.Exists(fn));
            Assert.AreEqual(contents, FileSystem.ReadText(destInfo));
        }
Exemplo n.º 4
0
        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)));
        }
Exemplo n.º 5
0
        public void File_FromPath()
        {
            var fn = GetNewFileNameOnTempPath(".txt");

            Assert.AreEqual(new FileInfo(fn).FullName, FileSystem.FileFromPath(fn).FullName);
        }