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); }
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"); } }