public void RatingCreate_RatingOnEmergencyClosedSite() { //create ratings objects _ratings.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList); _ratings.CallingUser.IsUserSignedInSecure(TestUtils.TestUserAccounts.GetNormalUserAccount.Cookie, TestUserAccounts.GetNormalUserAccount.SecureCookie, site.IdentityPolicy, site.SiteID, null, Guid.Empty); var callingUser = _ratings.CallingUser; //set up test data RatingInfo rating = new RatingInfo { text = "this is a nunit generated rating.", rating = 3 }; rating.text += Guid.NewGuid().ToString();//have to randomize the string to post string IPAddress = String.Empty; Guid BBCUid = Guid.NewGuid(); string ratingForumID = "testratingForum" + Guid.NewGuid().ToString(); RatingForum ratingForum = RatingForumCreate(ratingForumID); try {//turn the site into emergency closed mode _siteList.GetSite(site.ShortName).IsEmergencyClosed = true; using (FullInputContext inputcontext = new FullInputContext("")) { _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList); _ratings.CallingUser = callingUser; } RatingInfo result = _ratings.RatingCreate(ratingForum, rating); } catch (ApiException ex) { Assert.AreEqual(ErrorType.SiteIsClosed, ex.type); } finally {//reset the site into emergency closed mode _siteList.GetSite(site.ShortName).IsEmergencyClosed = false; } }
public void RatingCreate_PreModSiteWithProcessPreMod() { using (FullInputContext inputcontext = new FullInputContext("")) { using (IDnaDataReader reader = inputcontext.CreateDnaDataReader("")) { reader.ExecuteDEBUGONLY("update sites set premoderation=1 where siteid=" + site.SiteID.ToString());//set premod reader.ExecuteDEBUGONLY("insert into siteoptions (SiteID,Section,Name,Value,Type, Description) values(" + site.SiteID.ToString() + ",'Moderation', 'ProcessPreMod','1',1,'test premod value')"); } _siteList = SiteList.GetSiteList(); site = _siteList.GetSite("h2g2"); _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), inputcontext.SiteList); } try { //set up test data RatingInfo rating = new RatingInfo { text = "this is a nunit generated rating.", rating = 3 }; rating.text += Guid.NewGuid().ToString();//have to randomize the string to post string IPAddress = String.Empty; Guid BBCUid = Guid.NewGuid(); string ratingForumID = "testratingForum" + Guid.NewGuid().ToString(); RatingForum ratingForum = RatingForumCreate(ratingForumID, ModerationStatus.ForumStatus.Unknown);//should override this with the site value //normal user _ratings.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList); _ratings.CallingUser.IsUserSignedInSecure(TestUtils.TestUserAccounts.GetNormalUserAccount.Cookie, TestUserAccounts.GetNormalUserAccount.SecureCookie, site.IdentityPolicy, site.SiteID, null, Guid.Empty); try { _ratings.RatingCreate(ratingForum, rating); } catch (ApiException ex) { Assert.IsTrue(ex.type == ErrorType.InvalidProcessPreModState); } } finally { //reset h2g2 site using (FullInputContext inputcontext = new FullInputContext("")) { using (IDnaDataReader reader = inputcontext.CreateDnaDataReader("")) { reader.ExecuteDEBUGONLY("update sites set premoderation=0 where siteid=" + site.SiteID.ToString());//set premod reader.ExecuteDEBUGONLY("delete from siteoptions where SiteID=" + site.SiteID.ToString() + " and Name='ProcessPreMod'"); } _siteList = SiteList.GetSiteList(); site = _siteList.GetSite("h2g2"); _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), inputcontext.SiteList); } } }
public void RatingCreate_RatingWithBiggerSiteOption() { try { using (FullInputContext inputcontext = new FullInputContext("")) { using (IDnaDataReader reader = inputcontext.CreateDnaDataReader("")) { reader.ExecuteDEBUGONLY("insert into siteoptions (SiteID,Section,Name,Value,Type, Description) values(" + site.SiteID.ToString() + ",'CommentForum', 'MaxForumRatingScore','15',0,'test MaxForumRatingScore value')"); } _siteList.ReInitialise(); site = _siteList.GetSite("h2g2"); _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList); } //set up test data RatingInfo rating = new RatingInfo { text = "this is a nunit generated rating.", rating = 14//standard site option = 5 }; rating.text += Guid.NewGuid().ToString();//have to randomize the string to post string IPAddress = String.Empty; Guid BBCUid = Guid.NewGuid(); string ratingForumID = "testratingForum" + Guid.NewGuid().ToString(); RatingForum ratingForum = RatingForumCreate(ratingForumID); _ratings.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetNormalUserAccount.UserName, _siteList); _ratings.CallingUser.IsUserSignedInSecure(TestUtils.TestUserAccounts.GetNormalUserAccount.Cookie, TestUserAccounts.GetNormalUserAccount.SecureCookie, site.IdentityPolicy, site.SiteID, null, Guid.Empty); //getr the forum and check value RatingInfo result = _ratings.RatingCreate(ratingForum, rating); Assert.IsTrue(result != null); Assert.IsTrue(result.ID > 0); Assert.IsTrue(result.text == rating.text); Assert.IsTrue(result.rating == rating.rating); } finally { using (FullInputContext inputcontext = new FullInputContext("")) { using (IDnaDataReader reader = inputcontext.CreateDnaDataReader("")) { reader.ExecuteDEBUGONLY("delete from siteoptions where SiteID=" + site.SiteID.ToString() + " and Name='MaxForumRatingScore'"); _siteList = new SiteList(DnaMockery.CreateDatabaseReaderCreator(), DnaDiagnostics.Default, CacheFactory.GetCacheManager(), null, null); _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList); } } } }