Exemplo n.º 1
0
 public void TestCorrectAnswer()
 {
     facade.Start(1);
     mockUow.Setup(x => x.QuizQuestionRepository.GetById(1))
     .Returns(questions[0]);
     facade.Answer(1, 3, 1);
     // Verify that record is inserted into DB
     mockUow.Verify(x => x.QuizAnswerRepository.Insert(It.IsAny <QuizAnswer>()), Times.Once);
     // Verify that answer is marked as correct
     Assert.AreEqual(true, answer.IsCorrect);
 }
Exemplo n.º 2
0
        public void Answer(int questionId, int answer, int userId, int quizId)
        {
            try
            {
                log.Debug("Question answer questionId: " + questionId + " answer: " + answer + " userId: " + userId + " quizId: " + quizId);

                _quiz.Answer(questionId, answer, userId);
                log.Debug("Answer saved to database");

                Clients.Caller.notify(NotificationType.SUCCESS, "Answer submitted");
                log.Debug("Notify answer submitted");

                string stats = _quiz.GetAnswerStatistic(questionId);
                Clients.All.setStats(quizId, stats);
                log.Debug("Broadcast answer statistic: " + stats);
            }
            catch (Exception ex)
            {
                log.Error("Exception ", ex);
                Clients.Caller.notify(NotificationType.ERROR, ex.Message);
                log.Debug("Notify error");
            }
        }