예제 #1
0
 public QuizControllerTest()
 {
     _quizManagementService = A.Fake<IQuizManagementService>();
     _controller = new QuizController(_quizManagementService);
     _quizModelWithId = A.Fake<IQuizModel>();
     _quizWithoutId = A.Fake<Quiz>();
     _createQuizViewModel = A.Fake<CreateQuizViewModel>();
     _questionViewModel = A.Fake<QuestionViewModel>();
     _addQuestionToQuizViewModel = new AddQuestionToQuizViewModel
     {
         QuizId = 1,
         Question = _questionViewModel
     };
     _question = new Question();
 }
예제 #2
0
 public async Task<IHttpActionResult> AddQuestion(AddQuestionToQuizViewModel questionToQuizViewModel)
 {
     if (questionToQuizViewModel == null)
     {
         throw new ArgumentNullException("questionToQuizViewModel");
     }
     try
     {
         var questionModel = questionToQuizViewModel.Question.ToQuestion();
         await _quizManagementService.AddQuestionToQuizAsync(questionToQuizViewModel.QuizId, questionModel);
     }
     catch (InvalidAddQuestionException exception)
     {
         return BadRequestWithModelState(exception);
     }
     return Ok();
 }