예제 #1
0
        public async Task <IActionResult> GetTestQuestionByTestIdAsync([FromRoute] int id)
        {
            if (!await _testRepository.IsTestExists(id))
            {
                return(NotFound());
            }

            return(Ok(await _testRepository.GetTestQuestionByTestIdAsync(id)));
        }
예제 #2
0
        public async Task GetTestQuestionByTestIdAsyncTest()
        {
            string userName = "******";
            var    user     = new ApplicationUser()
            {
                Email = userName, UserName = userName
            };
            await _userManager.CreateAsync(user);

            var applicationUser = await _userManager.FindByEmailAsync(user.Email);

            var categoryObj = CreateCategory("category1");
            await _categoryRepository.AddCategoryAsync(categoryObj);

            var questionAC     = CreateQuestionAc(true, "This is some question detail", categoryObj.Id, 1);
            var questionACList = new List <TestQuestionAC>();
            var testQuestionAc = new TestQuestionAC();

            testQuestionAc.Id         = questionAC.Question.Id;
            testQuestionAc.CategoryID = questionAC.Question.CategoryID;
            testQuestionAc.IsSelect   = questionAC.Question.IsSelect;
            questionACList.Add(testQuestionAc);
            await _questionRepository.AddSingleMultipleAnswerQuestionAsync(questionAC, applicationUser.Id);

            var test = CreateTest("Maths");
            await _testRepository.CreateTestAsync(test, applicationUser.Id);

            var testQuestion = new TestQuestion();

            testQuestion.QuestionId = questionAC.Question.Id;
            testQuestion.TestId     = test.Id;
            await _testRepository.AddTestQuestionsAsync(questionACList, test.Id);

            var questionList = await _testRepository.GetTestQuestionByTestIdAsync(test.Id);

            Assert.True(questionList.Count == 1);
        }