Example #1
0
        public void Detail_WhenCalled_ShouldReturnTopicWithQuestionAnswerPairsInViewModel()
        {
            var topic = _context.AddTestTopicToDatabase();

            var question = _context.AddTestQuestionToDatabase();

            question.AddTopic(topic);

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

            _context.SaveChanges();

            var result = _controller.Detail(topic.Id);

            var topicDetailViewModel = (result as ViewResult).Model as TopicDetailViewModel;

            Assert.That(topicDetailViewModel.Topic.Id, Is.EqualTo(topic.Id));
            Assert.That(topicDetailViewModel.QuestionAnswers.Count, Is.EqualTo(1));
            Assert.That(topicDetailViewModel.QuestionAnswers.Keys.First().Id, Is.EqualTo(question.Id));
            Assert.That(topicDetailViewModel.QuestionAnswers.Values.First().Id, Is.EqualTo(answer.Id));
            Assert.That(topicDetailViewModel.IsFollowing, Is.True);
        }
Example #2
0
        public void Detail_WhenCalled_ReturnViewResult()
        {
            var result = _controller.Detail(_topic1.Id);

            Assert.That(result, Is.TypeOf <ViewResult>());
        }