public void GetEntriesForDay_WithEntriesNotInCache_RetrievesFromRepositoryAndInsertsInCache() { // arrange var entry = new Entry(PostType.BlogPost) { Title = "Testing Cacher" }; var dateTime = DateTime.ParseExact("20090123", "yyyyMMdd", CultureInfo.InvariantCulture); var context = new Mock <ISubtextContext>(); context.Setup(c => c.Blog).Returns(new Blog { Id = 1001 }); context.Setup(c => c.Cache["EntryDay:Date20090123Blog1001"]).Returns(null); context.Setup(c => c.Repository.GetEntryDay(dateTime)).Returns(new EntryDay(dateTime, new List <Entry> { entry })); // act var cachedEntries = Cacher.GetEntriesForDay(dateTime, context.Object); // assert Assert.AreEqual(entry, cachedEntries.First()); context.Verify(c => c.Cache["EntryDay:Date20090123Blog1001"]); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (Context != null) { try { DateTime dayDate = SubtextContext.RequestContext.GetDateFromRequest(); SingleDay.CurrentDay = Cacher.GetEntriesForDay(dayDate, SubtextContext); Globals.SetTitle( string.Format(CultureInfo.InvariantCulture, "{0} - {1} Entries", Blog.Title, dayDate.ToString("D", CultureInfo.CurrentCulture)), Context); } catch (FormatException) { //Somebody probably is messing with the url. //404 is set in filenotfound - DF Response.Redirect("~/SystemMessages/FileNotFound.aspx"); } } }