public async Task GetTestInstructionsAsyncTest() { //Creating test var test = await CreateTestAsync(); //Creating test category var category1 = CreateCategory("Mathematics"); await _categoryRepository.AddCategoryAsync(category1); var category2 = CreateCategory("Computer"); await _categoryRepository.AddCategoryAsync(category2); var category3 = CreateCategory("History"); await _categoryRepository.AddCategoryAsync(category3); var testCategoryAC = new List <TestCategoryAC> { new TestCategoryAC() { CategoryId = category1.Id, IsSelect = true }, new TestCategoryAC() { CategoryId = category1.Id, IsSelect = false }, new TestCategoryAC() { CategoryId = category2.Id, IsSelect = true } }; await _testRepository.AddTestCategoriesAsync(test.Id, testCategoryAC); //Creating test questions var questionList = new List <QuestionAC> { CreateQuestionAC(true, "Category1 type question", category1.Id, 1), CreateQuestionAC(false, "Category1 type question", category1.Id, 2), CreateQuestionAC(true, "Category3 type question", category3.Id, 3), CreateQuestionAC(true, "Category3 type question", category3.Id, 4), }; var testQuestionList = new List <TestQuestionAC>(); questionList.ForEach(x => { var testQuestion = new TestQuestionAC(); testQuestion.CategoryID = x.Question.CategoryID; testQuestion.Id = x.Question.Id; testQuestion.IsSelect = x.Question.IsSelect; testQuestionList.Add(testQuestion); }); await _testRepository.AddTestQuestionsAsync(testQuestionList, test.Id); var testInstruction = await _testConductRepository.GetTestInstructionsAsync(_stringConstants.MagicString); Assert.NotNull(testInstruction); }
public async Task GetTestSummaryDetailsAsyncTest() { var category1 = CreateCategory("history"); await _categoryRepository.AddCategoryAsync(category1); var category2 = CreateCategory("indian culture"); await _categoryRepository.AddCategoryAsync(category2); var testCategoryList = new List <TestCategoryAC> { new TestCategoryAC() { IsSelect = true, CategoryId = category1.Id }, new TestCategoryAC() { IsSelect = true, CategoryId = category2.Id } }; //Creating questions var question1 = CreateQuestionAC(true, "Who was the father of Humayun ?", category1.Id, 0); var question2 = CreateQuestionAC(true, "Bharatnatyam is a popular dance form of which state ?", category2.Id, 0); await _questionRepository.AddSingleMultipleAnswerQuestionAsync(question1, "5"); await _questionRepository.AddSingleMultipleAnswerQuestionAsync(question2, "5"); var allQuestions = await _questionRepository.GetAllQuestionsAsync("5", 0, 0, "All", null); var test = CreateTest("General Awareness"); await _testRepository.CreateTestAsync(test, "5"); //Adding categories to test await _testRepository.AddTestCategoriesAsync(test.Id, testCategoryList); var qtestQuestionList = new List <TestQuestionAC>(); var questionDetailList = Mapper.Map <List <QuestionDetailAC> >(allQuestions.ToList()); foreach (var question in allQuestions.ToList()) { var testQuestion = new TestQuestionAC(); testQuestion.IsSelect = true; testQuestion.CategoryID = question.CategoryID; testQuestion.Id = question.Id; qtestQuestionList.Add(testQuestion); } await _testRepository.AddTestQuestionsAsync(qtestQuestionList, test.Id); var questionCount = await _testConductRepository.GetTestSummaryDetailsAsync(test.Link); Assert.Equal(2, questionCount); }
public async Task IsQuestionExistInTestTest() { var questionList = new List <TestQuestionAC>(); string userName = "******"; ApplicationUser user = new ApplicationUser() { Email = userName, UserName = userName }; await _userManager.CreateAsync(user); var applicationUser = await _userManager.FindByEmailAsync(user.Email); //create code-snippetQuestion var codingQuestion = await CreateCodingQuestion(); await _questionRepository.AddCodeSnippetQuestionAsync(codingQuestion, applicationUser.Id); //create single-multipleQuestion var multipleAnswerQuestion = await CreateMultipleAnswerQuestion(); await _questionRepository.AddSingleMultipleAnswerQuestionAsync(multipleAnswerQuestion, applicationUser.Id); var testCodingQuestion = new TestQuestionAC(); var codeSnippetquestion = await _trappistDbContext.Question.FirstOrDefaultAsync(x => x.QuestionDetail == codingQuestion.Question.QuestionDetail); testCodingQuestion.Id = codeSnippetquestion.Id; testCodingQuestion.CategoryID = codeSnippetquestion.CategoryID; testCodingQuestion.IsSelect = true; var singleMultipleQuestion = await _trappistDbContext.Question.FirstOrDefaultAsync(x => x.QuestionDetail == multipleAnswerQuestion.Question.QuestionDetail); multipleAnswerQuestion.Question.Id = singleMultipleQuestion.Id; questionList.Add(testCodingQuestion); //create Test var test = CreateTest("DemoTest"); await _testRepository.CreateTestAsync(test, applicationUser.Id); await _testRepository.AddTestQuestionsAsync(questionList, test.Id); Assert.True(await _questionRepository.IsQuestionExistInTestAsync(codeSnippetquestion.Id)); //If Question doesnot exist in test Assert.False(await _questionRepository.IsQuestionExistInTestAsync(multipleAnswerQuestion.Question.Id)); }
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); }
public async Task GetAllTestCategoryQuestionsByIdAsync() { var category1 = CreateCategory("category1"); await _categoryRepository.AddCategoryAsync(category1); var category2 = CreateCategory("category2"); await _categoryRepository.AddCategoryAsync(category2); var testCategoryAC = new List <TestCategoryAC> { new TestCategoryAC() { IsSelect = true, CategoryId = category1.Id }, new TestCategoryAC() { IsSelect = false, CategoryId = category2.Id } }; string userName = "******"; //Configuring Application User ApplicationUser user = new ApplicationUser() { Email = userName, UserName = userName }; await _userManager.CreateAsync(user); var applicationUser = await _userManager.FindByEmailAsync(user.Email); //Creating questions var question1 = CreateQuestionAc(true, "This is in Category 1", category1.Id, 0); var question2 = CreateQuestionAc(true, "This is in Category 2", category2.Id, 0); await _questionRepository.AddSingleMultipleAnswerQuestionAsync(question1, applicationUser.Id); await _questionRepository.AddSingleMultipleAnswerQuestionAsync(question2, applicationUser.Id); var allQuestions = await _questionRepository.GetAllQuestionsAsync(user.Id, 0, 0, "All", null); var test = CreateTest("Maths"); await _testRepository.CreateTestAsync(test, applicationUser.Id); //Adding categories to test await _testRepository.AddTestCategoriesAsync(test.Id, testCategoryAC); var questionListAc = new List <TestQuestionAC>(); var questionDetailList = Mapper.Map <List <Question>, List <QuestionDetailAC> >(allQuestions.ToList()); foreach (var question in questionDetailList) { var questionAc = new TestQuestionAC(); questionAc.IsSelect = true; questionAc.Id = question.Id; questionListAc.Add(questionAc); } await _testRepository.AddTestQuestionsAsync(questionListAc, test.Id); var questionAcList = await _testRepository.GetAllQuestionsByIdAsync(test.Id, category1.Id, applicationUser.Id); Assert.Equal(1, questionAcList.Count); Assert.Equal(2, _trappistDbContext.TestQuestion.Count()); Assert.True(questionAcList[0].Question.IsSelect); }