Esempio n. 1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (Context != null)
            {
                var tagName = RouteValues["tag"] as string;

                ICollection <Entry> et = Cacher.GetEntriesByTag(Count, tagName, SubtextContext);
                EntryStoryList.EntryListItems       = et;
                EntryStoryList.EntryListTitle       = tagName;
                EntryStoryList.EntryListDescription = string.Format(CultureInfo.InvariantCulture,
                                                                    Resources.TagEntryList_NoEntriesForTag, et.Count,
                                                                    tagName);

                Globals.SetTitle(string.Format(CultureInfo.InvariantCulture, "{0} - {1}", Blog.Title, tagName), Context);
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (Context != null)
            {
                Uri    url     = HttpContext.Current.Request.Url;
                string tagName = HttpUtility.UrlDecode(url.Segments[url.Segments.Length - 2].Replace("/", ""));

                ICollection <Entry> et = Cacher.GetEntriesByTag(Count, tagName, SubtextContext);
                EntryStoryList.EntryListItems       = et;
                EntryStoryList.EntryListTitle       = tagName;
                EntryStoryList.EntryListDescription = string.Format(CultureInfo.InvariantCulture,
                                                                    Resources.TagEntryList_NoEntriesForTag, et.Count,
                                                                    tagName);

                Globals.SetTitle(string.Format(CultureInfo.InvariantCulture, "{0} - {1}", Blog.Title, tagName), Context);
            }
        }
Esempio n. 3
0
        public void GetEntriesByTag_WithEntriesInCache_RetrievesFromCache()
        {
            // arrange
            var entry = new Entry(PostType.BlogPost)
            {
                Title = "Testing Cacher"
            };
            var context = new Mock <ISubtextContext>();

            context.Setup(c => c.Blog).Returns(new Blog {
                Id = 1001
            });
            context.Setup(c => c.Cache["ET:Count10TagTestTagBlogId1001"]).Returns(new List <Entry> {
                entry
            });
            context.Setup(c => c.Repository.GetEntriesByTag(10, "TestTag")).Throws(new Exception("Repository should not have been accessed"));

            // act
            var cachedEntries = Cacher.GetEntriesByTag(10 /*count*/, "TestTag" /*tag*/, context.Object);

            // assert
            Assert.AreEqual(entry, cachedEntries.First());
        }