public void GetNodesForRoles_ReturnsAllRolesIfAllOfThemAreRootNodes()
        {
            var mockReader = GetMockReader();
            ISiteMapService service = new SiteMapService(mockReader.Object);

            var nodes = service.GetNodesForRole("Admin");

            Assert.IsNotNull(nodes);
            Assert.AreEqual(2, nodes.Count());
        }
        public void RawSiteMapNodes_ReturnsTheRawNodesUnchanged()
        {
            var mockReader = new Mock<ISiteMapReader>();
            mockReader.Setup(x => x.GetAllNodes()).Returns(new[] { new SiteMapNode { Id = 1 } });
            ISiteMapService service = new SiteMapService(mockReader.Object);

            IEnumerable<SiteMapNode> nodes = service.RawSiteMapNodes;

            Assert.IsNotNull(nodes);
            Assert.AreEqual(1, nodes.Count());
        }
        public void GetNodesForRoles_GroupsTheNodesProperly()
        {
            Mock<ISiteMapReader> mockReader = GetMockReader();
            ISiteMapService service = new SiteMapService(mockReader.Object);

            var nodes = service.GetNodesForRole("Admin");

            Assert.IsNotNull(nodes);

            SiteMapNode firstNode = nodes.SingleOrDefault(x => x.Id == 1);
            SiteMapNode secondNode = nodes.SingleOrDefault(x => x.Id == 4);

            Assert.AreEqual(2, firstNode.Children.Count());
            Assert.AreEqual(3, secondNode.Children.Count());
        }
Esempio n. 4
0
 public static void Configure( ISiteMapReader siteMapReader )
 {
     ISiteMapService service = new SiteMapService( siteMapReader );
     CachedSiteMapService.Initialize( service );
 }