public void MarkThreadRead_ValidDbCall_ReturnsNoExceptions() { IDnaDataReader reader = mocks.DynamicMock<IDnaDataReader>(); IDnaDataReaderCreator creator = mocks.DynamicMock<IDnaDataReaderCreator>(); creator.Stub(x => x.CreateDnaDataReader("markthreadread")).Return(reader); mocks.ReplayAll(); int userId = 0; int threadId = 0; int postId = 0; bool force = false; ForumHelper helper = new ForumHelper(creator); helper.MarkThreadRead(userId, threadId, postId, force); helper.MarkThreadRead(userId, threadId, postId, true); }
public Stream GetForumThreadsWithPost(string siteName, string forumId, string threadId, string postId) { bool applySkin = QueryStringHelper.GetQueryParameterAsBool("applyskin", false); ISite site = Global.siteList.GetSite(siteName); ForumThreadPosts forumThreadPosts = null; CallingUser callingUser = null; try { callingUser = GetCallingUser(site); } catch (DnaWebProtocolException) { callingUser = null; } int fourmIdInt = Int32.Parse(forumId); int threadIdInt = Int32.Parse(threadId); forumThreadPosts = ForumThreadPosts.CreateThreadPostsByCallingUser(readerCreator, cacheManager, callingUser, siteList, site.SiteID, Int32.Parse(forumId), Int32.Parse(threadId), itemsPerPage, startIndex, Int32.Parse(postId), (SortBy.Created == sortBy), false, applySkin); try { if (callingUser.UserID > 0) { //get subscriptions SubscribeState subscribeState = SubscribeState.GetSubscriptionState(readerCreator, callingUser.UserID, threadIdInt, fourmIdInt); if (subscribeState != null && subscribeState.Thread != 0 && forumThreadPosts != null && forumThreadPosts.Post.Count > 0) { //update the last read post if the user is subscribed, increment by 1 because its a 0 based index if (subscribeState.LastPostCountRead < forumThreadPosts.Post[forumThreadPosts.Post.Count - 1].Index + 1) { ForumHelper forumHelper = new ForumHelper(readerCreator); forumHelper.MarkThreadRead(callingUser.UserID, threadIdInt, forumThreadPosts.Post[forumThreadPosts.Post.Count - 1].Index + 1, true); } } } } catch { } return GetOutputStream(forumThreadPosts); }