Beispiel #1
0
        public void Gets_Content_Of_Type_From_Cache()
        {
            var program = "news";
            var tree    = ParseTree(program);
            var cache   = Mock.Of <IContentCache>();

            var visitor = new PublishedCacheQueryVisitor(cache);
            var result  = visitor.Execute((IVisitable)tree.Root.AstNode);

            Mock.Get(cache).Verify(c => c.GetContentByXPath("//news"));
        }
Beispiel #2
0
        public void Limits_Ordered_Result()
        {
            var program = "latest 1 article";
            var tree    = ParseTree(program);
            var cache   = Mock.Of <IContentCache>();

            Mock.Get(cache).Setup(c => c.GetContentByXPath("//article")).Returns(new List <IPublishedContent>
            {
                Mock.Of <IPublishedContent>(c => c.CreateDate == DateTime.Today),
                Mock.Of <IPublishedContent>(c => c.CreateDate == DateTime.Today.AddDays(1))
            });

            var visitor = new PublishedCacheQueryVisitor(cache);
            var result  = visitor.Execute((IVisitable)tree.Root.AstNode);

            Assert.That(result.Single(), Has.Property("CreateDate").EqualTo(DateTime.Today.AddDays(1)));
        }