Ejemplo n.º 1
0
        /// <summary>
        /// Creates environmant with next drive FS structure:
        //  c:
        //      documents
        //          resume.txt
        //          my-photos.jpg
        //      photos
        //          photos2015
        //              lenovo
        //              turkey
        //              PHOTO1.jpg
        //              PHOTO2.jpg
        //              PHOTO3.jpg
        //              info.txt
        //
        //  Root directory: c:/photos.
        /// </summary>
        public static async Task<TestEnvironment> CreateSimpleAsync()
        {
            byte[] info_txt = Encoding.ASCII.GetBytes("Hello, World!");
            byte[] photo1_jpg = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            var storage = new MockStorage("mock-1");
            storage.AddFile(new MockStorageFile(storage, "PHOTO1.jpg") { content = photo1_jpg });
            storage.AddFile(new MockStorageFile(storage, "info.txt") { content = info_txt });

            var account = new Account(storage);
            var drive = new MockDrive(account);
            var root = new MockDriveFile(drive, "c:", isFolder: true);

            var docs = root.Add(new MockDriveFile(drive, "documents", isFolder: true));
            docs.Add(new MockDriveFile(drive, "resume.txt"));
            docs.Add(new MockDriveFile(drive, "my-photo.jpg"));
            var photos = root.Add(new MockDriveFile(drive, "photos", isFolder: true));
            var photos2015 = photos.Add(new MockDriveFile(drive, "photos2015", isFolder: true));
            var lenovo = photos.Add(new MockDriveFile(drive, "lenovo", isFolder: true));
            var turkey = photos.Add(new MockDriveFile(drive, "turkey", isFolder: true));
            await photos2015.Add(new MockDriveFile(drive, "PHOTO1.jpg", isImage: true) { content = photo1_jpg }).SetStorageFileIdAsync("photo1-jpg", CancellationToken.None);
            var image2 = new MockDriveFile(drive, "PHOTO2.jpg", isImage: true);
            image2.content = new byte[] {
                1, 1, 1, 1, 1,
                0, 0, 0, 0, 0,
                1, 1, 1, 1, 1
            };
            photos2015.Add(image2); // unsync
            photos2015.Add(new MockDriveFile(drive, "PHOTO3.jpg", isImage: true)); // unsync
            await photos2015.Add(new MockDriveFile(drive, "info.txt") { content = info_txt }).SetStorageFileIdAsync("info-txt", CancellationToken.None);
            drive.root = root;
            drive.rootFolder = photos;
            return new TestEnvironment(storage, drive);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates environmant with next drive FS structure:
        //  c:
        //      documents
        //          resume.txt
        //          my-photos.jpg
        //      photos
        //          photos2015
        //              lenovo
        //              turkey
        //              PHOTO1.jpg
        //              PHOTO2.jpg
        //              PHOTO3.jpg
        //              info.txt
        //
        //  Root directory: c:/photos.
        /// </summary>
        public static async Task <TestEnvironment> CreateSimpleAsync()
        {
            byte[] info_txt   = Encoding.ASCII.GetBytes("Hello, World!");
            byte[] photo1_jpg = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            var    storage    = new MockStorage("mock-1");

            storage.AddFile(new MockStorageFile(storage, "PHOTO1.jpg")
            {
                content = photo1_jpg
            });
            storage.AddFile(new MockStorageFile(storage, "info.txt")
            {
                content = info_txt
            });

            var account = new Account(storage);
            var drive   = new MockDrive(account);
            var root    = new MockDriveFile(drive, "c:", isFolder: true);

            var docs = root.Add(new MockDriveFile(drive, "documents", isFolder: true));

            docs.Add(new MockDriveFile(drive, "resume.txt"));
            docs.Add(new MockDriveFile(drive, "my-photo.jpg"));
            var photos     = root.Add(new MockDriveFile(drive, "photos", isFolder: true));
            var photos2015 = photos.Add(new MockDriveFile(drive, "photos2015", isFolder: true));
            var lenovo     = photos.Add(new MockDriveFile(drive, "lenovo", isFolder: true));
            var turkey     = photos.Add(new MockDriveFile(drive, "turkey", isFolder: true));
            await photos2015.Add(new MockDriveFile(drive, "PHOTO1.jpg", isImage : true) { content = photo1_jpg }).SetStorageFileIdAsync("photo1-jpg", CancellationToken.None);

            var image2 = new MockDriveFile(drive, "PHOTO2.jpg", isImage: true);

            image2.content = new byte[] {
                1, 1, 1, 1, 1,
                0, 0, 0, 0, 0,
                1, 1, 1, 1, 1
            };
            photos2015.Add(image2);                                                // unsync
            photos2015.Add(new MockDriveFile(drive, "PHOTO3.jpg", isImage: true)); // unsync
            await photos2015.Add(new MockDriveFile(drive, "info.txt") { content = info_txt }).SetStorageFileIdAsync("info-txt", CancellationToken.None);

            drive.root       = root;
            drive.rootFolder = photos;
            return(new TestEnvironment(storage, drive));
        }
Ejemplo n.º 3
0
 public TestEnvironment(MockStorage storage, IEnumerable<MockDrive> drives)
 {
     Account = new Account(storage);
     Account.Drives.AddRange(drives);
 }
Ejemplo n.º 4
0
 public TestEnvironment(MockStorage storage, params MockDrive[] drives)
 {
     Account = new Account(storage);
     Account.Drives.AddRange(drives);
 }
Ejemplo n.º 5
0
 public TestEnvironment(MockStorage storage, IEnumerable <MockDrive> drives)
 {
     Account = new Account(storage);
     Account.Drives.AddRange(drives);
 }
Ejemplo n.º 6
0
 public TestEnvironment(MockStorage storage, params MockDrive[] drives)
 {
     Account = new Account(storage);
     Account.Drives.AddRange(drives);
 }