예제 #1
0
        public async Async.Task OneNoteGetNotebooksExpandSection()
        {
            try
            {
                IOnenoteNotebooksCollectionPage notebooksPage = await graphClient.Me
                                                                .Onenote
                                                                .Notebooks
                                                                .Request()
                                                                .Expand("sections")
                                                                .GetAsync();

                Assert.IsTrue(notebooksPage.Count > 0, $"Expected at least one Notebook; Actual {notebooksPage.Count}");
                Assert.IsNotNull(notebooksPage[0].Id, "Expected an ID value; ID value is missing.");
                Assert.IsNotNull(notebooksPage[0].Sections, "Expected that the sections property was expanded; Actual: null.");
            }
            catch (Microsoft.Graph.ServiceException e)
            {
                Assert.Fail("Error code: {0}", e.Error.Code);
            }

            catch (Exception e)
            {
                Assert.Fail("Error code: {0}", e.Message);
            }
        }
예제 #2
0
        public async Task OneNoteGetNotebooksExpandSection()
        {
            try
            {
                IOnenoteNotebooksCollectionPage notebooksPage = await graphClient.Me
                                                                .Onenote
                                                                .Notebooks
                                                                .Request()
                                                                .Expand("sections")
                                                                .GetAsync();

                Assert.True(notebooksPage.Count > 0);
                Assert.NotNull(notebooksPage[0].Id);
                Assert.NotNull(notebooksPage[0].Sections);
            }
            catch (Microsoft.Graph.ServiceException e)
            {
                Assert.True(false, $"Error code: {e.Error.Code}");
            }

            catch (Exception e)
            {
                Assert.True(false, $"Error code: {e.Message}");
            }
        }
예제 #3
0
        public async Task It_accesses_a_sites_OneNote_notebooks()
        {
            try
            {
                Site site = await graphClient.Sites.Root.Request().GetAsync();

                Assert.NotNull(site);

                IOnenoteNotebooksCollectionPage notebooks = await graphClient.Sites[site.Id].Onenote.Notebooks.Request().GetAsync();
                Assert.NotNull(notebooks);
            }
            catch (Exception)
            {
                Assert.True(false, "An unexpected exception was thrown. This test case failed.");
            }
        }
예제 #4
0
        public async Async.Task OneNoteGetNotebooks()
        {
            try
            {
                IOnenoteNotebooksCollectionPage notebooksPage = await graphClient.Me
                                                                .Onenote
                                                                .Notebooks
                                                                .Request()
                                                                .GetAsync();

                Assert.True(notebooksPage.Count > 0, $"Expected at least one Notebook; Actual {notebooksPage.Count}");
                Assert.NotNull(notebooksPage[0].Id);
            }
            catch (Microsoft.Graph.ServiceException e)
            {
                Assert.True(false, $"Error code: {e.Error.Code}");
            }

            catch (Exception e)
            {
                Assert.True(false, $"Error code: {e.Message}");
            }
        }
        /// <summary>
        /// Gets the OneNote notebooks associated with the given GraphServiceClient.
        /// </summary>
        /// <param name="client">An authenticated GraphServiceClient containing the user's access token.</param>
        /// <returns>The list of notebooks owned by the user.</returns>
        public static async Task <List <Notebook> > GetMyNotebooks(GraphServiceClient client)
        {
            IOnenoteNotebooksCollectionPage results = await client.Me.Onenote.Notebooks.Request().GetAsync();

            return(results.ToList());
        }