public async void ValidarFiltroNumeroProcesso(string numeroProcesso, int responsaveisCountEsperado, int[] responsaveisIdsEsperados)
        {
            // Arrange
            var query = new ObterResponsaveisQuery {
                NumeroProcesso = numeroProcesso
            };

            query.ConfigurarPaginacao(1, 10);

            this.mockResponsavelRepository
            .Setup(r => r.Query())
            .Returns(this.responsaveis.AsQueryable());

            this.mockValidator
            .Setup(v => v.ValidateModelAsync(It.IsNotNull <ObterResponsaveisQuery>()))
            .Returns(Task.FromResult(true));

            // Act
            var result = await sut.Handle(query, default);

            // Assert
            result.Success.Should().BeTrue();
            result.Value.Should().HaveCount(responsaveisCountEsperado);
            result.Value.Select(r => r.Id).Should().Equal(responsaveisIdsEsperados);
        }
        public async void ValidarFiltroCpf(string cpf, int responsavelIdEsperado)
        {
            // Arrange
            var query = new ObterResponsaveisQuery {
                Cpf = cpf
            };

            query.ConfigurarPaginacao(1, 10);

            this.mockResponsavelRepository
            .Setup(r => r.Query())
            .Returns(this.responsaveis.AsQueryable());

            this.mockValidator
            .Setup(v => v.ValidateModelAsync(It.IsNotNull <ObterResponsaveisQuery>()))
            .Returns(Task.FromResult(true));

            // Act
            var result = await sut.Handle(query, default);

            // Assert
            result.Success.Should().BeTrue();
            result.Value.Should().HaveCount(1);
            result.Value[0].Id.Should().Be(responsavelIdEsperado);
        }
        public Task <IActionResult> ObterResponsaveisAsync([FromBody] ObterResponsaveisQuery query, [FromQuery] ObterResponsaveisParameter parameters)
        {
            query.ConfigurarPaginacao(parameters.PageNumber, parameters.PageSize);

            return(this.ExecAndHandleAsync(
                       action: () => this.responsavelService.ObterResponsaveisAsync(query),
                       onSuccessActionResultHandler: (result) =>
            {
                this.EnsurePaginationMetadata(result, "ObterResponsaveis");
                return this.Ok(result);
            }));
        }
        public async void ValidarRetornoPaginado(int pageNumber, int pageSize, int expectedItemsCount, int expectedTotalPages, int expectedTotalCount)
        {
            // Arrange
            var query = new ObterResponsaveisQuery();

            query.ConfigurarPaginacao(pageNumber, pageSize);

            this.mockResponsavelRepository
            .Setup(r => r.Query())
            .Returns(this.responsaveis.AsQueryable());

            this.mockValidator
            .Setup(v => v.ValidateModelAsync(It.IsNotNull <ObterResponsaveisQuery>()))
            .Returns(Task.FromResult(true));

            // Act
            var result = await sut.Handle(query, default);

            // Assert
            result.Success.Should().BeTrue();
            result.Value.Should().HaveCount(expectedItemsCount);
            result.Value.TotalPages.Should().Be(expectedTotalPages);
            result.Value.TotalCount.Should().Be(expectedTotalCount);
        }