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

loresoft / MediatR.CommandQuery / 9307610999

30 May 2024 06:43PM CUT coverage: 57.741%. Remained the same
9307610999

Pull #513

github

web-flow
Merge e90664f48 into 7184530a4
Pull Request #513: Bump Microsoft.NET.Test.Sdk from 17.9.0 to 17.10.0

348 of 708 branches covered (49.15%)

Branch coverage included in aggregate %.

1032 of 1682 relevant lines covered (61.36%)

19.52 hits per line

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

0.0
/src/MediatR.CommandQuery.Cosmos/Handlers/EntityIdentifierQueryHandler.cs
1
using AutoMapper;
2

3
using Cosmos.Abstracts;
4

5
using MediatR.CommandQuery.Definitions;
6
using MediatR.CommandQuery.Queries;
7

8
using Microsoft.Extensions.Logging;
9

10
namespace MediatR.CommandQuery.Cosmos.Handlers;
11

12
public class EntityIdentifierQueryHandler<TRepository, TEntity, TReadModel>
13
    : RepositoryHandlerBase<TRepository, TEntity, EntityIdentifierQuery<string, TReadModel>, TReadModel>
14
    where TRepository : ICosmosRepository<TEntity>
15
    where TEntity : class, IHaveIdentifier<string>, new()
16
{
17
    public EntityIdentifierQueryHandler(ILoggerFactory loggerFactory, TRepository repository, IMapper mapper) : base(loggerFactory, repository, mapper)
×
18
    {
19
    }
×
20

21
    protected override async Task<TReadModel> Process(EntityIdentifierQuery<string, TReadModel> request, CancellationToken cancellationToken)
22
    {
23
        if (request is null)
×
24
            throw new ArgumentNullException(nameof(request));
×
25
        if (!CosmosKey.TryDecode(request.Id, out var id, out var partitionKey))
×
26
            throw new InvalidOperationException("Invalid Cosmos Key format");
×
27

28
        var entity = await Repository
×
29
            .FindAsync(id, partitionKey, cancellationToken)
×
30
            .ConfigureAwait(false);
×
31

32
        // convert deleted entity to read model
33
        var model = Mapper.Map<TReadModel>(entity);
×
34

35
        return model;
×
36
    }
×
37
}
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