public void RecentActivity_CreateNewRecentActivityWithOneRecentActivityForum_ExpectRecentActivityForums() { IDnaDataReader reader; IDnaDataReaderCreator creator; 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 RecentActivity = new RecentActivity(); RecentActivity.GetRecentActivityForSite(1, creator, mocks.DynamicMock<IDnaDiagnostics>()); Assert.AreEqual(1, RecentActivity.MostRecentConversations.topFiveForumList.Count); XmlDocument doc = SerializeToXML(RecentActivity); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTCONVERSATIONS/FORUM")); }
public void RecentActivity_CreateNewRecentActivityWithMultipleRecentActivityArticleAndMultipleRecentActivityForum_ExpectRecentActivityArticlesAndForums() { IDnaDataReader reader; IDnaDataReaderCreator creator; List<DataReaderFactory.TestDatabaseRow> databaseRows = new List<DataReaderFactory.TestDatabaseRow>(); databaseRows.Add(new RecentActivityForumTestDatabaseRow(123456789, 789456123, "Testing", "MostRecentConversations", "Most Recent Comments", true, false)); databaseRows.Add(new RecentActivityForumTestDatabaseRow(4826159, 78787878, "Testing", "MostRecentConversations", "Most Recent Comments", false, false)); databaseRows.Add(new RecentActivityArticleTestDatabaseRow(DateTime.Now, DateTime.Now.AddDays(1), 1, 123456, 0, "", 0, "Testing", 517436, "Testing User", "my site suffix", "MostRecent", "Most Recent Articles", true, true)); databaseRows.Add(new RecentActivityArticleTestDatabaseRow(DateTime.Now, DateTime.Now.AddDays(1), 1, 456789, 0, "", 0, "Testing", 649713, "Second Testing User", "Second SiteSuffix", "MostRecent", "Most Recent Articles", false, false)); databaseRows.Add(new RecentActivityForumTestDatabaseRow(456123789, 159487263, "Testing More", "MostRecentConversations", "Most Recent Posts", true, true)); databaseRows.Add(new RecentActivityArticleTestDatabaseRow(DateTime.Now, DateTime.Now.AddDays(2), 1, 15948, 0, "", 0, "Testing", 1063883681, "NewBod", "Newbods site suffix", "MostRecent", "Most Recent Articles", true, true)); DataReaderFactory.CreateMockedDataBaseObjects(mocks, "gettopfives2", out creator, out reader, databaseRows); var RecentActivity = new RecentActivity(); RecentActivity.GetRecentActivityForSite(1, creator, mocks.DynamicMock<IDnaDiagnostics>()); Assert.AreEqual(3, RecentActivity.MostRecentArticles.topFiveArticleList.Count); Assert.AreEqual(3, RecentActivity.MostRecentConversations.topFiveForumList.Count); XmlDocument doc = SerializeToXML(RecentActivity); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTCONVERSATIONS/FORUM")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTARTICLES/ARTICLE")); }
public void RecentActivity_CreateNewRecentActivityWithOneRecentActivityForumWithBADColumnData_ExpectRootRecentActivityWithNoRecentActivity() { IDnaDataReader reader; IDnaDataReaderCreator creator; DataReaderFactory.CreateMockedDataBaseObjects(mocks, "gettopfives2", out creator, out reader, null); reader.Stub(x => x.Read()).Return(true); reader.Stub(x => x.IsDBNull("h2g2id")).Return(true); reader.Stub(x => x.GetStringNullAsEmpty("groupname")).Return("MostRecent"); reader.Stub(x => x.GetStringNullAsEmpty("groupdescription")).Return("MostRecent"); reader.Stub(x => x.GetInt32NullAsZero("forumid")).Throw(new Exception("Database Exception")); reader.Stub(x => x.Read()).Return(true); var RecentActivity = new RecentActivity(); RecentActivity.GetRecentActivityForSite(1, creator, mocks.DynamicMock<IDnaDiagnostics>()); Assert.AreEqual(0, RecentActivity.MostRecentArticles.topFiveArticleList.Count); XmlDocument doc = SerializeToXML(RecentActivity); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY")); Assert.IsNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTCONVERSATIONS/FORUM")); }
public void RecentActivity_CreateNewRecentActivityWithOneRecentActivityArticleOneRecentActivityForumAndUnkownDataType_ExpectRecentActivityArticlesAndForumsNoUnkownDataType() { IDnaDataReader reader; IDnaDataReaderCreator creator; List<DataReaderFactory.TestDatabaseRow> databaseRows = new List<DataReaderFactory.TestDatabaseRow>(); databaseRows.Add(new RecentActivityArticleTestDatabaseRow(DateTime.Now, DateTime.Now.AddDays(1), 1, 123456, 0, "", 0, "Testing", 517436, "Testing User", "my site suffix", "MostRecent", "Most Recent Articles", true, false)); databaseRows.Add(new RecentActivityUnkownDataaTypeTestDatabaseRow()); databaseRows.Add(new RecentActivityForumTestDatabaseRow(123456789, 789456123, "Testing", "MostRecentComments", "Most Recent Comments", true, true)); DataReaderFactory.CreateMockedDataBaseObjects(mocks, "gettopfives2", out creator, out reader, databaseRows); var RecentActivity = new RecentActivity(); RecentActivity.GetRecentActivityForSite(1, creator, mocks.DynamicMock<IDnaDiagnostics>()); Assert.AreEqual(1, RecentActivity.MostRecentArticles.topFiveArticleList.Count); Assert.AreEqual(1, RecentActivity.MostRecentConversations.topFiveForumList.Count); XmlDocument doc = SerializeToXML(RecentActivity); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTCONVERSATIONS/FORUM")); Assert.IsNotNull(doc.SelectSingleNode("RECENTACTIVITY/MOSTRECENTARTICLES/ARTICLE")); }