Beispiel #1
0
        public void GetAllSections()
        {
            var notebookId = "0-3AE547978144BF51!117";
            var factory    = new GraphDocumentFactory();
            var list       = factory.GetAllItems(notebookId);

            Assert.IsNotNull(list);
            Assert.IsTrue(list.Count > 0);
        }
Beispiel #2
0
        public void GetSection()
        {
            var id = "0-3AE547978144BF51!131";

            var factory = new GraphDocumentFactory();
            var section = factory.GetItem(id);

            Assert.IsNotNull(section);
            Assert.IsTrue(section.Id.Equals(id));
        }
Beispiel #3
0
        public void CreateSection()
        {
            var notebookId = "0-3AE547978144BF51!117";

            var sectionInst = new Document
            {
                DisplayName = "New Notebook Section",
            };

            var factory  = new GraphDocumentFactory();
            var notebook = factory.AddItem(sectionInst, notebookId);

            Assert.IsNotNull(notebook.Id);
            Assert.IsTrue(notebook.DisplayName.Equals(sectionInst.DisplayName));
        }
Beispiel #4
0
        /// <summary>
        /// Creates OneNote section
        /// </summary>
        /// <param name="notebook"></param>
        /// <returns></returns>
        private static Document OpenOrCreateSection(Notebook notebook)
        {
            Console.WriteLine("Loading notebook sections ...");
            var             sectionFactory = new GraphDocumentFactory();
            List <Document> sections       = sectionFactory.GetAllItems();
            var             section        = sections.FirstOrDefault(s => s.DisplayName.Equals("Sample API Section"));

            if (section == null)
            {
                section = sectionFactory.AddItem(new Document {
                    DisplayName = "Sample API Section"
                }, notebook.Id);
                Console.WriteLine($"Created notebook section: {section.DisplayName}");
            }

            return(section);
        }