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
AchievementServiceHarness
Assembly: Tests.dll
Syntax
public class AchievementServiceHarness
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
Fields
DefaultPlayer
The player every harness writes as unless one is passed in.
Declaration
public static readonly PlayerId DefaultPlayer
Field Value
FirstBlood
A boolean, visible, ten-point achievement.
Declaration
public static readonly AchievementId FirstBlood
Field Value
Marathon
A progressive, twenty-point achievement with a target of 100.
Declaration
public static readonly AchievementId Marathon
Field Value
Participant
A boolean achievement worth no points at all.
Declaration
public static readonly AchievementId Participant
Field Value
SecretEnding
A hidden, five-point achievement.
Declaration
public static readonly AchievementId SecretEnding
Field Value
Properties
Capturer
Declaration
public FakeAchievementScreenshotCapturer Capturer { get; }
Property Value
Dispatcher
Declaration
public RecordingEventDispatcherService Dispatcher { get; }
Property Value
FailableStore
Declaration
public FailableAchievementStore FailableStore { get; }
Property Value
Gateway
Declaration
public FakeAchievementPlatformGateway Gateway { get; }
Property Value
Identity
Declaration
public FakeAchievementPlayerIdentityProvider Identity { get; }
Property Value
Log
Declaration
public RecordingLogService Log { get; }
Property Value
Declaration
public AchievementPlatformSyncPass PlatformSync { get; }
Property Value
Score
Declaration
public RecordingScoreService Score { get; }
Property Value
ScreenshotAttachment
Declaration
public AchievementScreenshotAttachment ScreenshotAttachment { get; }
Property Value
ScreenshotStore
Declaration
public InMemoryAchievementScreenshotStore ScreenshotStore { get; }
Property Value
Service
Declaration
public AchievementService Service { get; }
Property Value
SessionGeneration
Declaration
public AchievementSessionGeneration SessionGeneration { get; }
Property Value
Settings
Declaration
public FakeAchievementSettings Settings { get; }
Property Value
Store
Declaration
public InMemoryAchievementStore Store { get; }
Property Value
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
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
Reopen()
Builds a second harness over the same store, screenshots and gateway, the way a relaunch would.
Declaration
public AchievementServiceHarness Reopen()
Returns
StandardDefinitions()
The four achievements every suite shares: boolean, progressive, hidden and zero-point.
Declaration
public static IReadOnlyDictionary<AchievementId, AchievementDefinition> StandardDefinitions()
Returns
WithScreenshotCapture()
Turns the screenshot capture on, the way a project that wants unlock frames does.
Declaration
public AchievementServiceHarness WithScreenshotCapture()
Returns