コード例 #1
0
        public async void GetExamById_WhenExamsExists_ExamIsReturned()
        {
            using (var fixture = new ExamsFixture())
            {
                var exams = new List <Exam>
                {
                    new ExamBuilder("First Exam", ExamType.GeneralKnowledge, "Kardiologia")
                    .WithQuestion("e1q1", CorrectAnswer.A)
                    .WithQuestion("e1q2", CorrectAnswer.B)
                    .Build(),
                    new ExamBuilder("Second Exam", ExamType.GeneralKnowledge, "Interna")
                    .WithQuestion("e2q1", CorrectAnswer.C)
                    .WithQuestion("e2q2", CorrectAnswer.D)
                    .Build(),
                    new ExamBuilder("Third Exam", ExamType.Specialization, "Kardiologia")
                    .WithQuestion("e3q1", CorrectAnswer.B)
                    .WithQuestion("e3q2", CorrectAnswer.D)
                    .Build()
                };
                await fixture.AddMany(exams);

                var expected = fixture.Mapper.Map <ExamWithQuestionsResult>(exams[1]);

                var query = new GetExamByIdQuery {
                    Id = exams[1].Id
                };
                var handler = new GetExamByIdQueryHandler(fixture.Repository, fixture.Mapper);
                var result  = await handler.HandleAsync(query);

                result.Content.Should().BeEquivalentTo(expected);
            }
        }
コード例 #2
0
        public async void GetExamById_WhenExamNotExists_EmptyValueIsReturned()
        {
            using (var fixture = new ExamsFixture())
            {
                var query = new GetExamByIdQuery {
                    Id = Guid.NewGuid()
                };
                var handler = new GetExamByIdQueryHandler(fixture.Repository, fixture.Mapper);
                var result  = await handler.HandleAsync(query);

                result.Content.Should().BeNull();
            }
        }