public void ToQuestionInfoTest()
 {
     Question question = new Question { CreationDate = new DateTime(2009, 06, 23, 1, 2, 3), Id = 123, Tags = new List<string> { "tag1", "tag2" } };
     QuestionInfo expected = new QuestionInfo { CreationDate = new DateTime(2009, 06, 23, 1, 2, 3), Id = 123, Tags = new List<string> { "tag1", "tag2"} };
     QuestionInfo actual;
     actual = StackyExtensions.ToQuestionInfo(question);
     Assert.AreEqual(expected, actual);
 }
Example #2
0
        public QuestionModel(Question question, IPagedList<Answer> answers, SiteState state)
        {
            Question = question;
            Answers = answers;

            state.PageSize = 30; //Will always be 30 for quesions.

            if (answers != null)
            {
                state.Page = Convert.ToInt32(answers.CurrentPage);
                state.ItemCount = answers.TotalItems;
                state.MaxPages = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(answers.TotalItems) / Convert.ToDouble(state.PageSize)));
            }
            else
            {
                state.Page = 1;
                state.ItemCount = question.AnswerCount;
                state.MaxPages = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(question.AnswerCount) / Convert.ToDouble(state.PageSize)));
            }

            State = state;
        }