• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / MediatR.CommandQuery / 8911801772

01 May 2024 04:09PM CUT coverage: 57.379% (-1.8%) from 59.163%
8911801772

push

github

pwelter34
tweak build

342 of 700 branches covered (48.86%)

Branch coverage included in aggregate %.

1011 of 1658 relevant lines covered (60.98%)

18.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/MediatR.CommandQuery.MongoDB/Handlers/EntityIdentifiersQueryHandler.cs
1
using AutoMapper;
2

3
using MediatR.CommandQuery.Definitions;
4
using MediatR.CommandQuery.Queries;
5

6
using Microsoft.Extensions.Logging;
7

8
using MongoDB.Abstracts;
9
using MongoDB.Driver;
10
using MongoDB.Driver.Linq;
11

12
namespace MediatR.CommandQuery.MongoDB.Handlers;
13

14
public class EntityIdentifiersQueryHandler<TRepository, TEntity, TKey, TReadModel>
15
    : RepositoryHandlerBase<TRepository, TEntity, TKey, EntityIdentifiersQuery<TKey, TReadModel>, IReadOnlyCollection<TReadModel>>
16
    where TRepository : IMongoRepository<TEntity, TKey>
17
    where TEntity : class, IHaveIdentifier<TKey>, new()
18
{
19
    public EntityIdentifiersQueryHandler(ILoggerFactory loggerFactory, TRepository repository, IMapper mapper) : base(loggerFactory, repository, mapper)
3✔
20
    {
21
    }
3✔
22

23
    protected override async Task<IReadOnlyCollection<TReadModel>> Process(EntityIdentifiersQuery<TKey, TReadModel> request, CancellationToken cancellationToken)
24
    {
25
        if (request is null)
3!
26
            throw new ArgumentNullException(nameof(request));
×
27

28
        var keys = new HashSet<TKey>(request.Ids);
3✔
29

30
        var results = await Repository.Collection
3✔
31
            .AsQueryable()
3✔
32
            .Where(p => keys.Contains(p.Id))
3✔
33
            .ToListAsync(cancellationToken)
3✔
34
            .ConfigureAwait(false);
3✔
35

36
        return Mapper.Map<IList<TEntity>, IReadOnlyCollection<TReadModel>>(results);
3✔
37
    }
3✔
38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc