private void SetupCallingUserSenario(int siteID, string dnaUserName, string siteSuffix, bool isKidsSite, bool useIdV4, string useUDNG, out ICacheManager mockedCacheManager, out IDnaDiagnostics mockedDiagnostics, out ISiteList mockedSiteList, out IDnaDataReaderCreator mockedCreator) { mockedCacheManager = _mocks.DynamicMock<ICacheManager>(); mockedDiagnostics = _mocks.DynamicMock<IDnaDiagnostics>(); mockedSiteList = _mocks.DynamicMock<ISiteList>(); mockedSiteList.Stub(x => x.GetSiteOptionValueBool(siteID, "General", "IsKidsSite")).Return(isKidsSite); mockedSiteList.Stub(x => x.GetSiteOptionValueBool(siteID, "CommentForum", "UseIDv4")).Return(useIdV4); mockedSiteList.Stub(x => x.GetSiteOptionValueString(siteID, "User", "AutoGeneratedNames")).Return(useUDNG); mockedCreator = _mocks.DynamicMock<IDnaDataReaderCreator>(); var mockedReader = _mocks.DynamicMock<IDnaDataReader>(); var mockedUserReader = _mocks.DynamicMock<IDnaDataReader>(); var mockedProfileReader = _mocks.DynamicMock<IDnaDataReader>(); var mockedUpdateReader = _mocks.DynamicMock<IDnaDataReader>(); mockedCreator.Stub(x => x.CreateDnaDataReader("updateuser2")).Return(mockedUpdateReader); mockedUserReader.Stub(x => x.GetInt32("userid")).Return(TestUserAccounts.GetNormalUserAccount.UserID); mockedUserReader.Stub(x => x.GetString("username")).Return(dnaUserName); mockedUserReader.Stub(x => x.GetStringNullAsEmpty("SiteSuffix")).Return(siteSuffix); mockedUserReader.Stub(x => x.Read()).Return(true); mockedUserReader.Stub(x => x.HasRows).Return(true); mockedCreator.Stub(x => x.CreateDnaDataReader("getbannedemails")).Return(mockedReader); mockedCreator.Stub(x => x.CreateDnaDataReader("createnewuserfromidentityid")).Return(mockedUserReader); mockedCreator.Stub(x => x.CreateDnaDataReader("synchroniseuserwithprofile")).Return(mockedProfileReader); }
private static void CreateForumThreadsFromDatabaseTestSetup(out int forumId, out int threadId, out int itemsPerPage, out int startIndex, out ThreadOrder threadOrder, out bool overFlow, out IDnaDataReaderCreator creator, out ISiteList siteList, out int siteId) { var mocks = new MockRepository(); siteId = 1; forumId = 1; threadId = 0; itemsPerPage = 10; startIndex = 0; threadOrder = ThreadOrder.LatestPost; overFlow = true; var reader = mocks.DynamicMock<IDnaDataReader>(); reader.Stub(x => x.HasRows).Return(true); reader.Stub(x => x.Read()).Return(true); reader.Stub(x => x.GetInt32NullAsZero("ThreadID")).Return(threadId); reader.Stub(x => x.GetInt32NullAsZero("ThreadCount")).Return(itemsPerPage + 1); reader.Stub(x => x.GetInt32NullAsZero("SiteID")).Return(siteId); reader.Stub(x => x.DoesFieldExist("ForumPostCount")).Return(true); reader.Stub(x => x.GetInt32NullAsZero("ForumPostCount")).Return(itemsPerPage + 1); reader.Stub(x => x.GetDateTime("ThreadLastUpdated")).Return(DateTime.MinValue); reader.Stub(x => x.GetDateTime("ForumLastUpdated")).Return(DateTime.MinValue); creator = mocks.DynamicMock<IDnaDataReaderCreator>(); creator.Stub(x => x.CreateDnaDataReader("forumgetthreadlist")).Return(reader); creator.Stub(x => x.CreateDnaDataReader("GetForumSiteID")).Return(reader); creator.Stub(x => x.CreateDnaDataReader("cachegetforumlastupdate")).Return(reader); var site = mocks.DynamicMock<ISite>(); site.Stub(x => x.SiteID).Return(siteId); site.Stub(x => x.IsEmergencyClosed).Return(false); site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Constraints(Is.Anything()).Return(false); siteList = mocks.DynamicMock<ISiteList>(); siteList.Stub(x => x.GetSite(1)).Return(site); mocks.ReplayAll(); }
private static void CreateJournalTestSetup(out int userId, out string identityUserName, out int forumId, out int threadId, out int itemsPerPage, out int startIndex, out ThreadOrder threadOrder, out bool overFlow, out IDnaDataReaderCreator creator, out ISiteList siteList, out int siteId) { var mocks = new MockRepository(); siteId = 1; userId = 6; identityUserName = "******"; forumId = 7; threadId = 0; itemsPerPage = 10; startIndex = 0; threadOrder = ThreadOrder.LatestPost; overFlow = true; var reader = mocks.DynamicMock<IDnaDataReader>(); reader.Stub(x => x.HasRows).Return(true); reader.Stub(x => x.Read()).Return(true); reader.Stub(x => x.GetInt32NullAsZero("Journal")).Return(forumId); reader.Stub(x => x.GetInt32NullAsZero("ThreadID")).Return(threadId); reader.Stub(x => x.GetInt32NullAsZero("ThreadCount")).Return(itemsPerPage + 1); reader.Stub(x => x.GetInt32NullAsZero("SiteID")).Return(siteId); reader.Stub(x => x.DoesFieldExist("ForumPostCount")).Return(true); reader.Stub(x => x.GetInt32NullAsZero("ForumPostCount")).Return(itemsPerPage + 1); reader.Stub(x => x.GetDateTime("ThreadLastUpdated")).Return(DateTime.MinValue); reader.Stub(x => x.GetDateTime("ForumLastUpdated")).Return(DateTime.MinValue); creator = mocks.DynamicMock<IDnaDataReaderCreator>(); creator.Stub(x => x.CreateDnaDataReader("finduserfromidentityusername")).Return(reader); creator.Stub(x => x.CreateDnaDataReader("finduserfromid")).Return(reader); creator.Stub(x => x.CreateDnaDataReader("forumgetthreadlist")).Return(reader); creator.Stub(x => x.CreateDnaDataReader("GetForumSiteID")).Return(reader); creator.Stub(x => x.CreateDnaDataReader("cachegetforumlastupdate")).Return(reader); var site = mocks.DynamicMock<ISite>(); site.Stub(x => x.SiteID).Return(siteId); siteList = mocks.DynamicMock<ISiteList>(); siteList.Stub(x => x.GetSite(1)).Return(site); mocks.ReplayAll(); }
private static void GetSiteForForumIdTestSetup(out MockRepository mocks, out IDnaDataReaderCreator creator, out ISiteList siteList) { const int siteId = 1; mocks = new MockRepository(); var reader = mocks.DynamicMock<IDnaDataReader>(); reader.Stub(x => x.HasRows).Return(true); reader.Stub(x => x.Read()).Return(true); reader.Stub(x => x.GetInt32NullAsZero("SiteID")).Return(siteId); creator = mocks.DynamicMock<IDnaDataReaderCreator>(); creator.Stub(x => x.CreateDnaDataReader("GetForumSiteID")).Return(reader); var site = mocks.DynamicMock<ISite>(); site.Stub(x => x.SiteID).Return(siteId); siteList = mocks.DynamicMock<ISiteList>(); siteList.Stub(x => x.GetSite(siteId)).Return(site); mocks.ReplayAll(); }