// //You can use the following additional attributes as you write your tests: // //Use ClassInitialize to run code before running the first test in the class //[ClassInitialize()] //public static void MyClassInitialize(TestContext testContext) //{ //} // //Use ClassCleanup to run code after all tests in a class have run //[ClassCleanup()] //public static void MyClassCleanup() //{ //} // //Use TestInitialize to run code before running each test //[TestInitialize()] //public void MyTestInitialize() //{ //} // //Use TestCleanup to run code after each test has run //[TestCleanup()] //public void MyTestCleanup() //{ //} // #endregion public static ArticleInfo CreateArticleInfo() { ArticleInfo target = new ArticleInfo() { H2g2Id = 1, DateCreated = new DateElement(DateTime.Now), LastUpdated = new DateElement(DateTime.Now), ForumId = 2, ModerationStatus = BBC.Dna.Moderation.Utils.ModerationStatus.ArticleStatus.UnMod, PageAuthor = ArticleInfoPageAuthorTest.CreatePageAuthor(), PreProcessed = 1, Site = new ArticleInfoSite() { Id = 1 }, SiteId = 1, Status = new ArticleStatus() { Type = 1, Value = "ok" }, RelatedMembers = new ArticleInfoRelatedMembers() { RelatedArticles = RelatedArticleTest.CreateRelatedArticles(), RelatedClubs = RelatedClubsTest.CreateRelatedClubs() }, CrumbTrails = CrumbTrailsTest.CreateCrumbTrails() }; return target; }
/// <summary> /// This method reads in the entry form the database and sets up all the member fields /// </summary> /// <param name="safeToCache">A flag to state whether or not this entry is safe to cache. Usually set to false whhen an error occures.</param> /// <param name="failingGracefully">A flag that states whether or not this method is failing gracefully.</param> static public ArticleInfo GetEntryFromDataBase(int entryId, IDnaDataReader reader, IDnaDataReaderCreator readerCreator) { ArticleInfo articleInfo = null; // fetch all the lovely intellectual property from the database // Make sure we got something back if (reader.HasRows) { // Go though the results untill we get the main article do { if (reader.GetInt32("IsMainArticle") == 1 ) { articleInfo = new ArticleInfo(); // Now start reading in all the values for the entry articleInfo.H2g2Id = reader.GetInt32("h2g2ID"); articleInfo.ForumId = reader.GetInt32("ForumID"); articleInfo.ModerationStatus = (BBC.Dna.Moderation.Utils.ModerationStatus.ArticleStatus)reader.GetInt32NullAsZero("ModerationStatus"); articleInfo.Status = ArticleStatus.GetStatus(reader.GetInt32("Status")); articleInfo.DateCreated = new DateElement(reader.GetDateTime("DateCreated")); articleInfo.LastUpdated = new DateElement(reader.GetDateTime("LastUpdated")); articleInfo.PreProcessed = reader.GetInt32("PreProcessed"); articleInfo.SiteId = reader.GetInt32("SiteID"); articleInfo.Site = new ArticleInfoSite() { Id = articleInfo.SiteId }; //create children objects articleInfo.PageAuthor = ArticleInfoPageAuthor.CreateListForArticle(articleInfo.H2g2Id, reader.GetInt32("Editor"), readerCreator); articleInfo.RelatedMembers = ArticleInfoRelatedMembers.GetRelatedMembers(articleInfo.H2g2Id, readerCreator); articleInfo.CrumbTrails = CrumbTrails.CreateArticleCrumbtrail(articleInfo.H2g2Id, readerCreator); if (articleInfo.Status.Type == 3) {//create Submittable if status = 3... bool isSubmittable = (reader.GetTinyIntAsInt("Submittable")==1); articleInfo.Submittable = ArticleInfoSubmittable.CreateSubmittable(readerCreator, articleInfo.H2g2Id, isSubmittable); } } if (articleInfo != null) { break;//got the info so run } } while (reader.Read()); } return articleInfo; }