示例#1
0
        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();
        }
示例#2
0
        private async Task CleanUp()
        {
            var queryService = new QuizResultsAppService(_documentStore, _bus, null);

            queryService.Start();
            var result = queryService.Get();

            var commandService = new QuizAppService(_documentStore, _bus);
            await commandService.Close(result.QuizId);
        }