public async Task <IActionResult> OnPostAnswerQuestionAsync(int userId, int questionId, int answerId) { GameData = await service.AnswerQuestion(userId, questionId, answerId); TempData["IsCorrect"] = GameData.AnswerIsCorrect ? "True" : "False"; return(RedirectToAction("OnGetAsync", new { user_id = userId })); }
public async Task AnswerQuestion_WhenAnswerIsCorrect_AddScore() { int userId = 1; User user = new User { Id = 1, Score = 0 }; int answerId = 2; Answer answer = new Answer { Id = answerId, IsCorrect = true, Point = 5 }; repo.Setup(r => r.GetAnswer(It.IsAny <int>())).ReturnsAsync(answer); repo.Setup(r => r.GetUser(userId)).ReturnsAsync(user); var gameData = await service.AnswerQuestion(userId, 1, answerId); Assert.That(gameData.User.Score.Equals(5)); Assert.That(gameData.AnswerIsCorrect, Is.True); }