Exemple #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public RatingForumTests()
        {
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                _siteList = SiteList.GetSiteList();
                site = _siteList.GetSite("h2g2");

                _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
                var b = new BannedEmails(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);
                var g = new UserGroups(inputcontext.ReaderCreator, inputcontext.dnaDiagnostics, CacheFactory.GetCacheManager(), null, null);
            }
            
        }
Exemple #2
0
 public void StartUp()
 {
     SnapshotInitialisation.RestoreFromSnapshot();
     Statistics.InitialiseIfEmpty(null, false);
     using (FullInputContext inputcontext = new FullInputContext(""))
     {
         var p = new ProfanityFilter(DnaMockery.CreateDatabaseReaderCreator(), null, CacheFactory.GetCacheManager(), null, null);
         var b = new BannedEmails(DnaMockery.CreateDatabaseReaderCreator(), null, CacheFactory.GetCacheManager(), null, null);
         var g = new UserGroups(DnaMockery.CreateDatabaseReaderCreator(), null, CacheFactory.GetCacheManager(), null, null);
         _siteList = SiteList.GetSiteList();
         site = _siteList.GetSite("h2g2");
         site.IsEmergencyClosed = false;
         _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
     }
 }
Exemple #3
0
        public ReviewService()
            : base(Global.connectionString, Global.siteList, Global.dnaDiagnostics)
        {
            _ratingObj = new Reviews(dnaDiagnostic, readerCreator, cacheManager, Global.siteList);
            _ratingObj.ItemsPerPage = itemsPerPage;
            _ratingObj.StartIndex = startIndex;
            _ratingObj.SignOnType = signOnType;
            _ratingObj.SortBy = sortBy;
            _ratingObj.SortDirection = sortDirection;
            _ratingObj.FilterBy = filterBy;
            _ratingObj.SummaryLength = summaryLength;
            if (bbcUidCookie != Guid.Empty)
            {
                _ratingObj.BbcUid = bbcUidCookie;
            }
            _ratingObj.IpAddress = _iPAddress;
            _ratingObj.BasePath = ConfigurationManager.AppSettings["ServerBasePath"];

        }
Exemple #4
0
        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);
                }
            }
        }
Exemple #5
0
        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;
            }
        }
Exemple #6
0
        public void RatingCreate_BannedUser()
        {
            Reviews ratings = null;
            using (FullInputContext inputcontext = new FullInputContext(""))
            {
                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 = 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);
            //normal user
            _ratings.CallingUser = new CallingUser(SignInSystem.DebugIdentity, null, null, null, TestUserAccounts.GetBannedUserAccount.UserName, _siteList);
            _ratings.CallingUser.IsUserSignedInSecure(TestUtils.TestUserAccounts.GetBannedUserAccount.Cookie, TestUserAccounts.GetBannedUserAccount.SecureCookie, site.IdentityPolicy, site.SiteID, null, Guid.Empty);

            try
            {
                RatingInfo result = _ratings.RatingCreate(ratingForum, rating);
            }
            catch (ApiException ex)
            {
                Assert.IsTrue(ex.type == ErrorType.UserIsBanned);
            }
        }
Exemple #7
0
        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);
                    }
                }
            }
        }
Exemple #8
0
 private void SetMinCharLimit(int minLimit)
 {
     //set min and max char option
     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', 'MinCommentCharacterLength','" + minLimit.ToString() + "',0,'test MinCommentCharacterLength value')");
             _siteList.ReInitialise();
             _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
         }
     }
 }
Exemple #9
0
 private void DeleteMinMaxLimitSiteOptions()
 {
     using (FullInputContext inputcontext = new FullInputContext(""))
     {
         using (IDnaDataReader reader = inputcontext.CreateDnaDataReader(""))
         {
             try
             {
                 reader.ExecuteDEBUGONLY("delete from siteoptions where SiteID=" + site.SiteID.ToString() + " and Name='MaxCommentCharacterLength'");
             }
             catch
             {
             }
             try
             {
                 reader.ExecuteDEBUGONLY("delete from siteoptions where SiteID=" + site.SiteID.ToString() + " and Name='MinCommentCharacterLength'");
             }
             catch
             {
             }
         }
         _siteList.ReInitialise();
         _ratings = new Reviews(inputcontext.dnaDiagnostics, inputcontext.ReaderCreator, CacheFactory.GetCacheManager(), _siteList);
     }
 }