• 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

68.75
/src/MediatR.CommandQuery/Behaviors/ValidateEntityModelCommandBehavior.cs
1
using FluentValidation;
2

3
using MediatR.CommandQuery.Commands;
4

5
using Microsoft.Extensions.Logging;
6

7
namespace MediatR.CommandQuery.Behaviors;
8

9
public class ValidateEntityModelCommandBehavior<TEntityModel, TResponse>
10
    : PipelineBehaviorBase<EntityModelCommand<TEntityModel, TResponse>, TResponse>
11
    where TEntityModel : class
12
{
13
    private readonly IValidator<TEntityModel> _validator;
14

15
    public ValidateEntityModelCommandBehavior(ILoggerFactory loggerFactory, IValidator<TEntityModel> validator) : base(loggerFactory)
40✔
16
    {
17
        _validator = validator ?? throw new ArgumentNullException(nameof(validator));
40!
18
    }
40✔
19

20
    protected override async Task<TResponse> Process(
21
        EntityModelCommand<TEntityModel, TResponse> request,
22
        RequestHandlerDelegate<TResponse> next,
23
        CancellationToken cancellationToken)
24
    {
25
        if (request is null)
36!
26
            throw new ArgumentNullException(nameof(request));
×
27

28
        if (next is null)
36!
29
            throw new ArgumentNullException(nameof(next));
×
30

31
        // validate before processing
32
        await _validator.ValidateAndThrowAsync(request.Model, cancellationToken: cancellationToken).ConfigureAwait(false);
36✔
33

34
        // continue pipeline
35
        return await next().ConfigureAwait(false);
36✔
36
    }
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