public void LoadMore_TopicDoesNotExist_ReturnNull()
        {
            _topic1 = null;

            var result = _controller.LoadMore(0, 1);

            Assert.That(result, Is.Null);
        }
Beispiel #2
0
        public void LoadMore_WhenCalled_ShouldReturnTopicWithQuestionAnswerPairsInViewModel()
        {
            var topic = _context.AddTestTopicToDatabase();

            var question = _context.AddTestQuestionToDatabase();

            question.AddTopic(topic);
            var answer = _context.AddTestAnswerToDatabase(question.Id);

            for (var i = 0; i < Constants.DefaultPageSize; i++)
            {
                var moreQuestion = _context.AddTestQuestionToDatabase();
                moreQuestion.AddTopic(topic);
                _context.AddTestAnswerToDatabase(moreQuestion.Id);
            }

            _context.AddTestQuestionToDatabase("Question without answers");

            _context.SaveChanges();

            var result = _controller.LoadMore(0, topic.Id);

            var pairs = result.Model as IDictionary <Question, Answer>;

            Assert.That(pairs.Count, Is.EqualTo(1));
            Assert.That(pairs.Keys.First().Id, Is.EqualTo(question.Id));
            Assert.That(pairs.Values.First().Id, Is.EqualTo(answer.Id));
        }