public void ExModerationEvent_BuildExModerationEvents_ExpectUriToBeCorrect()
        {
            _mockreader = MockRepository.GenerateStub<IDnaDataReader>();

            _mockreader.Stub(c => c.GetInt32NullAsZero("modid")).Return(0);
            _mockreader.Stub(c => c.GetString("notes")).Return(null);
            _mockreader.Stub(c => c.GetString("uri")).Return(_uri);
            _mockreader.Stub(c => c.GetDateTime("datecompleted")).Return(DateTime.MinValue);
            _mockreader.Stub(c => c.GetInt32NullAsZero("status")).Return(0);
            _mockreader.Stub(c => c.GetString("callbackuri")).Return(null);
            _mockreader.Stub(c => c.GetString("reasontype")).Return(null);
            _mockreader.Stub(c => c.GetString("reasontext")).Return(null);

            ExModerationEvent activity = new ExModerationEvent();
            activity = ExModerationEvent.CreateExModerationEvent(_mockreader);

            Assert.AreEqual(_uri, activity.Uri);
        }
Esempio n. 2
0
        private void SetupArticleLocationMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out readerCreator, out reader);

            if (rowsToReturn == 0)
            {
                reader.Stub(x => x.HasRows).Return(false);
                reader.Stub(x => x.Read()).Return(false);

            }
            else
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true);

                AddArticleLocationTestDatabaseRows(reader);
            }

            readerCreator.Stub(x => x.CreateDnaDataReader("GetGuideEntryLocation")).Return(reader);

            mocks.ReplayAll();
        }
Esempio n. 3
0
 private void AddReviewSubmissionsListTestDatabaseRows(IDnaDataReader reader)
 {
     reader.Stub(x => x.GetInt32NullAsZero("postid")).Return(1);
     reader.Stub(x => x.GetInt32NullAsZero("threadid")).Return(12345);
     reader.Stub(x => x.GetInt32NullAsZero("forumid")).Return(24088151);
 }
Esempio n. 4
0
 private void AddMonthSummaryTestDatabaseRows(IDnaDataReader reader)
 {
     reader.Stub(x => x.GetStringNullAsEmpty("Subject")).Return("Test Subject").Repeat.Twice();
     reader.Stub(x => x.GetInt32NullAsZero("EntryID")).Return(2408815).Repeat.Twice();
     reader.Stub(x => x.GetInt32NullAsZero("h2g2ID")).Return(24088151).Repeat.Twice();
     reader.Stub(x => x.GetInt32NullAsZero("type")).Return(1).Repeat.Twice();
     reader.Stub(x => x.GetDateTime("datecreated")).Return(DateTime.Now).Repeat.Twice();
 }
        private static void SubmittableTestSetup(out MockRepository mocks, out IDnaDataReader reader, out IDnaDataReaderCreator creator)
        {
            mocks = new MockRepository();
            reader = mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true);

            creator = mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("fetchreviewforummemberdetails")).Return(reader);
            creator.Stub(x => x.CreateDnaDataReader("fetchreviewforumdetails")).Return(reader);

            mocks.ReplayAll();
        }
Esempio n. 6
0
        private void AddArticleListUserDatabaseRows(IDnaDataReader reader, string suffix)
        {
            reader.Stub(x => x.Exists(suffix + "userID")).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero(suffix + "userID")).Return(1090497224).Repeat.Once();

            reader.Stub(x => x.Exists(suffix + "userid")).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero(suffix + "userid")).Return(1090497224).Repeat.Once();

            reader.Stub(x => x.Exists(suffix + "IdentityUserID")).Return(true);
            reader.Stub(x => x.GetStringNullAsEmpty(suffix + "IdentityUserID")).Return("608234").Repeat.Once();
            reader.Stub(x => x.Exists(suffix + "LoginName")).Return(true);
            reader.Stub(x => x.GetStringNullAsEmpty(suffix + "LoginName")).Return("Damnyoureyes").Repeat.Once();

            reader.Stub(x => x.Exists(suffix + "Name")).Return(true);
            reader.Stub(x => x.GetStringNullAsEmpty(suffix + "Name")).Return("name").Repeat.Once();
            reader.Stub(x => x.Exists(suffix + "Area")).Return(true);
            reader.Stub(x => x.GetStringNullAsEmpty(suffix + "Area")).Return("Editor Area").Repeat.Once();
            reader.Stub(x => x.Exists(suffix + "Status")).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero(suffix + "Status")).Return(2).Repeat.Once();
            reader.Stub(x => x.Exists(suffix + "TaxonomyNode")).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero(suffix + "TaxonomyNode")).Return(3).Repeat.Once();
            reader.Stub(x => x.Exists(suffix + "Journal")).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero(suffix + "Journal")).Return(4).Repeat.Once();
            reader.Stub(x => x.Exists(suffix + "Active")).Return(true);
            reader.Stub(x => x.GetBoolean(suffix + "Active")).Return(true).Repeat.Once();
            reader.Stub(x => x.Exists(suffix + "SiteSuffix")).Return(true);
            reader.Stub(x => x.GetStringNullAsEmpty(suffix + "SiteSuffix")).Return("suffix").Repeat.Once();
            reader.Stub(x => x.Exists(suffix + "Title")).Return(true);
            reader.Stub(x => x.GetStringNullAsEmpty(suffix + "Title")).Return("title").Repeat.Once();

        }
        private void SetupScoutRecommendationsMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, out ISite site, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out readerCreator, out reader);
            
            site = mocks.DynamicMock<ISite>();
            site.Stub(x => x.SiteID).Return(1);
            site.Stub(x => x.ModClassID).Return(1);

            if (rowsToReturn > 0)
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true).Repeat.Times(rowsToReturn);
            }
            else
            {
                reader.Stub(x => x.HasRows).Return(false);
                reader.Stub(x => x.Read()).Return(false);
            }
            AddSetupScoutRecommendsResponseDatabaseRows(reader);

            readerCreator.Stub(x => x.CreateDnaDataReader("FetchUndecidedRecommendations")).Return(reader);

            ProfanityFilterTests.InitialiseProfanities();

            mocks.ReplayAll();
        }
Esempio n. 8
0
        private static void CreateThreadFromDatabaseTestSetup(out MockRepository mocks, out int siteId, out int forumId, out int threadId, out int itemsPerPage, out int startIndex, out int postId, out int entryId, out bool orderByDatePostedDesc, out IDnaDataReader reader, out IDnaDataReaderCreator creator)
        {
            mocks = new MockRepository();
            siteId = 1;
            forumId = 1;
            threadId = 1;
            itemsPerPage = 10;
            startIndex = 0;
            postId = 0;
            entryId = 22;
            orderByDatePostedDesc = false;

            reader = mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true).Repeat.Times(itemsPerPage + 2);
            reader.Stub(x => x.GetInt32NullAsZero("EntryID")).Return(entryId);
            reader.Stub(x => x.GetInt32NullAsZero("Total")).Return(itemsPerPage * 2 + 1);//more should = 1

            creator = mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("threadlistposts2")).Return(reader);
            mocks.ReplayAll();
        }
Esempio n. 9
0
        private void AddRecommendationTestDatabaseRows(IDnaDataReader reader)
        {
            reader.Stub(x => x.GetStringNullAsEmpty("Subject")).Return("Test Subject").Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("OriginalEntryID")).Return(2408805).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("Originalh2g2ID")).Return(24088052).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("EntryID")).Return(2408815).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("h2g2ID")).Return(24088151).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("GuideStatus")).Return(4).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("AcceptedStatus")).Return(1).Repeat.Twice();

            reader.Stub(x => x.GetDateTime("DateAllocated")).Return(DateTime.Now).Repeat.Twice();
            reader.Stub(x => x.GetDateTime("DateReturned")).Return(DateTime.Now).Repeat.Twice();

            reader.Stub(x => x.Exists("SubEditorID")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorName")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorFirstNames")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorLastName")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorArea")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorStatus")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorTaxomyNode")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorJournal")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorActive")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorSiteSuffix")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("SubEditorTitle")).Return(true).Repeat.Twice();

            reader.Stub(x => x.Exists("ScoutID")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutName")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutFirstNames")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutLastName")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutArea")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutStatus")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutTaxomyNode")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutJournal")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutActive")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutSiteSuffix")).Return(true).Repeat.Twice();
            reader.Stub(x => x.Exists("ScoutTitle")).Return(true).Repeat.Twice();


            reader.Stub(x => x.GetInt32NullAsZero("SubEditorID")).Return(2408805).Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("SubEditorName")).Return("FredSmith").Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("SubEditorFirstNames")).Return("Fred").Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("SubEditorLastName")).Return("Smith").Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("SubEditorArea")).Return(4).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("SubEditorStatus")).Return(4).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("SubEditorTaxomyNode")).Return(4).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("SubEditorJournal")).Return(123456).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("SubEditorActive")).Return(1).Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("SubEditorSiteSuffix")).Return("SiteSuffix").Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("SubEditorTitle")).Return("Title").Repeat.Twice();

            reader.Stub(x => x.GetInt32NullAsZero("ScoutID")).Return(1090558353).Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("ScoutName")).Return("Scout").Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("ScoutFirstNames")).Return("FirstScout").Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("ScoutLastName")).Return("LastScout").Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("ScoutArea")).Return(4).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("ScoutStatus")).Return(4).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("ScoutTaxomyNode")).Return(4).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("ScoutJournal")).Return(123456).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("ScoutActive")).Return(1).Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("ScoutSiteSuffix")).Return("SiteSuffix").Repeat.Twice();
            reader.Stub(x => x.GetStringNullAsEmpty("ScoutTitle")).Return("Title").Repeat.Twice();

        }
Esempio n. 10
0
        private void SetupRecommendationsMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader)
        {
            mocks = new MockRepository();
            readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();

            // mock the search response
            reader = mocks.DynamicMock<IDnaDataReader>();

            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true).Repeat.Times(2);

            AddRecommendationTestDatabaseRows(reader);

            readerCreator.Stub(x => x.CreateDnaDataReader("getacceptedentries")).Return(reader);

            mocks.ReplayAll();

        }
        private void AddArticleSubscriptionsListArticlesDatabaseRows(IDnaDataReader reader)
        {
            reader.Stub(x => x.HasRows).Return(true);

            reader.Stub(x => x.NextResult()).Return(true);

            reader.Stub(x => x.Read()).Return(true).Repeat.Times(2);
            reader.Stub(x => x.GetInt32("IsMainArticle")).Return(1);
            reader.Stub(x => x.GetInt32("EntryID")).Return(73322156);
            reader.Stub(x => x.GetTinyIntAsInt("style")).Return(1);
            reader.Stub(x => x.GetInt32("PreProcessed")).Return(10);
            reader.Stub(x => x.GetString("text")).Return("<GUIDE><BODY>this is an<BR /> article</BODY></GUIDE>");
        }
 private void AddArticleSubscriptionsListArticlePageAuthorsDatabaseRows(IDnaDataReader reader)
 {
     reader.Stub(x => x.HasRows).Return(true);
     reader.Stub(x => x.Read()).Return(true).Repeat.Once();
     //PageAuthor
     reader.Stub(x => x.Exists("UserID")).Return(true);
     reader.Stub(x => x.GetInt32("UserID")).Return(1090497224).Repeat.Once();
 }
Esempio n. 13
0
        private void AddForumSourceTestDatabaseRows(IDnaDataReader reader)
        {
            reader.Stub(x => x.GetStringNullAsEmpty("Subject")).Return("Test Subject").Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("Type")).Return(1).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("AlertInstantly")).Return(0).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("EntryID")).Return(2408815).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("h2g2ID")).Return(24088151).Repeat.Twice();
            reader.Stub(x => x.GetInt32("EntryID")).Return(2408815).Repeat.Twice();
            reader.Stub(x => x.GetInt32("h2g2ID")).Return(24088151).Repeat.Twice();
            reader.Stub(x => x.GetInt32("ForumID")).Return(1).Repeat.Twice();

            reader.Stub(x => x.GetDateTime("datecreated")).Return(DateTime.Now).Repeat.Twice();

            reader.Stub(x => x.GetInt32("IsMainArticle")).Return(1);
            reader.Stub(x => x.GetInt32("Status")).Return(1);
            reader.Stub(x => x.GetTinyIntAsInt("style")).Return(1);
            reader.Stub(x => x.GetString("text")).Return("<GUIDE><BODY>this is an article</BODY></GUIDE>");

            reader.Stub(x => x.GetByteNullAsZero("ModerationStatus")).Return(3);
            reader.Stub(x => x.GetDateTime("DateCreated")).Return(DateTime.Now);
            reader.Stub(x => x.GetDateTime("LastUpdated")).Return(DateTime.Now);
            reader.Stub(x => x.GetInt32("PreProcessed")).Return(0);
            reader.Stub(x => x.GetInt32("SiteID")).Return(1);
            reader.Stub(x => x.GetTinyIntAsInt("Submittable")).Return(1);

            reader.Stub(x => x.GetByteNullAsZero("ModerationStatus")).Return(3);

        }
Esempio n. 14
0
        private void SetupForumSourceMocks(out MockRepository mocks, out ICacheManager cache, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out cache, out readerCreator, out reader);

            if (rowsToReturn > 0)
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true).Repeat.Times(rowsToReturn);
            }
            else
            {
                reader.Stub(x => x.HasRows).Return(false);
                reader.Stub(x => x.Read()).Return(false);
            }
            AddForumSourceTestDatabaseRows(reader);

            readerCreator.Stub(x => x.CreateDnaDataReader("getforumsource")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("getarticlecomponents2")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("getauthorsfromh2g2id")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("getrelatedarticles")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("getrelatedclubs")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("getarticlecrumbtrail")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("GetBookmarkCount")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("getforumstyle")).Return(reader);           

            mocks.ReplayAll();
        }
Esempio n. 15
0
 private void AddArticleLocationTestDatabaseRows(IDnaDataReader reader)
 {
     //Add in locations
     reader.Stub(x => x.GetStringNullAsEmpty("description")).Return("Test Location 1").Repeat.Once();
     reader.Stub(x => x.GetStringNullAsEmpty("title")).Return("Test Location 1").Repeat.Once();
     reader.Stub(x => x.GetInt32NullAsZero("locationid")).Return(1).Repeat.Once();
     reader.Stub(x => x.GetInt32NullAsZero("ownerid")).Return(1090497224).Repeat.Once();
     reader.Stub(x => x.GetInt32NullAsZero("siteid")).Return(1).Repeat.Once();
     reader.Stub(x => x.GetDateTime("CreatedDate")).Return(DateTime.Now).Repeat.Once();
 }
Esempio n. 16
0
        private void SetupSoloGuideEntriesMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, out IDnaDataReader reader2, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out readerCreator, out reader, out reader2);

            if (rowsToReturn == 0)
            {
                reader.Stub(x => x.HasRows).Return(false);
                reader.Stub(x => x.Read()).Return(false);
            }
            else
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true);

                AddSoloGuideEntriesUserDatabaseRows(reader, "");
                AddSoloGuideEntriesUserDatabaseRows(reader, "");
            }

            readerCreator.Stub(x => x.CreateDnaDataReader("getsologuideentriescountuserlist")).Return(reader);

            mocks.ReplayAll();
        }
Esempio n. 17
0
        private static void QueueValuesToDataReaderCalls(IDnaDataReader reader, Dictionary<string, Queue<RowQueueItem>> queuedData)
        {
            // Add the queues to the relavent datareader calls
            foreach (KeyValuePair<string, Queue<RowQueueItem>> o in queuedData)
            {
                string keyName = o.Key;
                Queue<RowQueueItem> queue = o.Value;

                bool isDBNullCall = keyName.IndexOf("-isdbnull") > 0;
                keyName = keyName.Replace("-isdbnull", "");

                bool isGetStringCall = keyName.IndexOf("-getstring") > 0;
                keyName = keyName.Replace("-getstring", "");

                bool isGetInt32Call = keyName.IndexOf("-getint32") > 0;
                keyName = keyName.Replace("-getint32", "");

                bool isGetNullableInt32Call = keyName.IndexOf("-getnullableint32") > 0;
                keyName = keyName.Replace("-getnullableint32", "");

                bool isGetNullableBooleanCall = keyName.IndexOf("-getnullableboolean") > 0;
                keyName = keyName.Replace("-getnullableboolean", "");

                if (queue != null && queue.Count > 0)
                {
                    Console.WriteLine(string.Format("Adding queue for {0} with count of {1}", keyName, queue.Count));
                    System.Diagnostics.Debug.WriteLine(string.Format("Adding queue for {0} with count of {1}", keyName, queue.Count));

                    if (isGetNullableBooleanCall)
                    {
                        reader.Stub(x => x.GetNullableBoolean(keyName)).Return(false).WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                    }
                    else if (isGetNullableInt32Call)
                    {
                        reader.Stub(x => x.GetNullableInt32(keyName)).Return(0).WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                    }
                    else if (queue.ElementAt(0).ObjectValue.GetType() == typeof(bool))
                    {
                        if (isDBNullCall)
                        {
                            reader.Stub(x => x.IsDBNull(keyName)).Return(true).WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                        }
                        else
                        {
                            reader.Stub(x => x.GetBoolean(keyName)).Return(true).WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                        }
                    }
                    else if (queue.ElementAt(0).ObjectValue.GetType() == typeof(string))
                    {
                        if (isGetStringCall)
                        {
                            reader.Stub(x => x.GetString(keyName)).Return("").WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                        }
                        else
                        {
                            reader.Stub(x => x.GetStringNullAsEmpty(keyName)).Return("").WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                        }
                    }
                    else if (queue.ElementAt(0).ObjectValue.GetType() == typeof(int))
                    {
                        if (isGetInt32Call)
                        {
                            reader.Stub(x => x.GetInt32(keyName)).Return(0).WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                        }
                        else
                        {
                            reader.Stub(x => x.GetInt32NullAsZero(keyName)).Return(0).WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                        }
                    }
                    else if (queue.ElementAt(0).ObjectValue.GetType() == typeof(DateTime))
                    {
                        reader.Stub(x => x.GetDateTime(keyName)).Return(DateTime.Now).WhenCalled(x => x.ReturnValue = queue.Peek().ObjectValue);
                    }
                }
            }
        }
Esempio n. 18
0
        private static void UpdatePermissionsForViewingUserTestSetup(out MockRepository mocks, out IDnaDataReader reader, out IDnaDataReaderCreator creator, out IUser viewingIUser)
        {
            mocks = new MockRepository();
            reader = mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero("CanRead")).Return(0);
            reader.Stub(x => x.GetInt32NullAsZero("CanWrite")).Return(0);
            reader.Stub(x => x.GetInt32NullAsZero("CanChangePermissions")).Return(0);
            reader.Stub(x => x.GetInt32NullAsZero("DefaultCanRead")).Return(0);
            reader.Stub(x => x.GetInt32NullAsZero("DefaultCanWrite")).Return(0);
            reader.Stub(x => x.GetInt32NullAsZero("DefaultCanChangePermissions")).Return(0);

            creator = mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("GetArticlePermissionsForUser")).Return(reader);

            viewingIUser = mocks.DynamicMock<IUser>();
            viewingIUser.Stub(x => x.UserLoggedIn).Return(true);
            mocks.ReplayAll();
        }
Esempio n. 19
0
        private static void GetIndexOfPostInThreadTestSetup(out MockRepository mocks, out IDnaDataReader reader, out IDnaDataReaderCreator creator)
        {
            mocks = new MockRepository();
            reader = mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero("Index")).Return(25);

            creator = mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("getindexofpost")).Return(reader);
            mocks.ReplayAll();
        }
        private void SetupBlockedUserSubscriptionsListMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, out IDnaDataReader reader2, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out readerCreator, out reader, out reader2);

            if (rowsToReturn == 0)
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true);

                //Return the user but no rows
                reader2.Stub(x => x.HasRows).Return(true);
                reader2.Stub(x => x.Read()).Return(true).Repeat.Once();
                reader2.Stub(x => x.Read()).Return(false).Repeat.Once();

                reader2.Stub(x => x.NextResult()).Return(false);

                AddBlockedUserSubscriptionsListUserDatabaseRows(reader, "");
                AddBlockedUserSubscriptionsListUserDatabaseRows(reader2, "Blocker");
                reader.Stub(x => x.GetBoolean("BlockerAcceptSubscriptions")).Return(true).Repeat.Once();

            }
            else
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true);

                reader2.Stub(x => x.HasRows).Return(true);
                reader2.Stub(x => x.Read()).Return(true);

                reader2.Stub(x => x.NextResult()).Return(true);

                AddBlockedUserSubscriptionsListUserDatabaseRows(reader, "");

                AddBlockedUserSubscriptionsListUserDatabaseRows(reader2, "Blocker");
                AddBlockedUserSubscriptionsListUserDatabaseRows(reader2, "");
                AddBlockedUserSubscriptionsListUserDatabaseRows(reader2, "");

            }

            readerCreator.Stub(x => x.CreateDnaDataReader("getdnauseridfromidentityusername")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("getblockedusersubscriptions")).Return(reader2);

            mocks.ReplayAll();
        }
Esempio n. 21
0
        private void AddArticleListTestArticlesDatabaseRows(IDnaDataReader reader)
        {
            reader.Stub(x => x.GetInt32NullAsZero("Total")).Return(2);

            reader.Stub(x => x.GetStringNullAsEmpty("Subject")).Return("Test Subject").Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("EntryID")).Return(2408815).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("h2g2ID")).Return(24088151).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("status")).Return(1).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("Type")).Return(1).Repeat.Twice();
            reader.Stub(x => x.GetInt32NullAsZero("Count")).Return(83).Repeat.Twice();
            reader.Stub(x => x.GetDateTime("datecreated")).Return(DateTime.Now).Repeat.Twice();
            reader.Stub(x => x.GetDateTime("lastupdated")).Return(DateTime.Now).Repeat.Twice();
        }
        private void SetupBlockUnblockUserMocks(out MockRepository mocks, 
                                        out ICacheManager cache, 
                                        out IDnaDataReaderCreator readerCreator, 
                                        out ICallingUser viewingUser, 
                                        out ISite site, 
                                        out IDnaDataReader reader, 
                                        out IDnaDataReader reader2,
                                        int viewingUserId)
        {
            mocks = new MockRepository();
            cache = mocks.DynamicMock<ICacheManager>();
            readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            site = mocks.DynamicMock<ISite>();
            viewingUser = mocks.DynamicMock<ICallingUser>();

            // mock the response
            viewingUser.Stub(x => x.UserID).Return(viewingUserId);
            viewingUser.Stub(x => x.IsUserA(BBC.Dna.Users.UserTypes.Editor)).Return(false);
            viewingUser.Stub(x => x.IsUserA(BBC.Dna.Users.UserTypes.SuperUser)).Return(false);

            reader = mocks.DynamicMock<IDnaDataReader>();
            reader2 = mocks.DynamicMock<IDnaDataReader>();

            AddBlockedUserSubscriptionsListUserDatabaseRows(reader, "");

            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true);

            reader2.Stub(x => x.HasRows).Return(true);
            reader2.Stub(x => x.Read()).Return(true);

            readerCreator.Stub(x => x.CreateDnaDataReader("getdnauseridfromidentityusername")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("blockusersubscription")).Return(reader2);
            readerCreator.Stub(x => x.CreateDnaDataReader("unblockusersubscription")).Return(reader2);

            mocks.ReplayAll();
        }
Esempio n. 23
0
        private static void HasGroupAlertOnItemTestSetup(int groupIdExpected, out MockRepository mocks, out IDnaDataReader reader, out IDnaDataReaderCreator creator)
        {
            mocks = new MockRepository();
            reader = mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true);
            reader.Stub(x => x.GetInt32NullAsZero("GroupID")).Return(groupIdExpected);

            //test with Thread flag
            creator = mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("getthreadgroupalertid")).Return(reader);
            mocks.ReplayAll();
        }
        private static void StubDatabaseCall(IDnaDataReaderCreator readerCreator, IDnaDataReader reader, int totalActiveForums, DateTime closeDate, int count, DateTime lastRatedDate, int siteId, string urlName, string title, int totalPosts, string url, int upRatings, int downRatings)
        {
            reader.Stub(x => x.HasRows).Return(totalActiveForums > 0);

            if (totalActiveForums > 0)
            {
                reader.Stub(x => x.Read()).Return(true).Repeat.Once();
                reader.Stub(x => x.GetDateTime("ForumCloseDate")).Return(closeDate);
                reader.Stub(x => x.GetInt32("count")).Return(count);
                reader.Stub(x => x.GetDateTime("LastRatedDate")).Return(lastRatedDate);
                reader.Stub(x => x.GetInt32("siteid")).Return(siteId);
                reader.Stub(x => x.GetString("urlname")).Return(urlName);
                reader.Stub(x => x.GetString("title")).Return(title);
                reader.Stub(x => x.GetInt32("totalPosts")).Return(totalPosts);
                reader.Stub(x => x.GetString("url")).Return(url);
                reader.Stub(x => x.GetInt32("up")).Return(upRatings);
                reader.Stub(x => x.GetInt32("down")).Return(downRatings);
            }
            else
            {
                reader.Stub(x => x.Read()).Return(false);
            }

            readerCreator.Stub(x => x.CreateDnaDataReader("getcommentforumsactivity_ratings")).Return(reader);
        }
Esempio n. 25
0
        private void SetupMonthSummaryMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out readerCreator, out reader);

            if (rowsToReturn > 0)
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true).Repeat.Times(rowsToReturn);
            }
            else
            {
                reader.Stub(x => x.HasRows).Return(false);
                reader.Stub(x => x.Read()).Return(false);
            }
            AddMonthSummaryTestDatabaseRows(reader);

            readerCreator.Stub(x => x.CreateDnaDataReader("getmonthsummary")).Return(reader);

            mocks.ReplayAll();
        }
Esempio n. 26
0
        private void SetupAddFriendMocks(out MockRepository mocks, out ICacheManager cache, out IDnaDataReaderCreator readerCreator, out ICallingUser viewingUser, out ISite site, out IDnaDataReader reader, out IDnaDataReader reader2)
        {
            mocks = new MockRepository();
            cache = mocks.DynamicMock<ICacheManager>();
            readerCreator = mocks.DynamicMock<IDnaDataReaderCreator>();
            site = mocks.DynamicMock<ISite>();
            viewingUser = mocks.DynamicMock<ICallingUser>();
            
            // mock the response
            viewingUser.Stub(x => x.UserID).Return(1090497224);
            viewingUser.Stub(x => x.IsUserA(BBC.Dna.Users.UserTypes.Editor)).Return(false);
            viewingUser.Stub(x => x.IsUserA(BBC.Dna.Users.UserTypes.SuperUser)).Return(false);

            reader = mocks.DynamicMock<IDnaDataReader>();
            reader2 = mocks.DynamicMock<IDnaDataReader>();

            AddFriendsListUserDatabaseRows(reader, "");

            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true);

            reader2.Stub(x => x.HasRows).Return(true);
            reader2.Stub(x => x.Read()).Return(true);

            readerCreator.Stub(x => x.CreateDnaDataReader("getdnauseridfromidentityusername")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("watchuserjournal")).Return(reader2);
            readerCreator.Stub(x => x.CreateDnaDataReader("deletewatchedusers")).Return(reader2);

            mocks.ReplayAll();
        }
Esempio n. 27
0
        private void SetupReviewSubmissionMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, out ISite site, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out readerCreator, out reader);
            
            site = mocks.DynamicMock<ISite>();
            site.Stub(x => x.SiteID).Return(1);
            site.Stub(x => x.ModClassID).Return(1);

            if (rowsToReturn > 0)
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true).Repeat.Times(rowsToReturn);
            }
            else
            {
                reader.Stub(x => x.HasRows).Return(false);
                reader.Stub(x => x.Read()).Return(false);
            }
            AddReviewSubmissionsListTestDatabaseRows(reader);

            readerCreator.Stub(x => x.CreateDnaDataReader("addarticletoreviewforummembers")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("ForceUpdateEntry")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("fetchpersonalspaceforum")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("fetchreviewforumdetails")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("posttoforum")).Return(reader);

            ProfanityFilterTests.InitialiseProfanities();

            mocks.ReplayAll();
        }
Esempio n. 28
0
        private void SetupFriendsListMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, out IDnaDataReader reader2, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out readerCreator, out reader, out reader2);

            if (rowsToReturn == 0)
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true);
                AddFriendsListUserDatabaseRows(reader, "");

                reader2.Stub(x => x.HasRows).Return(false);
                reader2.Stub(x => x.Read()).Return(false);
            }
            else
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true);

                reader2.Stub(x => x.HasRows).Return(true);
                reader2.Stub(x => x.Read()).Return(true);

                AddFriendsListUserDatabaseRows(reader, "");

                AddFriendsListUserDatabaseRows(reader2, "");
                AddFriendsListUserDatabaseRows(reader2, "");

            }
            readerCreator.Stub(x => x.CreateDnaDataReader("getdnauseridfromidentityusername")).Return(reader);
            readerCreator.Stub(x => x.CreateDnaDataReader("fetchwatchedjournals")).Return(reader2);

            mocks.ReplayAll();
        }
Esempio n. 29
0
        private static void GetEntryFromDatabaseTestSetup(out MockRepository mocks, out IDnaDataReader reader, out IDnaDataReaderCreator creator)
        {
            mocks = new MockRepository();
            reader = mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(true).Repeat.Times(6);
            reader.Stub(x => x.GetInt32("IsMainArticle")).Return(1);

            creator = mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("getauthorsfromh2g2id")).Return(reader);
            creator.Stub(x => x.CreateDnaDataReader("getrelatedarticles")).Return(reader);
            creator.Stub(x => x.CreateDnaDataReader("getrelatedclubs")).Return(reader);
            creator.Stub(x => x.CreateDnaDataReader("getarticlecrumbtrail")).Return(reader);
            mocks.ReplayAll();
        }
Esempio n. 30
0
        private void SetupIndexMocks(out MockRepository mocks, out IDnaDataReaderCreator readerCreator, out IDnaDataReader reader, int rowsToReturn)
        {
            InitialiseMocks(out mocks, out readerCreator, out reader);

            if (rowsToReturn > 0)
            {
                reader.Stub(x => x.HasRows).Return(true);
                reader.Stub(x => x.Read()).Return(true).Repeat.Times(rowsToReturn);
            }
            else
            {
                reader.Stub(x => x.HasRows).Return(false);
                reader.Stub(x => x.Read()).Return(false);
            }
            AddIndexTestDatabaseRows(reader);

            readerCreator.Stub(x => x.CreateDnaDataReader("articlesinindex")).Return(reader);

            mocks.ReplayAll();
        }