public async Task QuizAppService_Test_WrongAnswers() { var appService = new QuizAppService(_documentStore, _bus); var state = await appService.Start(CreateQuiz()); await appService.Answer(new QuizAnswersCommand (state.QuizId, new List <QuizAnswer> { new QuizAnswer { QuestionId = state.Questions.First().Id, OptionId = state.Questions.First().Options.First(x => x.IsCorrect).Id }, new QuizAnswer { QuestionId = state.Questions.Last().Id, OptionId = state.Questions.Last().Options.First(x => !x.IsCorrect).Id }, })); var queryService = new QuizResultsAppService(_documentStore, _bus, null); queryService.Start(); var result = queryService.Get(); Assert.NotNull(result); Assert.Equal(50.0M, result.TotalCorrectAnswersPercent); Assert.Equal(50.0M, result.TotalIncorrectAnswersPercent); Assert.Equal(2, result.Questions.Count); await CleanUp(); }
public async Task QuizAppService_Test_Start() { var appService = new QuizAppService(_documentStore, _bus); var result = await appService.Start(CreateQuiz()); Assert.NotNull(result); Assert.Equal(QuizState.Started.ToString(), result.QuizState); Assert.Equal(2, result.Questions.Count); }