public async void GetExamsByTypeAndCategory_WhenExists_ReturnsResult() { using (var fixture = new ExamsFixture()) { var exams = new List <Exam> { new ExamBuilder("First Exam", ExamType.GeneralKnowledge, "Kardiologia").Build(), new ExamBuilder("Second Exam", ExamType.GeneralKnowledge, "Interna").Build(), new ExamBuilder("Third Exam", ExamType.Specialization, "Kardiologia").Build() }; await fixture.AddMany(exams); var expected = new ExamsResult(new[] { fixture.Mapper.Map <ExamsResult.Exam>(exams[1]) }); var query = new GetExamsByTypeAndCategoryQuery() { Category = "Interna", Type = ExamType.GeneralKnowledge }; var handler = new GetExamsByTypeAndCategoryQueryHandler(fixture.Repository, fixture.Mapper); var result = await handler.HandleAsync(query); result.Content.Should().BeEquivalentTo(expected); } }
public async void GetExamsByTypeAndCategory_WhenExists_ReturnsResultWithStatus200() { using (var sut = new SystemUnderTest(UsersFactory.CreateUser("*****@*****.**", Role.GetExamByTypeAndCategory))) { var exams = await sut.CreateManyAsync(new List <Exam>() { new ExamBuilder("First Exam", ExamType.GeneralKnowledge, "Kardiologia").Build(), new ExamBuilder("Second Exam", ExamType.GeneralKnowledge, "Interna").Build(), new ExamBuilder("Third Exam", ExamType.Specialization, "Kardiologia").Build() }); var expected = new ExamsResult(new [] { sut.Mapper.Map <ExamsResult.Exam>(exams[1]) }); var url = $"{Url}/{nameof(ExamType.GeneralKnowledge)}/Interna"; var result = sut.HttpGet <ExamsResult>(url); result.IsSuccess.Should().BeTrue(); result.Content.Should().BeEquivalentTo(expected); } }