< Summary

Information
Class: Trailblazer.Pathing.NavigationAreaPolicyKey
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Traversal/NavigationAreaPolicyKey.cs
Line coverage
100%
Covered lines: 30
Uncovered lines: 0
Coverable lines: 30
Total lines: 75
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%
Equals(...)100%22100%
Equals(...)100%22100%
GetHashCode()100%22100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%
Validate(...)100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Traversal/NavigationAreaPolicyKey.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationAreaPolicyKey.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9using SwiftCollections.Utility;
 10
 11namespace Trailblazer.Pathing;
 12
 13/// <summary>
 14/// Identifies one immutable navigation-area policy revision.
 15/// </summary>
 16public readonly struct NavigationAreaPolicyKey : IEquatable<NavigationAreaPolicyKey>
 17{
 18    /// <summary>Creates a stable policy identity and positive revision.</summary>
 19    public NavigationAreaPolicyKey(string policyId, long revision)
 20    {
 37621        SwiftThrowHelper.ThrowIfArgument(
 37622            string.IsNullOrWhiteSpace(policyId),
 37623            nameof(policyId),
 37624            "Policy ID cannot be null, empty, or whitespace.");
 37525        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 37526            revision <= 0,
 37527            actualValue: null,
 37528            nameof(revision),
 37529            "Policy revision must be positive.");
 30
 37431        PolicyId = policyId;
 37432        Revision = revision;
 37433    }
 34
 35    /// <summary>Gets the stable ordinal host-owned policy identifier.</summary>
 36    public string PolicyId { get; }
 37
 38    /// <summary>Gets the positive immutable content revision.</summary>
 39    public long Revision { get; }
 40
 41    /// <inheritdoc/>
 42    public bool Equals(NavigationAreaPolicyKey other) =>
 3107843        string.Equals(PolicyId, other.PolicyId, StringComparison.Ordinal)
 3107844        && Revision == other.Revision;
 45
 46    /// <inheritdoc/>
 21147    public override bool Equals(object? obj) => obj is NavigationAreaPolicyKey other && Equals(other);
 48
 49    /// <inheritdoc/>
 50    public override int GetHashCode()
 51    {
 337052        int idHash = PolicyId == null
 337053            ? 0
 337054            : SwiftHashTools.GetDeterministicStringEqualityComparer().GetHashCode(PolicyId);
 337055        return SwiftHashTools.CombineHashCodes(idHash, Revision.GetHashCode());
 56    }
 57
 58    /// <summary>Tests two policy keys for equality.</summary>
 249959    public static bool operator ==(NavigationAreaPolicyKey left, NavigationAreaPolicyKey right) => left.Equals(right);
 60
 61    /// <summary>Tests two policy keys for inequality.</summary>
 162    public static bool operator !=(NavigationAreaPolicyKey left, NavigationAreaPolicyKey right) => !left.Equals(right);
 63
 64    internal void Validate(string parameterName)
 65    {
 222666        SwiftThrowHelper.ThrowIfArgument(
 222667            string.IsNullOrWhiteSpace(PolicyId),
 222668            parameterName,
 222669            "Area policy key must contain a stable ID and positive revision.");
 222670        SwiftThrowHelper.ThrowIfArgument(
 222671            Revision <= 0,
 222672            parameterName,
 222673            "Area policy key must contain a stable ID and positive revision.");
 222674    }
 75}