logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class AchievementServiceHarness

    Assembles an AchievementService over the module's fakes and exposes every one of them, so a test states only the switch it cares about. Settings are read live by the service and its collaborators, so a test may flip one after the harness is built.

    Inheritance
    object
    AchievementServiceHarness
    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 AchievementServiceHarness
    Remarks

    Shared by the service, concurrency, degradation and action suites: they all need the same eight-collaborator graph, and letting each build its own is how the graph drifts apart.

    Constructors

    AchievementServiceHarness(InMemoryAchievementStore, InMemoryAchievementScreenshotStore, FakeAchievementPlatformGateway, PlayerId?, IReadOnlyDictionary<AchievementId, AchievementDefinition>)

    Builds a harness with the standard definitions and a fresh store, gateway and capturer.

    Declaration
    public AchievementServiceHarness(InMemoryAchievementStore store = null, InMemoryAchievementScreenshotStore screenshotStore = null, FakeAchievementPlatformGateway gateway = null, PlayerId? player = null, IReadOnlyDictionary<AchievementId, AchievementDefinition> definitions = null)
    Parameters
    Type Name Description
    InMemoryAchievementStore store

    The in-memory store to reuse, or null for a fresh one.

    InMemoryAchievementScreenshotStore screenshotStore

    The screenshot store to reuse, or null for a fresh one.

    FakeAchievementPlatformGateway gateway

    The platform gateway to reuse, or null for a fresh one.

    PlayerId? player

    The player to write as, or null for DefaultPlayer.

    IReadOnlyDictionary<AchievementId, AchievementDefinition> definitions

    The achievements to register, or null for the standard four.

    Fields

    DefaultPlayer

    The player every harness writes as unless one is passed in.

    Declaration
    public static readonly PlayerId DefaultPlayer
    Field Value
    Type Description
    PlayerId

    FirstBlood

    A boolean, visible, ten-point achievement.

    Declaration
    public static readonly AchievementId FirstBlood
    Field Value
    Type Description
    AchievementId

    Marathon

    A progressive, twenty-point achievement with a target of 100.

    Declaration
    public static readonly AchievementId Marathon
    Field Value
    Type Description
    AchievementId

    Participant

    A boolean achievement worth no points at all.

    Declaration
    public static readonly AchievementId Participant
    Field Value
    Type Description
    AchievementId

    SecretEnding

    A hidden, five-point achievement.

    Declaration
    public static readonly AchievementId SecretEnding
    Field Value
    Type Description
    AchievementId

    Properties

    Capturer

    Declaration
    public FakeAchievementScreenshotCapturer Capturer { get; }
    Property Value
    Type Description
    FakeAchievementScreenshotCapturer

    Dispatcher

    Declaration
    public RecordingEventDispatcherService Dispatcher { get; }
    Property Value
    Type Description
    RecordingEventDispatcherService

    FailableStore

    Declaration
    public FailableAchievementStore FailableStore { get; }
    Property Value
    Type Description
    FailableAchievementStore

    Gateway

    Declaration
    public FakeAchievementPlatformGateway Gateway { get; }
    Property Value
    Type Description
    FakeAchievementPlatformGateway

    Identity

    Declaration
    public FakeAchievementPlayerIdentityProvider Identity { get; }
    Property Value
    Type Description
    FakeAchievementPlayerIdentityProvider

    Log

    Declaration
    public RecordingLogService Log { get; }
    Property Value
    Type Description
    RecordingLogService

    PlatformSync

    Declaration
    public AchievementPlatformSyncPass PlatformSync { get; }
    Property Value
    Type Description
    AchievementPlatformSyncPass

    Score

    Declaration
    public RecordingScoreService Score { get; }
    Property Value
    Type Description
    RecordingScoreService

    ScreenshotAttachment

    Declaration
    public AchievementScreenshotAttachment ScreenshotAttachment { get; }
    Property Value
    Type Description
    AchievementScreenshotAttachment

    ScreenshotStore

    Declaration
    public InMemoryAchievementScreenshotStore ScreenshotStore { get; }
    Property Value
    Type Description
    InMemoryAchievementScreenshotStore

    Service

    Declaration
    public AchievementService Service { get; }
    Property Value
    Type Description
    AchievementService

    SessionGeneration

    Declaration
    public AchievementSessionGeneration SessionGeneration { get; }
    Property Value
    Type Description
    AchievementSessionGeneration

    Settings

    Declaration
    public FakeAchievementSettings Settings { get; }
    Property Value
    Type Description
    FakeAchievementSettings

    Store

    Declaration
    public InMemoryAchievementStore Store { get; }
    Property Value
    Type Description
    InMemoryAchievementStore

    Methods

    Definition(AchievementId, int, int, long, bool)

    Builds a definition with the harness's naming conventions.

    Declaration
    public static AchievementDefinition Definition(AchievementId id, int points, int displayOrder, long progressTarget = 0, bool isHidden = false)
    Parameters
    Type Name Description
    AchievementId id

    The achievement identifier.

    int points

    The points the unlock awards.

    int displayOrder

    The listing order.

    long progressTarget

    The progress target; zero makes the achievement boolean.

    bool isHidden

    Whether the achievement stays concealed until unlocked.

    Returns
    Type Description
    AchievementDefinition

    DrainDetachedWork(Func<bool>)

    Hands the scheduler enough turns for detached work to finish. The screenshot capture is deliberately not awaited by the unlock, so a test has to wait for it before asserting.

    Declaration
    public Task DrainDetachedWork(Func<bool> until = null)
    Parameters
    Type Name Description
    Func<bool> until

    The condition that ends the wait early. Omit it to drain for the full budget, which is what a test asserting that NOTHING happened has to do.

    Returns
    Type Description
    Task

    Reopen()

    Builds a second harness over the same store, screenshots and gateway, the way a relaunch would.

    Declaration
    public AchievementServiceHarness Reopen()
    Returns
    Type Description
    AchievementServiceHarness

    StandardDefinitions()

    The four achievements every suite shares: boolean, progressive, hidden and zero-point.

    Declaration
    public static IReadOnlyDictionary<AchievementId, AchievementDefinition> StandardDefinitions()
    Returns
    Type Description
    IReadOnlyDictionary<AchievementId, AchievementDefinition>

    WithScreenshotCapture()

    Turns the screenshot capture on, the way a project that wants unlock frames does.

    Declaration
    public AchievementServiceHarness WithScreenshotCapture()
    Returns
    Type Description
    AchievementServiceHarness
    In this article
    © 2026 Serenity. All Rights Reserved