logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class FakeAchievementPlatformGateway

    Scriptable IAchievementPlatformGateway used for tests: an in-memory unlocked set, a switchable availability flag, and a one-shot failure so the offline-retry and never-throw paths can be exercised without a real storefront SDK.

    Inheritance
    object
    FakeAchievementPlatformGateway
    Implements
    IAchievementPlatformGateway
    IDisposable
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Achievements.Tests.Fakes
    Assembly: Tests.dll
    Syntax
    public class FakeAchievementPlatformGateway : IAchievementPlatformGateway, IDisposable
    Remarks

    Also IDisposable, the way SteamAchievementGateway is: a test that proves CompositeAchievementPlatformGateway.Dispose reaches its children needs a child that can report it was asked to release something.

    Constructors

    FakeAchievementPlatformGateway()

    Declaration
    public FakeAchievementPlatformGateway()

    Properties

    AcceptedProgressReports

    The progress reports the gateway accepted, in call order.

    Declaration
    public List<string> AcceptedProgressReports { get; }
    Property Value
    Type Description
    List<string>

    AcceptedUnlockCount

    How many unlock pushes the gateway accepted.

    Declaration
    public int AcceptedUnlockCount { get; }
    Property Value
    Type Description
    int

    Available

    Whether the gateway reports itself reachable.

    Declaration
    public bool Available { get; set; }
    Property Value
    Type Description
    bool

    ClearCallCount

    How many times ClearAsync(CancellationToken) has been called.

    Declaration
    public int ClearCallCount { get; }
    Property Value
    Type Description
    int

    DisposeCallCount

    How many times Dispose() has been called.

    Declaration
    public int DisposeCallCount { get; }
    Property Value
    Type Description
    int

    FailNextCall

    When set, the next call fails: it returns false, or throws when ThrowOnFailure is on.

    Declaration
    public bool FailNextCall { get; set; }
    Property Value
    Type Description
    bool

    FailQueryUnlockedCalls

    When set, only QueryUnlockedAsync(CancellationToken) fails, and it fails every time. Lets a test reach the "the account could not be read" branch without also failing the initialize that runs before it.

    Declaration
    public bool FailQueryUnlockedCalls { get; set; }
    Property Value
    Type Description
    bool

    HangOnEveryCall

    When set, every call never returns until its token is cancelled — the shape of a storefront SDK that has stopped answering, which is what the call timeout exists for.

    Declaration
    public bool HangOnEveryCall { get; set; }
    Property Value
    Type Description
    bool

    IsAvailable

    Declaration
    public bool IsAvailable { get; }
    Property Value
    Type Description
    bool

    Name

    The name reported as PlatformName.

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    string

    PlatformName

    Declaration
    public string PlatformName { get; }
    Property Value
    Type Description
    string

    ThrowOnDispose

    When set, Dispose() throws instead of recording the call.

    Declaration
    public bool ThrowOnDispose { get; set; }
    Property Value
    Type Description
    bool

    ThrowOnFailure

    Whether a failing call throws instead of returning false.

    Declaration
    public bool ThrowOnFailure { get; set; }
    Property Value
    Type Description
    bool

    Methods

    ClearAsync(CancellationToken)

    Declaration
    public Task<bool> ClearAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>

    Dispose()

    Declaration
    public void Dispose()

    HasUnlocked(AchievementId)

    Whether the platform account carries an achievement.

    Declaration
    public bool HasUnlocked(AchievementId achievement)
    Parameters
    Type Name Description
    AchievementId achievement

    The achievement to test.

    Returns
    Type Description
    bool

    InitializeAsync(CancellationToken)

    Declaration
    public Task<bool> InitializeAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>

    QueryUnlockedAsync(CancellationToken)

    Declaration
    public Task<PlatformUnlockQueryResult> QueryUnlockedAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<PlatformUnlockQueryResult>
    Remarks

    A fake stands in for a real storefront, never for NullAchievementPlatformGateway or an inert template, so it never fabricates Answered(empty) out of a failure: every path that cannot vouch for the account — the one-shot failure, unavailability, a timeout — answers Unreachable() instead.

    SeedUnlocked(AchievementId)

    Seeds the platform account with an achievement the local store may not know about.

    Declaration
    public void SeedUnlocked(AchievementId achievement)
    Parameters
    Type Name Description
    AchievementId achievement

    The achievement the platform already carries.

    SetProgressAsync(AchievementDefinition, long, long, CancellationToken)

    Declaration
    public Task<bool> SetProgressAsync(AchievementDefinition definition, long current, long target, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    AchievementDefinition definition
    long current
    long target
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>

    UnlockAsync(AchievementDefinition, CancellationToken)

    Declaration
    public Task<bool> UnlockAsync(AchievementDefinition definition, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    AchievementDefinition definition
    CancellationToken cancellationToken
    Returns
    Type Description
    Task<bool>

    Implements

    IAchievementPlatformGateway
    IDisposable
    In this article
    © 2026 Serenity. All Rights Reserved