コード例 #1
0
        public async Task GetOne_ShouldReturnNotFoundIfQuestionNotExists()
        {
            var questionRepository = new QuestionRepositoryBuilder().Build();
            var questionController = new QuestionsControllerBuilder().WithRepository(questionRepository)
                                     .Build();

            var notFoundResult = await questionController.GetOne(1);

            Assert.IsInstanceOfType(notFoundResult, typeof(NotFoundResult));
        }
コード例 #2
0
        public async Task GetOne_ShouldReturnOneQuestion()
        {
            var questionRepository = new QuestionRepositoryBuilder().Build();
            var questionController = new QuestionsControllerBuilder().WithRepository(questionRepository)
                                     .Build();

            var savedQuestion = (await questionController.Add(_questionModel)).Cast <CreatedAtRouteResult, Question>();

            var okResult = await questionController.GetOne(savedQuestion.Id);

            var question = okResult.Cast <OkObjectResult, QuestionModel>();

            Assert.IsInstanceOfType(okResult, typeof(OkObjectResult));
        }