< Summary

Information
Class: IceRpc.Features.DeadlineFeature
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Features/DeadlineFeature.cs
Tag: 1856_27024993493
Line coverage
81%
Covered lines: 9
Uncovered lines: 2
Coverable lines: 11
Total lines: 34
Line coverage: 81.8%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage
100%
Covered methods: 4
Fully covered methods: 3
Total methods: 4
Method coverage: 100%
Full method coverage: 75%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
FromTimeout(...)75%4475%
get_Value()100%11100%
.ctor(...)100%11100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Features/DeadlineFeature.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3namespace IceRpc.Features;
 4
 5/// <summary>Default implementation of <see cref="IDeadlineFeature" />.</summary>
 6public sealed class DeadlineFeature : IDeadlineFeature
 7{
 8    // The maximum supported timeout (int.MaxValue ms, ~24.8 days). This is the maximum delay
 9    // CancellationTokenSource.CancelAfter accepts.
 110    private static readonly TimeSpan MaxSupportedTimeout = TimeSpan.FromMilliseconds(int.MaxValue);
 11
 12    /// <summary>Creates a deadline from a timeout.</summary>
 13    /// <param name="timeout">The timeout. Must be a positive value not exceeding ~24.8 days.</param>
 14    /// <returns>A new deadline equal to now plus the timeout.</returns>
 15    /// <exception cref="ArgumentException">Thrown if <paramref name="timeout" /> is not a positive value
 16    /// within the supported range.</exception>
 17    public static DeadlineFeature FromTimeout(TimeSpan timeout)
 318    {
 319        if (timeout <= TimeSpan.Zero || timeout > MaxSupportedTimeout)
 320        {
 321            throw new ArgumentException(
 322                $"The {nameof(timeout)} value must be positive and not exceed {MaxSupportedTimeout}.",
 323                nameof(timeout));
 24        }
 025        return new(DateTime.UtcNow + timeout);
 026    }
 27
 28    /// <inheritdoc/>
 1529    public DateTime Value { get; }
 30
 31    /// <summary>Constructs a deadline feature.</summary>
 32    /// <param name="deadline">The deadline value.</param>
 1833    public DeadlineFeature(DateTime deadline) => Value = deadline;
 34}