< Summary

Information
Class: Trailblazer.Pathing.NavigationConnectionOverlayOperation
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Map/Overlay/NavigationConnectionOverlayOperation.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 69
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
Upsert(...)100%11100%
Suppress(...)100%11100%
RevertToBake(...)100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Map/Overlay/NavigationConnectionOverlayOperation.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationConnectionOverlayOperation.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
 8namespace Trailblazer.Pathing;
 9
 10/// <summary>Identifies the final-state action for a source-owned connection.</summary>
 11public enum NavigationConnectionOverlayOperationKind
 12{
 13    /// <summary>Write or replace a complete connection definition.</summary>
 14    Upsert = 0,
 15
 16    /// <summary>Tombstone the effective source-owned connection.</summary>
 17    Suppress = 1,
 18
 19    /// <summary>Remove the override or tombstone and restore the baked definition.</summary>
 20    RevertToBake = 2
 21}
 22
 23/// <summary>Describes one immutable source-owned connection overlay operation.</summary>
 24public readonly struct NavigationConnectionOverlayOperation
 25{
 26    private NavigationConnectionOverlayOperation(
 27        string id,
 28        NavigationConnectionOverlayOperationKind kind,
 29        NavigationConnection? connection)
 30    {
 416731        SwiftThrowHelper.ThrowIfNull(id, nameof(id));
 416732        SwiftThrowHelper.ThrowIfArgument(
 416733            string.IsNullOrWhiteSpace(id),
 416734            nameof(id),
 416735            "Connection id cannot be empty or whitespace.");
 36
 416737        Id = id;
 416738        Kind = kind;
 416739        Connection = connection;
 416740    }
 41
 42    /// <summary>Gets the stable source-map-local connection identifier.</summary>
 43    public string Id { get; }
 44
 45    /// <summary>Gets the final-state operation kind.</summary>
 46    public NavigationConnectionOverlayOperationKind Kind { get; }
 47
 48    /// <summary>
 49    /// Gets the complete definition for <see cref="NavigationConnectionOverlayOperationKind.Upsert"/>.
 50    /// The value is ignored for suppression and reversion.
 51    /// </summary>
 52    public NavigationConnection? Connection { get; }
 53
 54    /// <summary>Creates an Upsert operation from a complete connection definition.</summary>
 55    public static NavigationConnectionOverlayOperation Upsert(NavigationConnection connection)
 56    {
 414857        SwiftThrowHelper.ThrowIfNull(connection, nameof(connection));
 414758        return new(connection.Id, NavigationConnectionOverlayOperationKind.Upsert, connection);
 59    }
 60
 61    /// <summary>Creates a source-owned connection tombstone.</summary>
 62    public static NavigationConnectionOverlayOperation Suppress(string id) =>
 1663        new(id, NavigationConnectionOverlayOperationKind.Suppress, default);
 64
 65    /// <summary>Creates an operation that restores the baked source-owned connection.</summary>
 66    public static NavigationConnectionOverlayOperation RevertToBake(string id) =>
 467        new(id, NavigationConnectionOverlayOperationKind.RevertToBake, default);
 68
 69}