logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class RecordingAchievementService

    An IAchievementService that records what was asked of it and answers from a dictionary, so a suite can assert exactly how many writes an evaluation produced.

    Inheritance
    object
    RecordingAchievementService
    Implements
    IAchievementService
    IService
    IFoundationSettings
    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 RecordingAchievementService : IAchievementService, IService, IFoundationSettings, IDisposable
    Remarks

    The real service is exercised end to end by the example suite; this one exists for the questions that are about call counts rather than about stored state, which a real service's deduplication would hide.

    Constructors

    RecordingAchievementService(IReadOnlyDictionary<AchievementId, AchievementDefinition>)

    Creates a recording service over the given definitions.

    Declaration
    public RecordingAchievementService(IReadOnlyDictionary<AchievementId, AchievementDefinition> definitions)
    Parameters
    Type Name Description
    IReadOnlyDictionary<AchievementId, AchievementDefinition> definitions

    The achievements this service knows about.

    Properties

    BlockPlatformSync

    Makes RetryPlatformSyncAsync(CancellationToken) hang until ReleasePlatformSync(), so a test can hold a pass open and prove a second one cannot start beside it.

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

    ConditionStateCalls

    Every state SaveConditionStateAsync(AchievementId, string, CancellationToken) was called with, in call order.

    Declaration
    public List<KeyValuePair<AchievementId, string>> ConditionStateCalls { get; }
    Property Value
    Type Description
    List<KeyValuePair<AchievementId, string>>

    DisposeCallCount

    How many times Dispose() was called.

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

    FailNextWrite

    Makes the next write of every kind fault, the way an unreachable backend would.

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

    FailPlatformSync

    Makes RetryPlatformSyncAsync(CancellationToken) fault, the way a closed storefront client would.

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

    Guid

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

    Id

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

    IsLoaded

    Whether a load has run, as the real service reports it.

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

    LogService

    Declaration
    public ILogService LogService { get; set; }
    Property Value
    Type Description
    ILogService

    MaximumPoints

    The points GetMaximumPoints() answers with.

    Declaration
    public int MaximumPoints { get; set; }
    Property Value
    Type Description
    int

    ProgressCalls

    Every numerator SetProgressAsync(AchievementId, long, CancellationToken) was called with, in call order.

    Declaration
    public List<KeyValuePair<AchievementId, long>> ProgressCalls { get; }
    Property Value
    Type Description
    List<KeyValuePair<AchievementId, long>>

    RetryPlatformSyncCallCount

    How many times RetryPlatformSyncAsync(CancellationToken) was called.

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

    TotalPoints

    The points GetTotalPoints() answers with.

    Declaration
    public int TotalPoints { get; set; }
    Property Value
    Type Description
    int

    UnlockCalls

    Every achievement UnlockAsync(AchievementId, CancellationToken) was called for, in call order.

    Declaration
    public List<AchievementId> UnlockCalls { get; }
    Property Value
    Type Description
    List<AchievementId>

    Methods

    Dispose()

    Declaration
    public void Dispose()

    GetAll()

    Declaration
    public IReadOnlyList<AchievementDefinition> GetAll()
    Returns
    Type Description
    IReadOnlyList<AchievementDefinition>

    GetMaximumPoints()

    Declaration
    public int GetMaximumPoints()
    Returns
    Type Description
    int

    GetTotalPoints()

    Declaration
    public int GetTotalPoints()
    Returns
    Type Description
    int

    GetUnlocked()

    Declaration
    public IReadOnlyList<AchievementDefinition> GetUnlocked()
    Returns
    Type Description
    IReadOnlyList<AchievementDefinition>

    GetVisible()

    Everything not hidden, plus every hidden achievement already unlocked — the real rule.

    Declaration
    public IReadOnlyList<AchievementDefinition> GetVisible()
    Returns
    Type Description
    IReadOnlyList<AchievementDefinition>

    IncrementProgressAsync(AchievementId, long, CancellationToken)

    Declaration
    public Task IncrementProgressAsync(AchievementId achievement, long delta, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    AchievementId achievement
    long delta
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    IsUnlocked(AchievementId)

    Declaration
    public bool IsUnlocked(AchievementId achievement)
    Parameters
    Type Name Description
    AchievementId achievement
    Returns
    Type Description
    bool

    LoadAsync(CancellationToken)

    Declaration
    public Task LoadAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    MarkUnlocked(AchievementId)

    Marks an achievement as already unlocked, the way a loaded store would.

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

    The achievement to mark.

    MarkUnlocked(AchievementUnlockRecord)

    Marks an achievement as unlocked with a stored record, the way a loaded store would.

    Declaration
    public void MarkUnlocked(AchievementUnlockRecord record)
    Parameters
    Type Name Description
    AchievementUnlockRecord record

    The unlock record to answer with.

    ReleasePlatformSync()

    Lets a blocked RetryPlatformSyncAsync(CancellationToken) finish, so a test can drain it.

    Declaration
    public void ReleasePlatformSync()

    ResetAllAsync(CancellationToken)

    Declaration
    public Task ResetAllAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    RetryPlatformSyncAsync(CancellationToken)

    Declaration
    public Task RetryPlatformSyncAsync(CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    SaveConditionStateAsync(AchievementId, string, CancellationToken)

    Declaration
    public Task SaveConditionStateAsync(AchievementId achievement, string conditionState, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    AchievementId achievement
    string conditionState
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    SeedProgress(AchievementProgress)

    Seeds the tracked progress of an achievement, the way a loaded store would.

    Declaration
    public void SeedProgress(AchievementProgress progress)
    Parameters
    Type Name Description
    AchievementProgress progress

    The progress to answer with.

    SetProgressAsync(AchievementId, long, CancellationToken)

    Declaration
    public Task SetProgressAsync(AchievementId achievement, long current, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    AchievementId achievement
    long current
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    TryGetProgress(AchievementId, out AchievementProgress)

    Declaration
    public bool TryGetProgress(AchievementId achievement, out AchievementProgress progress)
    Parameters
    Type Name Description
    AchievementId achievement
    AchievementProgress progress
    Returns
    Type Description
    bool

    TryGetUnlockRecord(AchievementId, out AchievementUnlockRecord)

    Declaration
    public bool TryGetUnlockRecord(AchievementId achievement, out AchievementUnlockRecord record)
    Parameters
    Type Name Description
    AchievementId achievement
    AchievementUnlockRecord record
    Returns
    Type Description
    bool

    UnlockAsync(AchievementId, CancellationToken)

    Declaration
    public Task UnlockAsync(AchievementId achievement, CancellationToken cancellationToken = default)
    Parameters
    Type Name Description
    AchievementId achievement
    CancellationToken cancellationToken
    Returns
    Type Description
    Task

    Events

    Loaded

    Raised by LoadAsync(CancellationToken), as the real service raises it.

    Declaration
    public event Action Loaded
    Event Type
    Type Description
    Action

    StateReset

    Raised by ResetAllAsync(CancellationToken), as the real service raises it.

    Declaration
    public event Action StateReset
    Event Type
    Type Description
    Action

    Implements

    IAchievementService
    IService
    IFoundationSettings
    IDisposable
    In this article
    © 2026 Serenity. All Rights Reserved