示例#1
0
        internal async void SearchFiles_WithSingleFileAndNoChildFolder_MustSingleArray()
        {
            var fileData = new DTOs.FileSearch
            {
                value = new DTOs.File[] {
                    new DTOs.File {
                        file            = new DTOs.FileDetails {
                        },
                        id              = "fileID", name = "fileName.txt",
                        parentReference = new DTOs.DirectoryParent {
                            id = "parentID", path = "/parent/folderName"
                        }
                    }
                }
            };
            var directoryData = new DTOs.DirectorySearch
            {
                value = new DTOs.Directory[] { }
            };
            var client = ClientBuilder.Create()
                         .With("$select=id,name,createdDateTime,size,@microsoft.graph.downloadUrl,file,parentReference&$top=1000", fileData)
                         .With("$select=id,name,folder,parentReference&$top=1000", directoryData)
                         .Build();
            var service   = new OneDriveService(client);
            var directory = new DirectoryVM {
                ID = "driveID!folderID"
            };

            var value = await service.SearchFiles(directory, "*.txt");

            Assert.NotNull(value);
            Assert.Single(value);
            Assert.Equal("fileID", value[0].ID);
        }
示例#2
0
        internal async void SearchFiles_WithValidFilesAndFolder_MustResultAsSpected(string searchPattern, int searchLimit)
        {
            var fileData = new DTOs.FileSearch
            {
                value = new DTOs.File[] {
                    new DTOs.File {
                        file            = new DTOs.FileDetails {
                        },
                        id              = "file1ID", name = "file1Name.txt",
                        parentReference = new DTOs.DirectoryParent {
                            id = "parentID", path = "/parent/folderName"
                        }
                    },
                    new DTOs.File {
                        file            = new DTOs.FileDetails {
                        },
                        id              = "file2ID", name = "file2Name.zip",
                        parentReference = new DTOs.DirectoryParent {
                            id = "parentID", path = "/parent/folderName"
                        }
                    },
                    new DTOs.File {
                        file            = new DTOs.FileDetails {
                        },
                        id              = "file3ID", name = "file3Name.txt",
                        parentReference = new DTOs.DirectoryParent {
                            id = "parentID", path = "/parent/folderName"
                        }
                    }
                }
            };
            var directoryData = new DTOs.DirectorySearch
            {
                value = new DTOs.Directory[] {
                    new DTOs.Directory {
                        folder          = new DTOs.DirectoryDetails {
                        },
                        id              = "driveID!folderID", name = "folderName",
                        parentReference = new DTOs.DirectoryParent {
                            path = "/rootName"
                        }
                    }
                }
            };
            var client = ClientBuilder.Create()
                         .With("$select=id,name,createdDateTime,size,@microsoft.graph.downloadUrl,file,parentReference&$top=1000", fileData)
                         .With("$select=id,name,folder,parentReference&$top=1000", directoryData)
                         .Build();
            var service   = new OneDriveService(client);
            var directory = new DirectoryVM {
                ID = "driveID!folderID"
            };

            var value = await service.SearchFiles(directory, searchPattern, searchLimit);

            Assert.NotNull(value);
            Assert.Equal(searchLimit, value.Length);
        }
示例#3
0
        internal async void GetFiles_WithValidArgument_MustResultAsSpected()
        {
            var firstData = new DTOs.FileSearch
            {
                value = new DTOs.File[] {
                    new DTOs.File {
                        file            = new DTOs.FileDetails {
                        },
                        id              = "fileID", name = "fileName",
                        parentReference = new DTOs.DirectoryParent {
                            id = "parentID", path = "/parent/folderName"
                        }
                    }
                },
                nextLink = "$top=1000&$page=2"
            };
            var secondData = new DTOs.FileSearch
            {
                value = new DTOs.File[] {
                    new DTOs.File {
                    },
                    new DTOs.File {
                        file            = new DTOs.FileDetails {
                        },
                        id              = "file2ID", name = "file2Name",
                        parentReference = new DTOs.DirectoryParent {
                            id = "parentID", path = "/parent/folderName"
                        }
                    },
                },
                nextLink = "https://graph.microsoft.com/v1.0/"
            };
            var client = ClientBuilder
                         .Create()
                         .With("$top=1000", firstData)
                         .With("$top=1000&$page=2", secondData)
                         .Build();
            var service   = new OneDriveService(client);
            var directory = new DirectoryVM {
                ID = "driveID!folderID"
            };

            var value = await service.GetFiles(directory);

            Assert.NotNull(value);
            Assert.Equal(2, value.Length);
            Assert.Equal("fileID", value[0].ID);
            Assert.Equal("fileName", value[0].Name);
            Assert.Equal("/parent/folderName", value[0].Path);
            Assert.Equal("parentID", value[0].ParentID);
        }