示例#1
0
        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));
        }
示例#2
0
        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);
        }
示例#3
0
        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));
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }