Exemplo n.º 1
0
        public void ToQuiz_CreateQuizViewModel_CorrectlyMapped()
        {
            var viewModel = new CreateQuizViewModel { Name = "Name" };
            var model = viewModel.ToQuiz();

            Assert.Equal(viewModel.Name, model.Name);
        }
Exemplo n.º 2
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();
 }
Exemplo n.º 3
0
        //[ClaimsPrincipalPermission(SecurityAction.Demand, Operation = "Create", Resource = "Quiz")]
        public async Task<IHttpActionResult> Post(CreateQuizViewModel newQuizViewModel)
        {
            if (newQuizViewModel == null)
            {
                throw new ArgumentNullException("newQuizViewModel");
            }

            IQuizModel quizModel = newQuizViewModel.ToQuiz();
            IQuizModel createdQuiz;
            try
            {
                createdQuiz = await _quizManagementService.CreateQuizAsync(quizModel);
            }
            catch (InvalidQuizException exception)
            {
                return BadRequestWithModelState(exception);
            }
            return Ok(createdQuiz);
        }