< Summary - AsyncResponse (Release / net8.0+net10.0 / unit+integration)

Information
Class: AsyncResponse.Transports.NATS.NatsCorrelationIdExtractor
Assembly: AsyncResponse.Transports.NATS
File(s): /_/src/Transports/AsyncResponse.Transports.NATS/NatsCorrelationIdExtractor.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 23
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Extract(...)100%66100%

File(s)

/_/src/Transports/AsyncResponse.Transports.NATS/NatsCorrelationIdExtractor.cs

#LineLine coverage
 1namespace AsyncResponse.Transports.NATS;
 2
 3/// <summary>
 4/// Extracts the AsyncResponse correlation id from an inbound response message: first from the
 5/// configured NATS header, then from the JSON body via the configured paths (walked by the shared
 6/// <see cref="CorrelationIdJsonPaths"/>).
 7/// </summary>
 8internal static class NatsCorrelationIdExtractor
 9{
 10    /// <summary>Extracts the correlation id from the supplied message.</summary>
 11    public static string? Extract(
 12        IReadOnlyDictionary<string, string>? headers,
 13        string messageJson,
 14        NatsAsyncResponseTransportOptions options)
 15    {
 51416        var headerName = NatsTransportOptionsValidator.Required(options.CorrelationIdHeader, nameof(options.CorrelationI
 17
 51418        if (headers is not null && headers.TryGetValue(headerName, out var headerValue) && !string.IsNullOrWhiteSpace(he
 419            return headerValue;
 20
 51021        return CorrelationIdJsonPaths.Extract(messageJson, options.CorrelationIdJsonPaths);
 22    }
 23}