logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class PrefetchPolicyCreatorTests

    EditMode tests for PrefetchPolicyCreator. Every test targets fixture asset paths under a private temp folder — the real project's own PrefetchPolicyRegistry/PrefetchPolicyProfile assets, if any, are never touched — and every test passes an explicit RegistryAssetPath so the project-wide registry search never resolves to (or is made ambiguous by) the real project's own registry asset.

    Inheritance
    object
    PrefetchPolicyCreatorTests
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.AssetPrefetcher.Tests.Editor.Builder
    Assembly: Serenity.AssetPrefetcher.Tests.Editor.dll
    Syntax
    public class PrefetchPolicyCreatorTests

    Constructors

    PrefetchPolicyCreatorTests()

    Declaration
    public PrefetchPolicyCreatorTests()

    Methods

    Create_DefaultProfileNotFirstInInput_ReordersRegistryProfilesWithDefaultFirst()

    The installer's boot wiring (UnitySerenityInstaller.InstallAssetPrefetcher) always uses the FIRST entry of the registry's Profiles array, not GetDefault() — so Create() must guarantee the 'default' profile lands first regardless of the authored row order.

    Declaration
    public void Create_DefaultProfileNotFirstInInput_ReordersRegistryProfilesWithDefaultFirst()

    Create_ExistingProfileFileRemovedBeforeSecondRun_RollsBackTheAppliedFieldMutation()

    The symmetric counterpart of Create_ExistingRegistryFileRemovedBeforeSecondRun_RollsBackTheAppliedProfileMutation(): an already-existing PROFILE asset (not the registry) has its file removed from disk between runs. The same disk-existence guard the registry branch has must also apply to profiles, and a failure there must roll back the in-memory field mutation just applied to it.

    Declaration
    public void Create_ExistingProfileFileRemovedBeforeSecondRun_RollsBackTheAppliedFieldMutation()

    Create_ExistingProfileWithEmptyIdMatchingRowByAssetName_UpdatesInPlaceInsteadOfDuplicating()

    The folder search that decides update-in-place vs create-new must also match by resolved id: before that, an empty-Id asset named after the row was not found, and the "new" asset path collided with the existing file — silently clobbering it via CreateAsset.

    Declaration
    public void Create_ExistingProfileWithEmptyIdMatchingRowByAssetName_UpdatesInPlaceInsteadOfDuplicating()

    Create_ExistingProfileWithSameIdInOutputFolder_UpdatesInPlaceInsteadOfDuplicating()

    Declaration
    public void Create_ExistingProfileWithSameIdInOutputFolder_UpdatesInPlaceInsteadOfDuplicating()

    Create_ExistingRegistryAtExplicitPath_UpdatesItInPlaceInsteadOfCreatingANewOne()

    Declaration
    public void Create_ExistingRegistryAtExplicitPath_UpdatesItInPlaceInsteadOfCreatingANewOne()

    Create_ExistingRegistryFileRemovedBeforeSecondRun_RollsBackTheAppliedProfileMutation()

    Exercises the resolve-or-edit rollback path specifically: an already-existing registry's Profiles gets its referenced profile mutated in memory, then the pre-persist disk check fails (the registry file was removed from disk after the first Create() call). The mutation must be rolled back to its pre-call values, not just reported as failed.

    Declaration
    public void Create_ExistingRegistryFileRemovedBeforeSecondRun_RollsBackTheAppliedProfileMutation()

    Create_RegisterAsAddressablesFalse_LeavesAddressablesUntouched()

    Declaration
    public void Create_RegisterAsAddressablesFalse_LeavesAddressablesUntouched()

    Create_RegisterAsAddressablesTrue_RegistersTheRegistryAndEveryProfile()

    Declaration
    public void Create_RegisterAsAddressablesTrue_RegistersTheRegistryAndEveryProfile()

    Create_RegistryFileRemovedAfterFreshProfileIsReferencedLive_StillDeletesTheFreshProfile()

    Reproduces the interception bug fixed on PrefetchPolicyCreator.RollBack's delete loop. Create assigns registryAsset.Profiles a live reference to the freshly created 'default' profile before the ALREADY-EXISTING registry's own disk-verification runs (a planted-then-deleted registry file forces that verification to fail) — mirrors PlayerInputCreatorTests.Create_Multiplayer_DefinitionFileRemovedOnFreshChain_RollsBackAllThreeFreshSubAssets's boundary shape. Without Serenity.Global.Infrastructure.Editor.Validation.References.SerenitySafeDeleteScope.Suppressed around the rollback delete loop, SerenitySafeDeleteAssetProcessor.OnWillDeleteAsset would find the still-dirty in-memory registry as a live referencer of the freshly created profile (via a live UnityEditor.SerializedObject scan, not just what is saved to disk) and refuse the delete in an open editor — silently leaving the "deleted" profile on disk. This test would have failed before that fix.

    Declaration
    public void Create_RegistryFileRemovedAfterFreshProfileIsReferencedLive_StillDeletesTheFreshProfile()

    Create_RegistryWriteFailsAfterProfilesAlreadyCreated_RollsBackEverythingIncludingAddressablesEntries()

    Exercises a genuine rollback: two profiles and their Addressables entries — plus the nested output folder chain — are actually written to disk and registered before the registry write fails, forcing a full rollback. Asserts every one of those real artifacts is gone afterward, not just that the call reported failure.

    Declaration
    public void Create_RegistryWriteFailsAfterProfilesAlreadyCreated_RollsBackEverythingIncludingAddressablesEntries()

    Create_ValidInput_CreatesRegistryAndProfileWithConfiguredValues()

    Declaration
    public void Create_ValidInput_CreatesRegistryAndProfileWithConfiguredValues()

    Preview_ExistingRegistryHasLeftoverProfileFromPreviousRun_ListsItInProfilesToUnlink()

    Declaration
    public void Preview_ExistingRegistryHasLeftoverProfileFromPreviousRun_ListsItInProfilesToUnlink()

    Preview_ExistingRegistryProfileWithEmptyIdMatchingRowByAssetName_ListsNothingToUnlink()

    Declaration
    public void Preview_ExistingRegistryProfileWithEmptyIdMatchingRowByAssetName_ListsNothingToUnlink()

    SetUp()

    Declaration
    public void SetUp()

    TearDown()

    Declaration
    public void TearDown()

    Validate_DefaultProfileNotFirstInRowOrder_WarnsAboutReordering()

    Declaration
    public void Validate_DefaultProfileNotFirstInRowOrder_WarnsAboutReordering()

    Validate_DuplicateProfileIdsDifferingOnlyByCase_ReturnsError()

    Declaration
    public void Validate_DuplicateProfileIdsDifferingOnlyByCase_ReturnsError()

    Validate_DuplicateProfileIds_ReturnsError()

    Declaration
    public void Validate_DuplicateProfileIds_ReturnsError()

    Validate_EmptyProfileList_ReturnsError()

    Declaration
    public void Validate_EmptyProfileList_ReturnsError()

    Validate_ExistingRegistryHasLeftoverProfileFromPreviousRun_WarnsAboutUnlinking()

    Re-running the wizard against an existing registry with fewer rows than before drops the leftover profile from the registry's array (its asset stays on disk, untouched). Validate/Preview must warn about this so it is never a silent surprise.

    Declaration
    public void Validate_ExistingRegistryHasLeftoverProfileFromPreviousRun_WarnsAboutUnlinking()

    Validate_ExistingRegistryProfileWithEmptyIdMatchingRowByAssetName_DoesNotWarnAboutUnlinking()

    A referenced profile whose serialized Id is empty still resolves to its asset name at runtime (PrefetchPolicyRegistry.Get matches the resolved id) — the orphan check must classify by that same resolved identity, not the raw serialized field.

    Declaration
    public void Validate_ExistingRegistryProfileWithEmptyIdMatchingRowByAssetName_DoesNotWarnAboutUnlinking()

    Validate_MaxSizeMBBelowRuntimeFloor_WarnsWithoutBlocking()

    Declaration
    public void Validate_MaxSizeMBBelowRuntimeFloor_WarnsWithoutBlocking()

    Validate_MaxSizeMBZeroOrLess_ReturnsError()

    Declaration
    public void Validate_MaxSizeMBZeroOrLess_ReturnsError()

    Validate_NoDefaultProfile_ReturnsError()

    Declaration
    public void Validate_NoDefaultProfile_ReturnsError()

    Validate_OrphanedProfileWithEmptyId_WarnsUsingItsResolvedAssetName()

    Declaration
    public void Validate_OrphanedProfileWithEmptyId_WarnsUsingItsResolvedAssetName()
    In this article
    © 2026 Serenity. All Rights Reserved