Exemplo n.º 1
0
        public void AwsS3FileWriteAllBytes()
        {
            if (!Global.TestAws)
            {
                throw new Exception("Amazon S3 Tests Are Not Enabled.  Set Global.TestAws To True To Enable.");
            }

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

            Assert.IsNotEmpty(files);
            foreach (ZephyrFile file in files)
            {
                Console.WriteLine($"File: {file.FullName}");
                byte[]     bytes   = file.ReadAllBytes();
                string     outPath = $"{source.FullName}{Global.RandomFile}";
                ZephyrFile outFile = source.CreateFile(outPath);
                outFile.WriteAllBytes(bytes);
                byte[] outBytes = outFile.ReadAllBytes();
                Assert.AreEqual(bytes.Length, outBytes.Length);
                for (int i = 0; i < bytes.Length; i++)
                {
                    Assert.AreEqual(bytes[i], outBytes[i]);
                }

                outFile.Delete();
            }

            source.Delete();
        }
Exemplo n.º 2
0
        public void WindowsFileWriteAllLines()
        {
            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)
            {
                Console.WriteLine($"File: {file.FullName}");
                string[]   lines   = file.ReadAllLines();
                string     outPath = Path.Combine(source.FullName, Global.RandomFile);
                ZephyrFile outFile = source.CreateFile(outPath);
                outFile.WriteAllLines(lines);
                string[] outLines = outFile.ReadAllLines();
                Assert.AreEqual(lines.Length, outLines.Length);
                for (int i = 0; i < lines.Length; i++)
                {
                    Assert.AreEqual(lines[i], outLines[i]);
                }

                outFile.Delete();
            }

            source.Delete();
        }
Exemplo n.º 3
0
        public void AwsS3FileWriteAllText()
        {
            if (!Global.TestAws)
            {
                throw new Exception("Amazon S3 Tests Are Not Enabled.  Set Global.TestAws To True To Enable.");
            }

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

            Assert.IsNotEmpty(files);
            foreach (ZephyrFile file in files)
            {
                Console.WriteLine($"File: {file.FullName}");
                string     content = file.ReadAllText();
                string     outPath = $"{source.FullName}{Global.RandomFile}";
                ZephyrFile outFile = source.CreateFile(outPath);
                outFile.WriteAllText(content);
                string outText = outFile.ReadAllText();
                Assert.AreEqual(content, outText);

                outFile.Delete();
            }

            source.Delete();
        }
Exemplo n.º 4
0
        public void AwsS3FileMoveToAwsS3Directory()
        {
            if (!Global.TestAws)
            {
                throw new Exception("Amazon S3 Tests Are Not Enabled.  Set Global.TestAws To True To Enable.");
            }

            ZephyrDirectory source = Global.StageTestFilesToAws();
            string          path   = $"{Global.AwsS3WorkingPath}{Global.RandomDirectory}/";
            ZephyrDirectory target = new AwsS3ZephyrDirectory(Global.Clients.aws, path);

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

            Assert.IsNotEmpty(files);
            foreach (ZephyrFile file in files)
            {
                String filePath = $"{target.FullName}{file.Name}";
                file.MoveTo(target);
                Assert.That(Utilities.Exists(filePath, Global.Clients));
                Assert.That(!file.Exists);
                Utilities.Delete(filePath, Global.Clients);
            }

            source.Delete();
        }
Exemplo n.º 5
0
        public void WindowsFileMoveToWindowsDirectory()
        {
            if (!Global.TestWindows)
            {
                throw new Exception("Windows Tests Are Not Enabled.  Set Global.TestWindows To True To Enable.");
            }

            ZephyrDirectory source = Global.StageTestFilesToWindows();
            string          path   = Path.Combine(Global.WindowsWorkingPath, $"{Global.RandomDirectory}\\");
            ZephyrDirectory target = new WindowsZephyrDirectory(path);

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

            Assert.IsNotEmpty(files);
            foreach (ZephyrFile file in files)
            {
                String filePath = Path.Combine(target.FullName, file.Name);
                file.MoveTo(target);
                Assert.That(File.Exists(filePath));
                Assert.That(!file.Exists);
                Utilities.Delete(filePath, Global.Clients);
            }

            source.Delete();
        }
Exemplo n.º 6
0
        public void WindowsDirectoryGetDirectoriesandGetFiles()
        {
            ZephyrDirectory dir = Global.StageTestFilesToWindows();

            List <ZephyrDirectory> dirs = (List <ZephyrDirectory>)(dir.GetDirectories());

            Console.WriteLine($"Found [{dirs.Count}] Sub-directories.");
            Assert.AreEqual(dirs.Count, 3);

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

            Console.WriteLine($"Found [{files.Count}] Files.");
            Assert.AreEqual(files.Count, 5);

            dir.Delete(verbose: false);
        }
Exemplo n.º 7
0
        public static string DirectoryObjectCounts(ZephyrDirectory dir)
        {
            List <ZephyrDirectory> dirs  = (List <ZephyrDirectory>)dir.GetDirectories();
            List <ZephyrFile>      files = (List <ZephyrFile>)dir.GetFiles();

            //TODO: Sort Directories To Ensure Counts Come Back In Same Order

            String counts = $"{dirs.Count},{files.Count}";

            foreach (ZephyrDirectory childDir in dirs)
            {
                counts = $"{counts},{DirectoryObjectCounts(childDir)}";
            }

            return(counts);
        }
Exemplo n.º 8
0
        public void AwsS3FileReadAllText()
        {
            if (!Global.TestAws)
            {
                throw new Exception("Amazon S3 Tests Are Not Enabled.  Set Global.TestAws To True To Enable.");
            }

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

            Assert.IsNotEmpty(files);
            foreach (ZephyrFile file in files)
            {
                Console.WriteLine($"File: {file.FullName}");
                String content = file.ReadAllText();
                Console.WriteLine(content);
                Assert.IsNotEmpty(content);
            }

            source.Delete();
        }
Exemplo n.º 9
0
        public void AwsS3DirectoryGetDirectoriesandGetFiles()
        {
            if (!Global.TestAws)
            {
                throw new Exception("Amazon S3 Tests Are Not Enabled.  Set Global.TestAws To True To Enable.");
            }

            ZephyrDirectory dir = Global.StageTestFilesToAws();

            List <ZephyrDirectory> dirs = (List <ZephyrDirectory>)(dir.GetDirectories());

            Console.WriteLine($"Found [{dirs.Count}] Sub-directories.");
            Assert.AreEqual(dirs.Count, 3);

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

            Console.WriteLine($"Found [{files.Count}] Files.");
            Assert.AreEqual(files.Count, 5);

            dir.Delete(verbose: false);
        }
Exemplo n.º 10
0
        public void AwsS3FileCopyToAwsS3File()
        {
            if (!Global.TestAws)
            {
                throw new Exception("Amazon S3 Tests Are Not Enabled.  Set Global.TestAws To True To Enable.");
            }

            ZephyrDirectory source = Global.StageTestFilesToAws();

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

            Assert.IsNotEmpty(files);
            foreach (ZephyrFile file in files)
            {
                String     path = $"{Global.AwsS3WorkingPath}{Global.RandomFile}";
                ZephyrFile dest = new AwsS3ZephyrFile(Global.Clients.aws, path);
                file.CopyTo(dest);
                Assert.That(Utilities.Exists(path, Global.Clients));
                dest.Delete();
            }

            source.Delete();
        }
Exemplo n.º 11
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();
        }
Exemplo n.º 12
0
        public void WindowsFileReadAllBytes()
        {
            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)
            {
                Console.WriteLine($"File: {file.FullName}");
                byte[] content = file.ReadAllBytes();
                foreach (byte b in content)
                {
                    Console.Write(b);
                }
                Assert.IsNotEmpty(content);
            }

            source.Delete();
        }