< Summary

Information
Class: FLP.Application.Handlers.Bugs.GetBugsHandler
Assembly: FLP.Application
File(s): /home/runner/work/FLP.AzureFunctions/FLP.AzureFunctions/FLP.Application/Handlers/Bugs/GetBugsHandler.cs
Line coverage
81%
Covered lines: 13
Uncovered lines: 3
Coverable lines: 16
Total lines: 39
Line coverage: 81.2%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Handle()50%2285.71%

File(s)

/home/runner/work/FLP.AzureFunctions/FLP.AzureFunctions/FLP.Application/Handlers/Bugs/GetBugsHandler.cs

#LineLine coverage
 1using AutoMapper;
 2using FLP.Application.Requests.Bugs;
 3using FLP.Application.Responses.Bugs;
 4using FLP.Application.Validators.Bugs;
 5using FLP.Core.Context.Shared;
 6using FLP.Core.Interfaces.Repository;
 7using MediatR;
 8using Microsoft.Extensions.Logging;
 9
 10namespace FLP.Application.Handlers.Bugs;
 11
 212public class GetBugsHandler(IUnitOfWork _uow, IMapper _mapper, ILogger<GetBugsHandler> _logger) : IRequestHandler<GetBug
 13{
 14    public async Task<BaseResponse<GetBugsPaginatedResponse>> Handle(GetBugsPaginatedRequest request, CancellationToken 
 215    {
 216        _logger.LogInformation("GetBugsHandler called with request: {@Request}", request);
 17
 218        var validator = new GetBugsValidator();
 219        var validationResult = validator.Validate(request);
 20
 221        if (!validationResult.IsValid)
 022        {
 023            _logger.LogWarning("Validation failed for GetBugsRequest: {Errors}", validationResult.Errors);
 024            return new BaseResponse<GetBugsPaginatedResponse>(false,validationResult.Errors.Select(e => e.ErrorMessage))
 25        }
 26
 27        // Retrieve bugs from the repository
 228        var bugs = await _uow.BugRepository.GetAsync(request, cancellationToken);
 229        var count = _uow.BugRepository.CountAsync(request, cancellationToken);
 30
 231        _logger.LogInformation("Retrieved {Count} bugs.", bugs.Count());
 32        // Map the bugs to response DTOs
 233        var response = _mapper.Map<IEnumerable<GetBugResponse>>(bugs);
 34
 235        _logger.LogInformation("Mapped bugs to response DTOs: {@Response}", response);
 36
 237        return new BaseResponse<GetBugsPaginatedResponse>(new GetBugsPaginatedResponse(response, await count));
 238    }
 39}