< Summary

Information
Class: AsiBackbone.AspNetCore.Acknowledgments.AcknowledgmentChallengeResult
Assembly: AsiBackbone.AspNetCore
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.AspNetCore/Acknowledgments/AcknowledgmentChallengeResult.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 84
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Succeeded()100%11100%
get_Acknowledged()100%22100%
get_Rejected()100%22100%
get_CanProceed()100%22100%
Success(...)100%11100%
Failure(...)100%11100%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.AspNetCore/Acknowledgments/AcknowledgmentChallengeResult.cs

#LineLine coverage
 1using AsiBackbone.Core.Acknowledgments;
 2using AsiBackbone.Core.Results;
 3
 4namespace AsiBackbone.AspNetCore.Acknowledgments;
 5
 6/// <summary>
 7/// Represents the result of handling a host-submitted acknowledgment challenge response.
 8/// </summary>
 9public sealed class AcknowledgmentChallengeResult
 10{
 2311    private AcknowledgmentChallengeResult(
 2312        OperationResult result,
 2313        AcknowledgmentResponse? acknowledgment)
 14    {
 2315        ArgumentNullException.ThrowIfNull(result);
 16
 2317        Result = result;
 2318        Acknowledgment = acknowledgment;
 2319    }
 20
 21    /// <summary>
 22    /// Gets the operation result describing response handling success or failure.
 23    /// </summary>
 24    public OperationResult Result { get; }
 25
 26    /// <summary>
 27    /// Gets the Core acknowledgment response when one was created.
 28    /// </summary>
 29    public AcknowledgmentResponse? Acknowledgment { get; }
 30
 31    /// <summary>
 32    /// Gets a value indicating whether the response was handled successfully.
 33    /// </summary>
 34    /// <remarks>
 35    /// This reports only that the response was valid and produced an acknowledgment record. It is <see langword="true" 
 36    /// when the actor explicitly declined, because a refusal is recorded as a <see cref="AcknowledgmentResponse" />
 37    /// just like an acceptance. Do not use it to decide whether the operation may continue; use
 38    /// <see cref="CanProceed" /> instead.
 39    /// </remarks>
 2840    public bool Succeeded => Result.Succeeded;
 41
 42    /// <summary>
 43    /// Gets a value indicating whether the response was accepted by the actor.
 44    /// </summary>
 845    public bool Acknowledged => Acknowledgment?.Acknowledged == true;
 46
 47    /// <summary>
 48    /// Gets a value indicating whether the response was rejected by the actor.
 49    /// </summary>
 550    public bool Rejected => Acknowledgment?.Rejected == true;
 51
 52    /// <summary>
 53    /// Gets a value indicating whether the operation that required acknowledgment may continue.
 54    /// </summary>
 55    /// <remarks>
 56    /// This is <see langword="true" /> only when the response was handled successfully and the actor accepted. A handle
 57    /// refusal and every handling failure yield <see langword="false" />. It is the single check a host should gate the
 58    /// consequential operation on, matching <see cref="Core.Decisions.GovernanceDecision.CanProceed" />.
 59    /// </remarks>
 560    public bool CanProceed => Succeeded && Acknowledged;
 61
 62    /// <summary>
 63    /// Creates a successful acknowledgment challenge result.
 64    /// </summary>
 65    /// <param name="acknowledgment">The Core acknowledgment response.</param>
 66    /// <returns>A successful challenge result.</returns>
 67    public static AcknowledgmentChallengeResult Success(AcknowledgmentResponse acknowledgment)
 68    {
 769        ArgumentNullException.ThrowIfNull(acknowledgment);
 70
 671        return new AcknowledgmentChallengeResult(OperationResult.Success(), acknowledgment);
 72    }
 73
 74    /// <summary>
 75    /// Creates a failed acknowledgment challenge result.
 76    /// </summary>
 77    /// <param name="code">The failure reason code.</param>
 78    /// <param name="message">The failure reason message.</param>
 79    /// <returns>A failed challenge result.</returns>
 80    public static AcknowledgmentChallengeResult Failure(string code, string message)
 81    {
 1782        return new AcknowledgmentChallengeResult(OperationResult.Failure(code, message), null);
 83    }
 84}