public async Task ShouldEvaluateAndSaveResults(IFixture fixture, int userId, int examId)
        {
            var answerKeyForms = GenerateAnswerKeyOpticalForms(fixture, 1).ToList();

            var client = _webApplicationFactory.CreateClientWithUserId(userId);
            var repo   = _webApplicationFactory.Services.GetRequiredService <IAnswerKeyOpticalFormRepository>();

            await ExecuteExamCreatedConsumerAsync(repo, answerKeyForms, examId);

            var studentOpticalFormRepository =
                _webApplicationFactory.Services.GetRequiredService <IStudentOpticalFormRepository>();
            var examStatisticsRepository       = _webApplicationFactory.Services.GetRequiredService <IExamStatisticsRepository>();
            var answerKeyOpticalFormRepository = _webApplicationFactory.Services.GetRequiredService <IAnswerKeyOpticalFormRepository>();
            var logger = _webApplicationFactory.Services.GetRequiredService <ILogger <EvaluateExamConsumer> >();

            var forms = new List <StudentOpticalForm>
            {
                GenerateStudentForm(fixture, examId, userId),
                GenerateStudentForm(fixture, examId, userId),
            };
            var response = await client.PostAsync(ApiPath, forms.ToJsonContent());

            response.EnsureSuccessStatusCode();

            var consumer = new EvaluateExamConsumer(
                studentOpticalFormRepository,
                logger,
                new Evaluator(),
                answerKeyOpticalFormRepository,
                null,
                examStatisticsRepository);
            await consumer.ConsumeAsync(examId);

            var studentOpticalForms = await GetListAsync <StudentOpticalForm>(client, examId);

            studentOpticalForms.Should().HaveCount(forms.Count);
            studentOpticalForms.Should().NotContain(s => !s.Orders.Any());
            response = await client.GetAsync($"api/v1/exam-statistics/{examId}");

            var examStats = await response.ReadAsync <ExamStatistics>();

            examStats.GeneralAttendanceCount.Should().Be(forms.Count);
            examStats.CityAttendanceCounts.First().Value.Should().Be(forms.Count);
            examStats.ClassroomAttendanceCounts.First().Value.Should().Be(forms.Count);
            examStats.DistrictAttendanceCounts.First().Value.Should().Be(forms.Count);
            examStats.SchoolAttendanceCounts.First().Value.Should().Be(forms.Count);
        }
        public async Task ShouldEvaluateAndSaveResults()
        {
            var userId         = RandomGen.Next(10000);
            var answerKeyForms = GenerateAnswerKeyOpticalForms(1).ToList();

            using (var testServer = Create(userId))
            {
                var client = testServer.CreateClient();
                var examId = await ExecuteExamCreatedConsumerAsync(testServer, answerKeyForms);

                var repository = testServer.Host.Services.GetService(typeof(IOpticalFormRepository));
                var logger     = testServer.Host.Services.GetService(typeof(ILogger <EvaluateExamConsumer>));
                var forms      = new List <StudentOpticalForm>
                {
                    GenerateStudentForm(examId, userId),
                    GenerateStudentForm(examId, userId),
                };
                var response = await client.PostAsync(ApiPath, forms.ToJsonContent());

                response.EnsureSuccessStatusCode();

                var consumer = new EvaluateExamConsumer(
                    repository as IOpticalFormRepository,
                    logger as ILogger <EvaluateExamConsumer>);
                await consumer.ConsumeAsync(examId);

                var studentOpticalForms = await GetListAsync <StudentOpticalForm>(client, examId);

                studentOpticalForms.Should().HaveCount(forms.Count);
                studentOpticalForms.Should().NotContain(s => !s.Orders.Any());
                studentOpticalForms.First().GeneralAttendanceCount.Should().Be(forms.Count);
                studentOpticalForms.First().CityAttendanceCount.Should().Be(forms.Count);
                studentOpticalForms.First().ClassroomAttendanceCount.Should().Be(forms.Count);
                studentOpticalForms.First().SchoolAttendanceCount.Should().Be(forms.Count);
            }
        }