예제 #1
0
 public void Get_NonexistentCid()
 {
     using (var router = new ContentRouter())
     {
         var providers = router.Get(cid1);
         Assert.AreEqual(0, providers.Count());
     }
 }
예제 #2
0
        public void Get_Expired()
        {
            using (var router = new ContentRouter())
            {
                router.Add(cid1, self.Id, DateTime.MinValue);

                var providers = router.Get(cid1);
                Assert.AreEqual(0, providers.Count());
            }
        }
예제 #3
0
        public void Add()
        {
            using (var router = new ContentRouter())
            {
                router.Add(cid1, self.Id);

                var providers = router.Get(cid1);
                Assert.AreEqual(1, providers.Count());
                Assert.AreEqual(self.Id, providers.First());
            }
        }
예제 #4
0
        public void Add_MultipleProviders()
        {
            using (var router = new ContentRouter())
            {
                router.Add(cid1, self.Id);
                router.Add(cid1, other.Id);

                var providers = router.Get(cid1).ToArray();
                Assert.AreEqual(2, providers.Length);
                CollectionAssert.Contains(providers, self.Id);
                CollectionAssert.Contains(providers, other.Id);
            }
        }
예제 #5
0
        public void RootPageWithNonNullUrlSegment()
        {
            var root = new Page
            {
                UrlSegment = "lorem",
            };

            var result = new ContentRouter(new RootContentRouter(new TestContentSegmentRouter(root)), new TestRoutableRootContentProvider(root)).RouteContent(new List <string> {
                "lorem"
            }, null);

            Assert.Same(root, result);
        }
예제 #6
0
        public void PageUnderRootPageWithNullUrlSegment()
        {
            var root = new Page
            {
                Id         = "root",
                UrlSegment = null,
            };

            var page = new Page
            {
                ParentId   = root.Id,
                UrlSegment = "ipsum",
            };

            var result = new ContentRouter(new RootContentRouter(new TestContentSegmentRouter(root, page)), new TestRoutableRootContentProvider(root)).RouteContent(new List <string> {
                "ipsum"
            }, null);

            Assert.Same(page, result);
        }