< Summary

Information
Class: IceRpc.OutgoingResponse
Assembly: IceRpc
File(s): /home/runner/work/icerpc-csharp/icerpc-csharp/src/IceRpc/OutgoingResponse.cs
Tag: 2300_35243572715
Line coverage
100%
Covered lines: 20
Uncovered lines: 0
Coverable lines: 20
Total lines: 64
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
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(...)75%44100%

File(s)

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

#LineLine coverage
 1// Copyright (c) ZeroC, Inc.
 2
 3using IceRpc.Internal;
 4using System.Collections.Immutable;
 5
 6namespace IceRpc;
 7
 8/// <summary>Represents a response frame sent by the application.</summary>
 9public sealed class OutgoingResponse : OutgoingFrame
 10{
 11    /// <summary>Gets the error message of this response.</summary>
 12    /// <value>The error message of this response. It is guaranteed to be non-<see langword="null" /> when <see
 13    /// cref="StatusCode" /> is different from <see cref="StatusCode.Ok" />, and <see langword="null" /> when <see
 14    /// cref="StatusCode" /> is <see cref="StatusCode.Ok" />.</value>
 17615    public string? ErrorMessage { get; }
 16
 17    /// <summary>Gets or sets the fields of this response.</summary>
 18    /// <value>The fields of this incoming response. Defaults to <see cref="ImmutableDictionary{TKey, TValue}.Empty"
 19    /// />.</value>
 42220    public IDictionary<ResponseFieldKey, OutgoingFieldValue> Fields { get; set; } =
 297621        ImmutableDictionary<ResponseFieldKey, OutgoingFieldValue>.Empty;
 22
 23    /// <summary>Gets the status code of this response.</summary>
 24    /// <value>The <see cref="IceRpc.StatusCode" /> of this response.</value>
 649825    public StatusCode StatusCode { get; }
 26
 27    /// <summary>Constructs an outgoing response with the <see cref="StatusCode.Ok" /> status code and a <see
 28    /// langword="null" /> error message.</summary>
 29    /// <param name="request">The incoming request.</param>
 30    /// <remarks>The constructor also associates this response with the request. If another response is already set on
 31    /// the request, its payload and payload continuation are completed.</remarks>
 32    public OutgoingResponse(IncomingRequest request)
 285933        : base(request.Protocol)
 285934    {
 285935        request.Response = this;
 285936        StatusCode = StatusCode.Ok;
 285937    }
 38
 39    /// <summary>Constructs an outgoing response.</summary>
 40    /// <param name="request">The incoming request.</param>
 41    /// <param name="statusCode">The status code. It must be greater than <see cref="StatusCode.Ok" />.</param>
 42    /// <param name="message">The error message or null to use the default error message.</param>
 43    /// <param name="exception">The exception that is the cause of this failure.</param>
 44    /// <remarks>The constructor also associates this response with the request. If another response is already set on
 45    /// the request, its payload and payload continuation are completed.</remarks>
 46    public OutgoingResponse(
 47        IncomingRequest request,
 48        StatusCode statusCode,
 49        string? message = null,
 50        Exception? exception = null)
 11751        : base(request.Protocol)
 11752    {
 11753        StatusCode = statusCode > StatusCode.Ok ? statusCode :
 11754            throw new ArgumentException(
 11755                $"The status code for an exception must be greater than {nameof(StatusCode.Ok)}.",
 11756                nameof(statusCode));
 57
 11758        request.Response = this;
 59
 11760        ErrorMessage = DispatchErrorMessage.Compose(
 11761            message ?? $"The dispatch failed with status code {statusCode}.",
 11762            exception);
 11763    }
 64}