Ejemplo n.º 1
0
        public async Task GetAll_Doctors_ReturnsTrue(
            [Frozen] List <Doctor> doctor,
            [Frozen] List <ReadDoctorDto> doctorDto,
            [Frozen] PaginationQuery paginationQuery,
            [Frozen] PaginationFilter paginationFilter,
            [Frozen] DoctorsFiltrationQuery query,
            [Frozen] DoctorsFilter filter
            )
        {
            // Arrange
            doctorServiceMock.Setup(m => m.GetDoctorAsync(filter, paginationFilter))
            .ReturnsAsync(doctor);
            mapper.Setup(m => m.Map <ICollection <ReadDoctorDto> >(doctor))
            .Returns(doctorDto);
            mapper.Setup(m => m.Map <PaginationFilter>(paginationQuery))
            .Returns(paginationFilter);
            mapper.Setup(m => m.Map <DoctorsFilter>(query))
            .Returns(filter);

            // Act
            var actualResult = await doctorController.GetAsync(query, paginationQuery);

            // Assert
            var result = actualResult as OkObjectResult;

            Assert.True(actualResult is OkObjectResult);
            doctorServiceMock.Verify(m => m.GetDoctorAsync(filter, paginationFilter), Times.Once);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetAsync(
            [FromQuery] DoctorsFiltrationQuery query,
            [FromQuery] PaginationQuery paginationQuery)
        {
            var pagination = _mapper.Map <PaginationFilter>(paginationQuery);
            var filter     = _mapper.Map <DoctorsFilter>(query);
            var doctors    = await _doctorService.GetDoctorAsync(filter, pagination);

            var doctorsDto = _mapper.Map <ICollection <ReadDoctorDto> >(doctors);
            var totalCount = await _doctorService.GetTotalCount(filter);

            var pagedResponse = new PagedResponse <ReadDoctorDto>(doctorsDto, paginationQuery, totalCount);

            return(Ok(pagedResponse));
        }