Beispiel #1
0
        public void DeleteSearchNavigationNodeTest()
        {
            using (var clientContext = TestCommon.CreateClientContext())
            {
                var web = clientContext.Web;

                // First clear all search nav nodes
                var nodeCollection = web.LoadSearchNavigation();
                foreach (var node in nodeCollection.ToList())
                {
                    node.DeleteObject();
                }
                clientContext.ExecuteQueryRetry();

                web.AddNavigationNode("Test Node", new Uri("https://www.microsoft.com"), string.Empty, NavigationType.SearchNav);

                web.DeleteNavigationNode("Test Node", string.Empty, NavigationType.SearchNav);

                NavigationNodeCollection searchNavigation = web.LoadSearchNavigation();

                if (searchNavigation.Any())
                {
                    var navNode = searchNavigation.FirstOrDefault(n => n.Title == "Test Node");
                    Assert.IsNull(navNode);
                }
            }
        }
Beispiel #2
0
        public void DeleteSearchNavigationNodeTest()
        {
            using (var clientContext = TestCommon.CreateClientContext())
            {
                var web = clientContext.Web;

                web.AddNavigationNode("Test Node", new Uri("https://www.microsoft.com"), string.Empty, NavigationType.SearchNav);

                web.DeleteNavigationNode("Test Node", string.Empty, NavigationType.SearchNav);

                NavigationNodeCollection searchNavigation = web.LoadSearchNavigation();

                if (searchNavigation.Any())
                {
                    var navNode = searchNavigation.FirstOrDefault(n => n.Title == "Test Node");
                    Assert.IsNull(navNode);
                }
            }
        }
Beispiel #3
0
        public void AddSearchNavigationNodeTest()
        {
            using (var clientContext = TestCommon.CreateClientContext())
            {
                var web = clientContext.Web;

                web.AddNavigationNode("Test Node", new Uri("https://www.microsoft.com"), string.Empty, NavigationType.SearchNav);

                NavigationNodeCollection searchNavigation = web.LoadSearchNavigation();

                Assert.IsTrue(searchNavigation.AreItemsAvailable);

                if (searchNavigation.Any())
                {
                    var navNode = searchNavigation.FirstOrDefault(n => n.Title == "Test Node");
                    Assert.IsNotNull(navNode);
                    navNode.DeleteObject();
                    clientContext.ExecuteQueryRetry();
                }
            }
        }