< Summary

Information
Class: IceRpc.OutgoingResponse
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/OutgoingResponse.cs
Tag: 1856_27024993493
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 65
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage
100%
Covered methods: 5
Fully covered methods: 5
Total methods: 5
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ErrorMessage()100%11100%
get_Fields()100%11100%
.ctor(...)100%11100%
get_StatusCode()100%11100%
.ctor(...)83.33%66100%

File(s)

/home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/OutgoingResponse.cs

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using System.Collections.Immutable;
 4
 5namespace IceRpc;
 6
 7/// <summary>Represents a response frame sent by the application.</summary>
 8public sealed class OutgoingResponse : OutgoingFrame
 9{
 10    /// <summary>Gets the error message of this response.</summary>
 11    /// <value>The error message of this response. It is guaranteed to be non-<see langword="null" /> when <see
 12    /// cref="StatusCode" /> is different from <see cref="StatusCode.Ok" />, and <see langword="null" /> when <see
 13    /// cref="StatusCode" /> is <see cref="StatusCode.Ok" />.</value>
 16414    public string? ErrorMessage { get; }
 15
 16    /// <summary>Gets or sets the fields of this response.</summary>
 17    /// <value>The fields of this incoming response. Defaults to <see cref="ImmutableDictionary{TKey, TValue}.Empty"
 18    /// />.</value>
 44919    public IDictionary<ResponseFieldKey, OutgoingFieldValue> Fields { get; set; } =
 295820        ImmutableDictionary<ResponseFieldKey, OutgoingFieldValue>.Empty;
 21
 22    /// <summary>Gets the status code of this response.</summary>
 23    /// <value>The <see cref="IceRpc.StatusCode" /> of this response.</value>
 644224    public StatusCode StatusCode { get; }
 25
 26    /// <summary>Constructs an outgoing response with the <see cref="StatusCode.Ok" /> status code and a <see
 27    /// langword="null" /> error message.</summary>
 28    /// <param name="request">The incoming request.</param>
 29    /// <remarks>The constructor also associates this response with the request. If another response is already set on
 30    /// the request, its payload and payload continuation are completed.</remarks>
 31    public OutgoingResponse(IncomingRequest request)
 285332        : base(request.Protocol)
 285333    {
 285334        request.Response = this;
 285335        StatusCode = StatusCode.Ok;
 285336    }
 37
 38    /// <summary>Constructs an outgoing response.</summary>
 39    /// <param name="request">The incoming request.</param>
 40    /// <param name="statusCode">The status code. It must be greater than <see cref="StatusCode.Ok" />.</param>
 41    /// <param name="message">The error message or null to use the default error message.</param>
 42    /// <param name="exception">The exception that is the cause of this failure.</param>
 43    /// <remarks>The constructor also associates this response with the request. If another response is already set on
 44    /// the request, its payload and payload continuation are completed.</remarks>
 45    public OutgoingResponse(
 46        IncomingRequest request,
 47        StatusCode statusCode,
 48        string? message = null,
 49        Exception? exception = null)
 10550        : base(request.Protocol)
 10551    {
 10552        request.Response = this;
 10553        StatusCode = statusCode > StatusCode.Ok ? statusCode :
 10554            throw new ArgumentException(
 10555                $"The status code for an exception must be greater than {nameof(StatusCode.Ok)}.",
 10556                nameof(statusCode));
 57
 10558        string errorMessage = message ?? $"The dispatch failed with status code {statusCode}.";
 10559        if (exception is not null)
 2460        {
 2461            errorMessage += $" The failure was caused by an exception of type '{exception.GetType()}' with message: {exc
 2462        }
 10563        ErrorMessage = errorMessage;
 10564    }
 65}