< Summary

Information
Class: IceRpc.Features.RequestContextFeature
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/Features/RequestContextFeature.cs
Tag: 275_13775359185
Line coverage
37%
Covered lines: 3
Uncovered lines: 5
Coverable lines: 8
Total lines: 41
Line coverage: 37.5%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
37%
Covered methods: 3
Total methods: 8
Method coverage: 37.5%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Value()100%11100%
get_Item(...)100%210%
set_Item(...)100%210%
.ctor()100%11100%
.ctor(...)100%11100%
Add(...)100%210%
GetEnumerator()100%210%
System.Collections.IEnumerable.GetEnumerator()100%210%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Collections;
 4
 5namespace IceRpc.Features;
 6
 7/// <summary>Default implementation of <see cref="IRequestContextFeature" />.</summary>
 8/// <remarks>This class implements <see cref="IEnumerable" />, <see cref="Add" /> and the indexer operator to allow you
 9/// to use a collection initializer.</remarks>
 10public sealed class RequestContextFeature : IRequestContextFeature, IEnumerable<KeyValuePair<string, string>>
 11{
 12    /// <inheritdoc/>
 3913    public IDictionary<string, string> Value { get; }
 14
 15    /// <summary>Gets or sets an entry in <see cref="Value" />.</summary>
 16    /// <param name="key">The key.</param>
 17    /// <returns>The value.</returns>>
 18    public string this[string key]
 19    {
 020        get => Value[key];
 021        set => Value[key] = value;
 22    }
 23
 24    /// <summary>Constructs an empty writeable request context feature.</summary>
 1625    public RequestContextFeature() => Value = new Dictionary<string, string>();
 26
 27    /// <summary>Constructs a request context feature with the specified dictionary.</summary>
 28    /// <param name="dictionary">The dictionary that the new feature will hold.</param>
 3029    public RequestContextFeature(IDictionary<string, string> dictionary) => Value = dictionary;
 30
 31    /// <summary>Adds a new entry to <see cref="Value" />.</summary>
 32    /// <param name="key">The key of the new entry.</param>
 33    /// <param name="value">The value of the new entry.</param>
 034    public void Add(string key, string value) => Value.Add(key, value);
 35
 36    /// <inheritdoc />
 037    public IEnumerator<KeyValuePair<string, string>> GetEnumerator() => Value.GetEnumerator();
 38
 39    /// <inheritdoc />
 040    IEnumerator IEnumerable.GetEnumerator() => ((IEnumerable)Value).GetEnumerator();
 41}