Exemplo n.º 1
0
        public void Detail_WhenCalled_ShouldReturnAnswerAndAnswerCountAndMoreAnswersAndQuestionInViewModel()
        {
            var question         = _context.AddTestQuestionToDatabase();
            var answer           = _context.AddTestAnswerToDatabase(question.Id);
            var secondUserIdInDb = "2";
            var answer2          = _context.AddTestAnswerToDatabase(question.Id, userId: secondUserIdInDb);

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

            var answerDetailViewModel   = (result as ViewResult).Model as AnswerDetailViewModel;
            var questionDetailViewModel = answerDetailViewModel.QuestionDetailViewModel;

            Assert.That(answerDetailViewModel.Answer.Id, Is.EqualTo(answer.Id));
            Assert.That(answerDetailViewModel.MoreAnswers.First().Id, Is.EqualTo(answer2.Id));
            Assert.That(answerDetailViewModel.AnswerCount, Is.EqualTo(2));
            Assert.That(questionDetailViewModel.Question.Id, Is.EqualTo(question.Id));
            Assert.That(questionDetailViewModel.UserAnswerId, Is.EqualTo(answer.Id));
            Assert.That(questionDetailViewModel.CanUserDeleteAnswerPanelAnswer, Is.True);
        }
Exemplo n.º 2
0
        public void Detail_WhenCalled_ReturnViewResult()
        {
            var result = _controller.Detail(_answer1.Id);

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