コード例 #1
0
ファイル: Forum.aspx.cs プロジェクト: ITLec/Dynamics-365-XEP
        protected void ForumThreads_DataBound(object sender, EventArgs args)
        {
            var pager = ForumThreads.FindControl("ForumThreadsPager") as DataPager;

            if (pager == null)
            {
                return;
            }

            pager.Visible = pager.PageSize < pager.TotalRowCount;
        }
コード例 #2
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
 public static ForumThreads CreateForumThreadsTest()
 {
     var threads = new ForumThreads
                       {
                           ModerationStatus = new ModerationStatusObj
                                                  {
                                                      Value = "",
                                                      Id = 0
                                                  },
                           OrderBy = string.Empty,
                           Thread = new List<ThreadSummary>
                                        {ThreadSummaryTest.CreateThreadSummaryTest()}
                       };
     return threads;
 }
コード例 #3
0
        public IElementContent GetContent(IElementSettings settings, IPageContext pageContext, IUnitOfWork unitOfWork = null)
        {
            LatestThreadSettings latestThreadSettings = (LatestThreadSettings)settings;
            long         tenantId = latestThreadSettings.PageTenantId ?? pageContext.Page.TenantId;
            long         pageId   = latestThreadSettings.PageId ?? pageContext.Page.PageId;
            ForumThreads threads  = null;

            if (pageContext.Tags.Count == 0)
            {
                threads = _forumRepository.ListLatestThreads(tenantId, pageId, latestThreadSettings.PageSize, latestThreadSettings.Recursive, unitOfWork);
            }
            else
            {
                threads = _forumRepository.ListTaggedLatestThreads(tenantId, pageId, latestThreadSettings.PageSize, pageContext.Tags, latestThreadSettings.Recursive, unitOfWork);
            }
            return(new LatestThreadContent {
                PartialViewName = "LatestThread", Threads = threads
            });
        }
コード例 #4
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
 public void JournalOwnerAttribute_Not0_ReturnsString()
 {
     var target = new ForumThreads { JournalOwner = 1 };
     Assert.AreEqual("1", target.JournalOwnerAttribute);
 }
コード例 #5
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
        public void IsUpToDate_ThreadOutOfDate_ReturnsCorrect()
        {
            var target = new ForumThreads()
            {
                LastForumUpdated = DateTime.MaxValue,
                LastThreadUpdated = DateTime.MinValue

            };

            var reader = Mocks.DynamicMock<IDnaDataReader>();
            reader.Stub(x => x.HasRows).Return(true);
            reader.Stub(x => x.Read()).Return(false);

            var creator = Mocks.DynamicMock<IDnaDataReaderCreator>();
            creator.Stub(x => x.CreateDnaDataReader("cachegetforumlastupdate")).Return(reader);
            Mocks.ReplayAll();

            Assert.AreEqual(false, target.IsUpToDate(creator));
        }
コード例 #6
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
        public void CreateForumThreads_UpToDate_ReturnsValidObject()
        {
            IDnaDataReaderCreator readerCreator;
            int forumId;
            int itemsPerPage;
            int startIndex;
            int threadId;
            bool overFlow;
            ThreadOrder threadOrder;
            bool ignoreCache = false;
            ISiteList siteList = null;
            int siteId = 0;

            CreateForumThreadsFromDatabaseTestSetup(out forumId, out threadId, out itemsPerPage, out startIndex,
                                                    out threadOrder, out overFlow, out readerCreator, out siteList,
                                                    out siteId);

           
            var viewingUser = Mocks.DynamicMock<IUser>();
            viewingUser.Stub(x => x.IsEditor).Return(false);
            viewingUser.Stub(x => x.IsSuperUser).Return(false);

            var forumThreads = new ForumThreads()
                                   {
                                       LastForumUpdated = DateTime.MaxValue,
                                       LastThreadUpdated = DateTime.MaxValue,
                                       SiteId = siteId
                                   };
            var cache = Mocks.DynamicMock<ICacheManager>();
            cache.Stub(x => x.GetData("")).Constraints(Is.Anything()).Return(forumThreads);
            cache.Stub(x => x.Add("", null)).Constraints(Is.Anything(), Is.Anything()).Repeat.Once();

            Mocks.ReplayAll();

            ForumThreads actual = ForumThreads.CreateForumThreads(cache, readerCreator, siteList, forumId, itemsPerPage, startIndex,
                                                                  threadId, overFlow, threadOrder, viewingUser, ignoreCache, false);
            Assert.IsNotNull(actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
        }
コード例 #7
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
 public void GetCacheKeyTest()
 {
     var forumThread = new ForumThreads();
     string expected = string.Format("{0}|0|0|0|0|True|0|", typeof (ForumThreads).AssemblyQualifiedName);
     string actual = forumThread.GetCacheKey(0, 0, 0, 0, true, 0);
     Assert.AreEqual(expected, actual);
 }
コード例 #8
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
 public void CloneTest()
 {
     var target = new ForumThreads
                      {
                          Thread = new List<ThreadSummary> {ThreadSummaryTest.CreateThreadSummaryTest()}
                      };
     var actual = (ForumThreads) target.Clone();
     Assert.AreEqual(1, actual.Thread.Count);
 }
コード例 #9
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
        public void ApplyUserSettings_NullUserWithCanWriteIsOneAndDefaultIsZero_ReturnsCannotWrite()
        {
            IUser user = null;

            var site = Mocks.DynamicMock<ISite>();
            site.Stub(x => x.IsEmergencyClosed).Return(false);
            site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Constraints(Is.Anything()).Return(false);
            Mocks.ReplayAll();

            var target = new ForumThreads { CanWrite = 1, DefaultCanWrite = 0 };
            target.ApplyUserSettings(user, site);
            Assert.AreEqual(0, target.CanWrite);
        }
コード例 #10
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
        public void ApplyUserSettings_IsEditor_ReturnsCanWrite()
        {
            var user = Mocks.DynamicMock<IUser>();
            user.Stub(x => x.IsEditor).Return(true);
            user.Stub(x => x.IsSuperUser).Return(false);

            var site = Mocks.DynamicMock<ISite>();
            site.Stub(x => x.IsEmergencyClosed).Return(false);
            site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Constraints(Is.Anything()).Return(false);
            Mocks.ReplayAll();

            var target = new ForumThreads
                             {
                                 Thread = new List<ThreadSummary> {ThreadSummaryTest.CreateThreadSummaryTest()}
                                 , CanWrite=0
                                 ,DefaultCanWrite=0
                             };


            target.ApplyUserSettings(user, site);
            Assert.AreEqual(1, target.CanWrite);
        }
コード例 #11
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
        public void GetLatestSkipValue_ThreadFoundWith11PostsAndShow5_Returns10()
        {
            var threads = new ForumThreads();
            threads.Thread.Add(new ThreadSummary { ThreadId = 1, TotalPosts = 11 });
            Assert.AreEqual(10, threads.GetLatestSkipValue(1, 5));

        }
コード例 #12
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
        public void GetLatestSkipValue_NoThreadFound_Returns0()
        {
            var threads = new ForumThreads();
            Assert.AreEqual(0, threads.GetLatestSkipValue(0,1));

        }
コード例 #13
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
 public void JournalOwnerAttribute_Is0_ReturnsString()
 {
     var target = new ForumThreads();
     Assert.IsNull(target.JournalOwnerAttribute);
 }
 public int PageCount()
 {
     return(Convert.ToInt32(Math.Ceiling(ForumThreads.Count() / (double)ThreadtPerPage)));
 }
コード例 #15
0
ファイル: ForumThreadsTest.cs プロジェクト: rocketeerbkw/DNA
        public void ApplyUserSettings_CanWriteIsZeroSiteOpen_ReturnsCannotWrite()
        {
            var user = Mocks.DynamicMock<IUser>();
            user.Stub(x => x.IsEditor).Return(false);
            user.Stub(x => x.IsSuperUser).Return(false);

            var site = Mocks.DynamicMock<ISite>();
            site.Stub(x => x.IsEmergencyClosed).Return(false);
            site.Stub(x => x.IsSiteScheduledClosed(DateTime.Now)).Constraints(Is.Anything()).Return(false);
            Mocks.ReplayAll();

            var target = new ForumThreads { CanWrite = 0, DefaultCanWrite = 0 };
            target.ApplyUserSettings(user, site);
            Assert.AreEqual(0, target.CanWrite);
        }
        public IEnumerable <ForumThread> PaginatedThread()
        {
            int start = (CurrentPage - 1) * ThreadtPerPage;

            return(ForumThreads.OrderBy(b => b.ThreadId).Skip(start).Take(ThreadtPerPage));
        }
コード例 #17
0
ファイル: ForumPageBuilder.cs プロジェクト: rocketeerbkw/DNA
        /// <summary>
        /// Used to process the current request.
        /// </summary>
        public override void ProcessRequest()
        {
            //get the parameters from the querystring
            GetQueryParameters();
            //Process any commands sent through querystring
            ProcessCommand();

            //Assemble page parts.
            //add topics
            if (InputContext.IsPreviewMode())
            {
                RootElement.AppendChild(ImportNode(InputContext.CurrentSite.GetPreviewTopicsXml(_creator)));
            }
            else
            {
                RootElement.AppendChild(ImportNode(InputContext.CurrentSite.GetTopicListXml()));
            }

            

            //add forumsource
            ForumSource forumSource = ForumSource.CreateForumSource(_cache, _creator, _viewingUser, _forumId, _threadId,
                                                                    InputContext.CurrentSite.SiteID,
                                                                    true, _ignoreCache, false);

            if (forumSource == null)
            {
                AddErrorXml("ForumOrThreadNotFound", "Unable to find the requested forum or thread.", null);
                return;
            }
            if (forumSource.Type == ForumSourceType.Redirect)
            {
//do redirect now
                AddDnaRedirect(((ForumSourceRedirect) forumSource).Url);
                return;
            }
            SerialiseAndAppend(forumSource, String.Empty);

            ForumThreads threads = new ForumThreads();
            //check for article ForumStyle - if 1 then dont include threads
            if (forumSource.Article != null && forumSource.Article.ForumStyle != 1)
            {
//dont add threads for forumstyle=1
                threads = ForumThreads.CreateForumThreads(_cache, _creator, InputContext.TheSiteList,
                                                                       _forumId,
                                                                       THREADSTOSHOW, _skip, _threadId, false,
                                                                       ThreadOrder.LatestPost, _viewingUser, _ignoreCache, false);
                SerialiseAndAppend(threads, String.Empty);
            }

            //get subscriptions
            SubscribeState subscribeState = SubscribeState.GetSubscriptionState(_creator,
                                                                                InputContext.ViewingUser.UserID,
                                                                                _threadId, _forumId);
            if (subscribeState != null)
            {
                SerialiseAndAppend(subscribeState, String.Empty);
            }

            if (_latest)
            {
                _skip = threads.GetLatestSkipValue(_threadId, POSTSTOSHOW);
            }

            //add threadposts if required
            if (_threadId > 0 || (forumSource.Article != null && forumSource.Article.ForumStyle == 1))
            {
//get the thread
                ProcessThreadPosts(subscribeState);
                //add online users
                OnlineUsers users = OnlineUsers.GetOnlineUsers(_creator, _cache, OnlineUsersOrderBy.None,
                                                               InputContext.CurrentSite.SiteID, true, _ignoreCache);
                SerialiseAndAppend(users, String.Empty);
            }


            //add page ui to xml
            PageUi pageUi = PageUi.GetPageUi(_creator, forumSource.Article, _viewingUser);
            SerialiseAndAppend(pageUi, String.Empty);
            
        }