< Summary

Information
Class: dotnet_etcd.AsyncStreamCallFactory<T1, T2>
Assembly: dotnet-etcd
File(s): /home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/AsyncStreamCallFactory.cs
Line coverage
42%
Covered lines: 3
Uncovered lines: 4
Coverable lines: 7
Total lines: 39
Line coverage: 42.8%
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(...)50%22100%
CreateDuplexStreamingCall(...)100%210%

File(s)

/home/runner/work/dotnet-etcd/dotnet-etcd/dotnet-etcd/AsyncStreamCallFactory.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Threading;
 6using dotnet_etcd.interfaces;
 7using Grpc.Core;
 8
 9namespace dotnet_etcd;
 10
 11/// <summary>
 12///     Factory for creating async streaming calls to etcd
 13/// </summary>
 14/// <typeparam name="TRequest">The request type</typeparam>
 15/// <typeparam name="TResponse">The response type</typeparam>
 16public class AsyncStreamCallFactory<TRequest, TResponse> : IAsyncStreamCallFactory<TRequest, TResponse>
 17{
 18    private readonly Func<Metadata, DateTime?, CancellationToken, AsyncDuplexStreamingCall<TRequest, TResponse>>
 19        _callFactory;
 20
 21    /// <summary>
 22    ///     Initializes a new instance of the <see cref="AsyncStreamCallFactory{TRequest, TResponse}" /> class.
 23    /// </summary>
 24    /// <param name="callFactory">Factory function to create the gRPC call</param>
 25    /// <exception cref="ArgumentNullException">Thrown if callFactory is null</exception>
 6326    public AsyncStreamCallFactory(
 6327        Func<Metadata, DateTime?, CancellationToken, AsyncDuplexStreamingCall<TRequest, TResponse>> callFactory) =>
 6328        _callFactory = callFactory ?? throw new ArgumentNullException(nameof(callFactory));
 29
 30    /// <inheritdoc />
 31    public IAsyncDuplexStreamingCall<TRequest, TResponse> CreateDuplexStreamingCall(
 32        Metadata headers,
 33        DateTime? deadline,
 34        CancellationToken cancellationToken)
 035    {
 036        AsyncDuplexStreamingCall<TRequest, TResponse> call = _callFactory(headers, deadline, cancellationToken);
 037        return new AsyncDuplexStreamingCallAdapter<TRequest, TResponse>(call);
 038    }
 39}