public ActionResult TakeTest() { TakeTestViewModel model = new TakeTestViewModel(); model.Questions = _context.RoadieTestQuestions.Where(x => true).ToList(); model.Answers = new List <double>(new double[model.Questions.Count()]); return(View(model)); }
public void TakeTestDisplaysCorrectNumberOfQuestionsData() { INavigationService navigationService = new NavigationService(); IDialogService dialogService = new DialogService(); IDataRepository dataRepository = new QuestionsDesignRepository(); TakeTestViewModel viewModel = new TakeTestViewModel(navigationService, dataRepository, dialogService); //Pass Test to View Model viewModel.CurrentTest = dataRepository.GetTestById(0); viewModel.PrepareTestCommand.Execute(null); Assert.AreEqual(dataRepository.GetTestById(0).QuestionsGroups.SelectMany(x => x.Questions).Count(), viewModel.QuestionsCount); }
public IActionResult TakeTest(Guid testId) { int qstn = 1; int qstnPerpage = 1; int start = (qstn - 1) * qstnPerpage; ViewBag.qstn = qstn; var test = testRepository.FindTest(testId); IEnumerable <QuestionAndAnswer> questions = testRepository.LoadTestQuestions(testId); var TakeTestVM = new TakeTestViewModel { Test = test, Questions = questions.OrderBy(q => q.Id).Skip(start).Take(qstnPerpage), PageCount = Convert.ToInt32(Math.Ceiling(questions.Count() / (double)qstnPerpage)) }; return(View(TakeTestVM)); }
public void TakeTestDisplaysAllAnswersForRandomQuestionData() { INavigationService navigationService = new NavigationService(); IDialogService dialogService = new DialogService(); IDataRepository dataRepository = new QuestionsDesignRepository(); TakeTestViewModel viewModel = new TakeTestViewModel(navigationService, dataRepository, dialogService); //Pass Test to View Model viewModel.CurrentTest = dataRepository.GetTestById(0); viewModel.PrepareTestCommand.Execute(null); int questionId = viewModel.CurrentQuestion.Id; Question questionById = dataRepository.GetQuestionById(questionId); foreach (Answer answerById in questionById.Answers) { Assert.AreEqual(answerById.AnswerPhrase , viewModel.CurrentQuestion.Answers.FirstOrDefault(x => x.Id == answerById.Id).AnswerPhrase); } }
public void TakeTestDisplaysCorrectSelectedAnswerData() { INavigationService navigationService = new NavigationService(); IDialogService dialogService = new DialogService(); IDataRepository dataRepository = new QuestionsDesignRepository(); TakeTestViewModel viewModel = new TakeTestViewModel(navigationService, dataRepository, dialogService); //Pass Test to View Model viewModel.CurrentTest = dataRepository.GetTestById(0); viewModel.PrepareTestCommand.Execute(null); Answer answerToProvide = viewModel.CurrentQuestion.Answers.FirstOrDefault(); viewModel.SelectAnswerCommand.Execute(answerToProvide); Assert.AreEqual(answerToProvide, viewModel.UserAnswers.LastOrDefault().Value); }
public void TakeTestDisplaysRandomQuestionData() { INavigationService navigationService = new NavigationService(); IDialogService dialogService = new DialogService(); IDataRepository dataRepository = new QuestionsDesignRepository(); TakeTestViewModel viewModel = new TakeTestViewModel(navigationService, dataRepository, dialogService); //Pass Test to View Model viewModel.CurrentTest = dataRepository.GetTestById(0); viewModel.PrepareTestCommand.Execute(null); int questionId = viewModel.CurrentQuestion.Id; Question questionById = dataRepository.GetQuestionById(questionId); Assert.AreEqual(questionById.QuestionPhrase, viewModel.CurrentQuestion.QuestionPhrase); }
public void TakeTestDisplaysData() { INavigationService navigationService = new NavigationService(); IDialogService dialogService = new DialogService(); IDataRepository dataRepository = new QuestionsDesignRepository(); TakeTestViewModel viewModel = new TakeTestViewModel(navigationService, dataRepository, dialogService); viewModel.CurrentTest = dataRepository.GetTestById(0); viewModel.PrepareTestCommand.Execute(null); Assert.IsNotNull(viewModel.CurrentQuestion); }