コード例 #1
0
        public void WindowsFileDelete()
        {
            if (!Global.TestWindows)
            {
                throw new Exception("Windows Tests Are Not Enabled.  Set Global.TestWindows To True To Enable.");
            }

            String path = Path.Combine(Global.WindowsWorkingPath, $"{Global.RandomFile}");

            Console.WriteLine(path);
            ZephyrFile file = new WindowsZephyrFile(path);

            file.Create();
            file.Close();
            file.Delete();
            Assert.That(!Utilities.Exists(path, Global.Clients));
        }
コード例 #2
0
        public void WindowsFileClose()
        {
            if (!Global.TestWindows)
            {
                throw new Exception("Windows Tests Are Not Enabled.  Set Global.TestWindows To True To Enable.");
            }

            String path = Path.Combine(Global.WindowsWorkingPath, Global.RandomFile);

            Console.WriteLine(path);
            ZephyrFile file = new WindowsZephyrFile(path);

            file.Open(AccessType.Write);
            Assert.That(file.Stream.CanWrite);
            file.Close();
            Assert.IsNull(file.Stream);
            file.Delete();
        }
コード例 #3
0
        public void WindowsFileCreateDirectoryMethod()
        {
            if (!Global.TestWindows)
            {
                throw new Exception("Windows Tests Are Not Enabled.  Set Global.TestWindows To True To Enable.");
            }

            String path = Path.Combine(Global.WindowsWorkingPath, $"{Global.RandomFile}");

            Console.WriteLine(path);
            ZephyrFile file = new WindowsZephyrFile(path);

            ZephyrDirectory dir = Global.WindowsWorkingDirectory.CreateDirectory(path);

            Assert.That(!dir.Exists);
            dir.Create();
            Assert.That(dir.Exists);
            dir.Delete();
            file.Delete();
        }
コード例 #4
0
        public void WindowsFileProperties()
        {
            if (!Global.TestWindows)
            {
                throw new Exception("Windows Tests Are Not Enabled.  Set Global.TestWindows To True To Enable.");
            }

            String fileName = Global.RandomFile;
            String path     = Path.Combine(Global.WindowsWorkingPath, $"{fileName}");

            Console.WriteLine(path);
            ZephyrFile file = new WindowsZephyrFile(path);

            file.Create();
            file.Close();
            file.Open(AccessType.Write);

            Console.WriteLine($"FullName : {file.FullName}");
            Assert.AreEqual(file.FullName, path);

            Console.WriteLine($"Name     : {file.Name}");
            Assert.AreEqual(file.Name, fileName);

            Console.WriteLine($"Exists   : {file.Exists}");
            Assert.That(file.Exists);

            Console.WriteLine($"Stream   : {(file.Stream.CanWrite ? "Writable" : "Not Writable")}");
            Assert.That(file.Stream.CanWrite);

            Console.WriteLine($"IsOpen   : {file.IsOpen}");
            Assert.That(file.IsOpen);

            Console.WriteLine($"CanRead  : {file.CanRead}");
            Assert.That(!file.CanRead);

            Console.WriteLine($"CanWrite : {file.CanWrite}");
            Assert.That(file.CanWrite);

            file.Close();
            file.Delete();
        }
コード例 #5
0
        public void WindowsFileReopen()
        {
            if (!Global.TestWindows)
            {
                throw new Exception("Windows Tests Are Not Enabled.  Set Global.TestWindows To True To Enable.");
            }

            String path = Path.Combine(Global.WindowsWorkingPath, $"{Global.RandomFile}");

            Console.WriteLine(path);
            ZephyrFile file = new WindowsZephyrFile(path);

            System.IO.Stream stream = file.Open(AccessType.Read);
            Assert.That(stream.CanRead);
            Assert.That(!stream.CanWrite);

            stream = file.Reopen(AccessType.Write);
            Assert.That(!stream.CanRead);
            Assert.That(stream.CanWrite);

            file.Close();
            file.Delete();
        }
コード例 #6
0
        public void WindowsFileCopyToWindowsFile()
        {
            if (!Global.TestWindows)
            {
                throw new Exception("Windows Tests Are Not Enabled.  Set Global.TestWindows To True To Enable.");
            }

            ZephyrDirectory source = Global.StageTestFilesToWindows();

            List <ZephyrFile> files = (List <ZephyrFile>)source.GetFiles();

            Assert.IsNotEmpty(files);
            foreach (ZephyrFile file in files)
            {
                String     path = Path.Combine(Global.WindowsWorkingPath, Global.RandomFile);
                ZephyrFile dest = new WindowsZephyrFile(path);
                file.CopyTo(dest);
                Assert.That(File.Exists(path));
                dest.Delete();
            }

            source.Delete();
        }