public void RecentActivity_CheckCacheContainsNewRecentActivityForums_ExpectRecentActivityForums() { IDnaDataReader reader; IDnaDataReaderCreator creator; ICacheManager cache = new TestCacheManager(); List<DataReaderFactory.TestDatabaseRow> databaseRows = new List<DataReaderFactory.TestDatabaseRow>(); databaseRows.Add(new RecentActivityForumTestDatabaseRow(123456789, 789456123, "Testing", "MostRecent", "Most Recent Comments", true, false)); DataReaderFactory.CreateMockedDataBaseObjects(mocks, "gettopfives2", out creator, out reader, databaseRows); var recentAcivity = RecentActivity.GetSiteRecentActivity(1, creator, mocks.DynamicMock<IDnaDiagnostics>(), cache); Assert.AreEqual(1, recentAcivity.MostRecentConversations.topFiveForumList.Count); XmlDocument doc = SerializeToXML(recentAcivity); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTCONVERSATIONS/FORUM")); recentAcivity = RecentActivity.GetSiteRecentActivity(1, creator, mocks.DynamicMock<IDnaDiagnostics>(), cache); Assert.AreEqual(1, recentAcivity.MostRecentConversations.topFiveForumList.Count); doc = SerializeToXML(recentAcivity); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTCONVERSATIONS/FORUM")); }
public void RecentActivity_GetRecentActivityForumsFromDatabaseNotCacheWhenExpired_ExpectRecentActivityForums() { IDnaDataReader reader; IDnaDataReaderCreator creator; ICacheManager cache = new TestCacheManager(); RecentActivity RecentActivity; { List<DataReaderFactory.TestDatabaseRow> databaseRows = new List<DataReaderFactory.TestDatabaseRow>(); databaseRows.Add(new RecentActivityForumTestDatabaseRow(123456789, 789456123, "Testing <b>with tags</b> & encodings", "MostRecent", "Most Recent Comments", true, false)); DataReaderFactory.CreateMockedDataBaseObjects(mocks, "gettopfives2", out creator, out reader, databaseRows); RecentActivity = RecentActivity.GetSiteRecentActivity(1, creator, mocks.DynamicMock<IDnaDiagnostics>(), cache); Assert.AreEqual(1, RecentActivity.MostRecentConversations.topFiveForumList.Count); XmlDocument doc = SerializeToXML(RecentActivity); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTCONVERSATIONS/FORUM")); Assert.AreEqual("Testing with tags & encodings", RecentActivity.MostRecentConversations.topFiveForumList[0].Subject); } // Expire the cached RecentActivity var cachedRecentActivity = (CachableBase<RecentActivity>)cache.GetData("BBC.Dna.Objects.RecentActivity, BBC.Dna.Objects, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c2c5f2d0ba0d9887|1|"); ((RecentActivity)cachedRecentActivity).CacheExpireryDate = DateTime.Now.AddMinutes(-10); { List<DataReaderFactory.TestDatabaseRow> databaseRows = new List<DataReaderFactory.TestDatabaseRow>(); databaseRows.Add(new RecentActivityForumTestDatabaseRow(123456789, 789456123, "Testing", "MostRecent", "Most Recent Comments", true, false)); DataReaderFactory.CreateMockedDataBaseObjects(mocks, "gettopfives2", out creator, out reader, databaseRows); RecentActivity = RecentActivity.GetSiteRecentActivity(1, creator, mocks.DynamicMock<IDnaDiagnostics>(), cache); Assert.AreEqual(1, RecentActivity.MostRecentConversations.topFiveForumList.Count); XmlDocument doc = SerializeToXML(RecentActivity); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTCONVERSATIONS/FORUM")); } }