logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Namespace Serenity.Tests.Shared.Fakes

    Classes

    ClonerPrefabReferrerTestSettings

    A settings asset that names a prefab component by Id and by Guid — the "something else references the prefab's identity" side of the Clone Directory prefab tests. Lives in its own same-named file so Unity can bind its script when a test creates it as a real asset.

    ClonerPrefabTestComponent

    Identity-carrying IFoundationSettings UnityEngine.MonoBehaviour fixture for the Clone Directory tests that copy prefabs: it declares the references a prefab component can hold — to a settings asset and to another component, by Id and by Guid — plus one reference to something outside the cloned folder, a string that is no reference, and a plain field a nested prefab instance can override. Lives in the runtime Tests assembly because Unity refuses AddComponent for a type defined in an editor script assembly.

    FakeAtomicFileWriterService

    No-op IAtomicFileWriterService implementation for testing.

    FakeBlobStore

    No-op IBlobStore implementation for testing.

    FakeEventDispatcherService

    No-op IEventDispatcherService implementation for testing.

    FakeFileSystemService

    No-op IFileSystemService implementation for testing.

    FakeGameSettingsDefinition

    Minimal IGameSettingsDefinition so a real GameSettingsEntity can be constructed — the entity has no parameterless constructor.

    FakeGameSettingsService

    Configurable fake game-settings service: GetGameSettings(string) answers from Settings and returns null for an id nothing declared — the same "the key names no setting" answer the real UnityGameSettingsService gives. Only the members a service under test calls carry behaviour; the rest satisfy the interface.

    FakeLogService

    No-op ILogService implementation for testing.

    FakeLogSettings

    No-op ILogSettings implementation for testing.

    GatedKeyValueStore

    In-memory IKeyValueStore whose FIRST GetAsync call captures the current value and then suspends until the test calls ReleaseFirstReadGate() — returning the value it captured BEFORE suspending. This lets a test hold one read-modify-write cycle open on its stale snapshot while issuing a second concurrent operation, proving (or disproving) lost-update protection in the store under test.

    InMemoryBlobStore

    In-memory IBlobStore implementation for testing.

    InMemoryKeyValueStore

    In-memory IKeyValueStore implementation for testing.

    InMemoryStructuredStore

    In-memory IStructuredStore used for tests. Delegates every filter/sort/distinct/ trim computation to StructuredQueryEngine — the same engine every real backend delegates to — so this fake exercises the exact same semantics as production stores.

    RecordingEventDispatcherService

    IEventDispatcherService implementation that both records every dispatched signal for assertions and delivers it to subscribers, so a test can assert on what a service broadcast and drive an EventDispatcherAction through the same instance.

    RecordingLogService

    ILogService implementation that records every message it is given, for assertions.

    RecordingScoreService

    IScoreService implementation backed by an in-memory dictionary, recording how often each mutation was called so a test can assert both the resulting value and the fact that the service was (or was not) touched at all.

    RecordingViewBase

    Plain IViewBase that records show/hide calls, for router/browser tests.

    RecordingViewBrowserService

    Real-shaped IViewBrowserService over a plain list, so tests can push, pop and inspect the navigation history without a MonoBehaviour.

    ScratchAssetFixture

    One scratch-asset fixture for EditMode tests that create real assets under a throwaway folder and must leave nothing behind: a folder to create assets in, a GUID ledger for the Addressables entries those assets may pick up, and a delete pass that removes both. Replaces the ~60-line "scratch settings asset" fixture ten test suites used to hand-roll on their own — UnitySingletonSettingsLoaderTests, UnityCollectionSettingsLoaderTests, WiredOrDiscoveredSettingsTests, SystemAdoptionRunnerTests, ProjectWiringPinResolutionTests, AdoptedReferenceRemapperTests, AdoptedReferenceEndToEndTests, SerenityAdoptedReferenceValidatorTests, FoundationReferenceIndexTests and SerenityPackageContentRelocatorTests.

    A test owns one instance per [SetUp]/[TearDown] pair, constructed with every scratch folder the test will use (so a crashed previous run's leftovers are still reachable before this test creates anything), and disposes it in [TearDown]:

    private ScratchAssetFixture _fixture;
    
    [SetUp]
    public void SetUp()
    {
        _fixture = new ScratchAssetFixture(PackageScratchFolder, ProjectScratchFolder);
        _fixture.DeleteScratchFolders();
    }
    
    [TearDown]
    public void TearDown() => _fixture.Dispose();

    UnityAddressablesLabeler.RetagAssets is internal to the Global editor assembly and only Tests.Editor carries an InternalsVisibleTo grant for it, not this fixture's own Tests assembly — so retagging a created asset as Addressable stays one call at the test's own call site, right after CreateSettingsAsset<TSettings>(string, string, string, string) or SaveAsset(Object, string, string, string) returns its path.

    ScratchAssetFixtureTestSettings

    A throwaway IFoundationSettings asset type for ScratchAssetFixture's own tests. Lives in its own same-named file so Unity can bind its script when a test creates it as an asset (mirrors UnitySingletonSettingsLoaderTestSettings).

    SystemAdoptionTestIdentityComponent

    Identity-carrying IFoundationSettings UnityEngine.MonoBehaviour fixture — stands in for UnitySerenityInstaller/UnityFeedbackService/etc. so a system-adoption test can build a prefab the closure must exclude instead of cloning. Carries one object reference field so a test can assert the closure walk never follows an excluded prefab's own dependencies. Lives in the runtime Tests assembly, not an editor-only one: Unity refuses AddComponent for a type defined in an editor script assembly ("Can't add script behaviour ... because it is an editor script.").

    ThrowingBlobStore

    IBlobStore implementation whose every operation throws, for failure-path testing.

    ThrowingKeyValueStore

    IKeyValueStore implementation whose every operation throws, for failure-path testing.

    In this article
    © 2026 Serenity. All Rights Reserved