Example #1
0
        public void GetAllNotebooks()
        {
            var factory = new GraphNotebookFactory();
            var list    = factory.GetAllItems();

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

            var factory  = new GraphNotebookFactory();
            var notebook = factory.GetItem(id);

            Assert.IsNotNull(notebook);
            Assert.IsTrue(notebook.Id.Equals(id));
        }
Example #3
0
        public void CreateNotebook()
        {
            var notebookInst = new Notebook
            {
                DisplayName = "New Notebook",
            };

            var factory  = new GraphNotebookFactory();
            var notebook = factory.AddItem(notebookInst);

            Assert.IsNotNull(notebook.Id);
            Assert.IsTrue(notebook.DisplayName.Equals(notebookInst.DisplayName));
        }
Example #4
0
        /// <summary>
        /// Creates OneNote notebook
        /// </summary>
        /// <returns></returns>
        private static Notebook OpenOrCreateNotebook()
        {
            // get notebooks
            Console.WriteLine("loading notebooks ...");
            var             notebookFactory = new GraphNotebookFactory();
            List <Notebook> notebooks       = notebookFactory.GetAllItems();
            var             notebook        = notebooks.FirstOrDefault(n => n.DisplayName == "Sample Notebook");

            // no notebooks, creating new one
            if (notebook == null)
            {
                notebook = notebookFactory.AddItem(new Notebook {
                    DisplayName = "Sample Notebook"
                });
                Console.WriteLine($"Created notebook: {notebook.DisplayName}");
            }

            return(notebook);
        }