コード例 #1
0
 public void SiteMapReader_CanReadNodesFromTheDefaultFileIfItIsPresent()
 {
     var reader = new JsonSiteMapReader();
     var nodes = reader.GetAllNodes();
     Assert.IsNotNull(nodes);
     Assert.AreEqual(8, nodes.Count());
 }
コード例 #2
0
 public void SiteMapReader_CanReadNodesFromACustomJsonFile()
 {
     var reader = new JsonSiteMapReader("sitemap.json");
     var nodes = reader.GetAllNodes();
     Assert.IsNotNull(nodes);
     Assert.AreEqual(8, nodes.Count());
 }
コード例 #3
0
 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 );
 }
コード例 #4
0
 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() );
 }
コード例 #5
0
 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() );
 }
コード例 #6
0
        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 );
        }
コード例 #7
0
 public void SiteMapReader_ThrowsAnExceptionIfTheInputFileDoesNotExist()
 {
     var reader = new JsonSiteMapReader("nonexistant.json");
     var nodes = reader.GetAllNodes();
 }