public async Task SetAttendeeBrowserToleranceValueAsyncTest() { var test = CreateTest("Mathematics"); await _testRepository.CreateTestAsync(test, "5"); var testAttendee = CreateTestAttendee(test.Id); await _testConductRepository.RegisterTestAttendeesAsync(testAttendee); testAttendee.AttendeeBrowserToleranceCount = 2; await _testConductRepository.SetAttendeeBrowserToleranceValueAsync(testAttendee.Id, testAttendee.AttendeeBrowserToleranceCount); Assert.True(testAttendee.AttendeeBrowserToleranceCount != 0); }
public async Task <IActionResult> CreateTest([FromBody] Test test) { var applicationUser = await _userManager.FindByEmailAsync(User.Identity.Name); if (ModelState.IsValid) { await _testRepository.CreateTestAsync(test, applicationUser.Id); return(Ok(test)); } else { return(BadRequest()); } }
public async Task GetTestAttendeeDetailsByIdAsyncTest() { var test = CreateTest("Mathematics"); await _testRepository.CreateTestAsync(test, "1"); var testAttendee = CreateTestAttendee(test.Id); await _testConductRepository.RegisterTestAttendeesAsync(testAttendee); var testAttendeeObject = await _reportRepository.GetTestAttendeeDetailsByIdAsync(testAttendee.Id); Assert.NotNull(testAttendeeObject); }
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 AddTest() { var test = CreateTest("testname"); string userName = "******"; ApplicationUser user = new ApplicationUser() { Email = userName, UserName = userName }; await _userManager.CreateAsync(user); var applicationUser = await _userManager.FindByEmailAsync(user.Email); await _testRepository.CreateTestAsync(test, applicationUser.Id); Assert.True(_trappistDbContext.Test.Count() == 1); }