public async Task <Nivel> Handle(ObterNivelPorIdQuery request, CancellationToken cancellationToken) { if (!await request.EhValido()) { return(null); } return(await _nivelRepository.ObterPorId(request.Id)); }
public async Task ObterPorId_DeveInvalidarQueryQuandoIdForVazio() { var query = new ObterNivelPorIdQuery(Guid.Empty); var queryHandler = new NivelQueryHandler(_nivelRepository); await queryHandler.Handle(query, CancellationToken.None); (await query.EhValido()).Should().Be(false); query.ValidationResult.Errors .Should() .Contain(error => error.ErrorMessage == "Id deve possuir conteúdo"); }