public void SiteMapReader_CanReadNodesFromTheDefaultFileIfItIsPresent()
 {
     var reader = new JsonSiteMapReader();
     var nodes = reader.GetAllNodes();
     Assert.IsNotNull(nodes);
     Assert.AreEqual(8, nodes.Count());
 }
 public void SiteMapReader_CanReadNodesFromACustomJsonFile()
 {
     var reader = new JsonSiteMapReader("sitemap.json");
     var nodes = reader.GetAllNodes();
     Assert.IsNotNull(nodes);
     Assert.AreEqual(8, nodes.Count());
 }
 public void GetAllNodes_ThrowsAFileLoadException_IfFileIsEmpty()
 {
     var stream = new MemoryStream( Encoding.ASCII.GetBytes( "" ) );
     ISiteMapReader reader = new JsonSiteMapReader( stream );
     var nodes = reader.GetAllNodes();
     Assert.IsNotNull( nodes );
     Assert.IsInstanceOf<IEnumerable<SiteMapNode>>( nodes );
 }
 public void GetAllNodes_ReturnsAnIEnumerableOfSiteMapNodesWithMoreThanOneNode()
 {
     var stream = new MemoryStream( Encoding.ASCII.GetBytes( GetValidRawJson() ) );
     ISiteMapReader reader = new JsonSiteMapReader( stream );
     var nodes = reader.GetAllNodes();
     Assert.IsNotNull( nodes );
     Assert.IsInstanceOf<IEnumerable<SiteMapNode>>( nodes );
     Assert.AreEqual( 1, nodes.Count() );
 }
 public void GetAllNodes_ReturnsAnEmptyList_WhenFileDoesntHaveAnyNodes()
 {
     var stream = new MemoryStream( Encoding.ASCII.GetBytes( " " ) );
     ISiteMapReader reader = new JsonSiteMapReader( stream );
     var nodes = reader.GetAllNodes();
     Assert.IsNotNull( nodes );
     Assert.IsInstanceOf<IEnumerable<SiteMapNode>>( nodes );
     Assert.AreEqual( 0, nodes.Count() );
 }
        public void GetAllNodes_ParsesTheNodeFileAsExpected()
        {
            var stream = new MemoryStream( Encoding.ASCII.GetBytes( GetValidRawJson() ) );
            ISiteMapReader reader = new JsonSiteMapReader( stream );
            var nodes = reader.GetAllNodes();
            SiteMapNode node = nodes.FirstOrDefault();

            Assert.AreEqual( 1, node.Id );
            Assert.AreEqual( "Index", node.Action );
            Assert.AreEqual( "Home", node.Controller );
            Assert.AreEqual( "HOME", node.Title );
            Assert.AreEqual( 0, node.ParentId );
            Assert.AreEqual( "Anonymous,Administrator,Dashboard", node.Role );
        }
 public void SiteMapReader_ThrowsAnExceptionIfTheInputFileDoesNotExist()
 {
     var reader = new JsonSiteMapReader("nonexistant.json");
     var nodes = reader.GetAllNodes();
 }