Пример #1
0
        private GoogleDriveSession StartSession(GoogleDriveFileSystem fs = null, GoogleDriveParameters connParams = null)
        {
            if (fs == null)
            {
                fs = GetFileSystem();
            }

            return(fs.StartSession(connParams ?? CONN_PARAMS) as GoogleDriveSession);
        }
Пример #2
0
        public void GoogleDrive_NavigateToRoot()
        {
            using (CreateApplication())
            {
                using (var fs = new GoogleDriveFileSystem("GoogleDrive"))
                {
                    using (var session = StartSession(fs))
                    {
                        var dir = session[ROOT] as FileSystemDirectory;

                        Assert.AreEqual("/", dir.ParentPath);
                        Assert.AreEqual(ROOT, dir.Path);
                    }
                }
            }
        }
Пример #3
0
        public static void Run()
        {
            using (var fs = new GoogleDriveFileSystem("GoogleDrive"))
            {
                Desc("Starting session");
                var session = fs.StartSession(CONN_PARAMS);
                Ok();

                Desc("Getting root directory");
                var root = session["/"] as FileSystemDirectory;
                Ok();

                Desc("Creating directory {0}", TEST_DIR);
                var testDir = root.CreateDirectory(TEST_DIR);
                Ok();

                Desc("file1.xml from {0}", LOCAL_FILE);
                var file1 = testDir.CreateFile("file1.xml", LOCAL_FILE);
                Ok();

                Desc("Creating an empty file2.txt");
                var file2 = testDir.CreateFile("file2.txt", 100);
                Ok();

                Desc("Creating folder1");
                var folder1 = testDir.CreateDirectory("folder1");
                Ok();

                Desc("Creating folder1/folder1-file1");
                folder1.CreateFile("folder1-file1");
                Ok();

                Desc("Creating folder1/folder1-file2");
                folder1.CreateFile("folder1-file2");
                Ok();

                Desc("Creating folder2");
                var folder2 = testDir.CreateDirectory("folder2");
                Ok();

                Desc("Creating folder2/folder1-file1");
                folder2.CreateFile("folder2-file1");
                Ok();

                Desc("Creating folder2/folder1-file2");
                folder2.CreateFile("folder2-file2");
                Ok();

                Desc("Renaming file2.txt");
                file2.Rename("renamed");
                Ok();

                Desc("Deleting file1.xml");
                file1.Delete();
                Ok();

                PrintHeader("Directory nfx-test info".Args(testDir.Name));
                PrintItemInfo(testDir);

                PrintHeader("File {0} info".Args(file2.Name));
                PrintItemInfo(file2);

                Console.WriteLine("Folders:");
                Print(testDir.SubDirectoryNames);

                Console.WriteLine("Files:");
                Print(testDir.FileNames);

                PrintHeader("Recursive");

                Console.WriteLine("Folders:");
                Print(testDir.RecursiveSubDirectoryNames);

                Console.WriteLine("Files:");
                Print(testDir.RecursiveFileNames);

                testDir.Delete();
            }
        }
Пример #4
0
 public GoogleDriveRoot(GoogleDriveFileSystem fs) : base(string.Empty, fs)
 {
     IsRoot = true;
 }