Class SettingsAssetResolutionTests
EditMode tests for SettingsAssetResolution: both the by-Id-in-folder resolve-or-create every multi-asset creation engine shares, and the by-path resolve-or-create every single project-wide settings wizard shares. Built on real assets on disk, because the contract is about what the AssetDatabase resolves and what actually lands on disk — neither survives an in-memory double.
Every test drives a real Serenity.Global.Infrastructure.Editor.SerenityAssetCreationTransaction and rolls it back in teardown, so nothing is ever registered with the project's Addressables settings.
Inherited Members
Namespace: Serenity.StructuredPersistence.Tests.Editor
Assembly: Serenity.StructuredPersistence.Tests.Editor.dll
Syntax
public class SettingsAssetResolutionTests
Constructors
SettingsAssetResolutionTests()
Declaration
public SettingsAssetResolutionTests()
Methods
OneTimeSetUp()
Declaration
public void OneTimeSetUp()
OneTimeTearDown()
Declaration
public void OneTimeTearDown()
PlannedAssetPath_ExplicitEmpty_ComposesFromFallbackFolderAndFileName()
Declaration
public void PlannedAssetPath_ExplicitEmpty_ComposesFromFallbackFolderAndFileName()
PlannedAssetPath_ExplicitGiven_WinsOverFallback()
Declaration
public void PlannedAssetPath_ExplicitGiven_WinsOverFallback()
PlannedByIdPath_BlankId_UsesTheFallbackName()
Declaration
public void PlannedByIdPath_BlankId_UsesTheFallbackName()
ResolveOrCreateAtPath_ExistingResolution_ReturnsItAndCreatesNoFallbackFolder()
Declaration
public void ResolveOrCreateAtPath_ExistingResolution_ReturnsItAndCreatesNoFallbackFolder()
ResolveOrCreateAtPath_ExplicitPathGiven_WinsOverFallback()
Declaration
public void ResolveOrCreateAtPath_ExplicitPathGiven_WinsOverFallback()
ResolveOrCreateAtPath_FallbackFolderAlreadyExists_TracksNoFolderToRollBack()
Declaration
public void ResolveOrCreateAtPath_FallbackFolderAlreadyExists_TracksNoFolderToRollBack()
ResolveOrCreateAtPath_NoResolutionAndMissingFallbackFolder_CreatesAssetAndFolder()
Declaration
public void ResolveOrCreateAtPath_NoResolutionAndMissingFallbackFolder_CreatesAssetAndFolder()
ResolveOrCreateAtPath_RollbackAfterCreate_RemovesBothTheAssetAndTheCreatedFolder()
Declaration
public void ResolveOrCreateAtPath_RollbackAfterCreate_RemovesBothTheAssetAndTheCreatedFolder()
ResolveOrCreateByIdInFolder_BlankId_UsesTheFallbackName()
Declaration
public void ResolveOrCreateByIdInFolder_BlankId_UsesTheFallbackName()
ResolveOrCreateByIdInFolder_CaseVariantIdAtThePlannedPath_ThrowsInsteadOfTreatingItAsAMatch()
The collision check must compare Ids ordinally, not case-insensitively — a colliding asset whose Id differs from the requested one ONLY by case is a DIFFERENT entity (Serenity Ids are case-sensitive throughout, see the case-variant resolve test above) and must still be refused, never silently treated as a match.
Declaration
public void ResolveOrCreateByIdInFolder_CaseVariantIdAtThePlannedPath_ThrowsInsteadOfTreatingItAsAMatch()
ResolveOrCreateByIdInFolder_DifferentAssetAlreadyAtThePlannedPath_ThrowsAndLeavesItUntouched()
An asset already sits at the file path "beta" sanitizes to, but under a DIFFERENT Id (an adopted asset that kept its original file name while gaining an Id suffix). ResolveOrCreateByIdInFolder<TSettings>(string, string, string, SerenityAssetCreationTransaction, out bool) must refuse the create, leaving the colliding asset's Guid and every field untouched.
Declaration
public void ResolveOrCreateByIdInFolder_DifferentAssetAlreadyAtThePlannedPath_ThrowsAndLeavesItUntouched()
ResolveOrCreateByIdInFolder_DifferentAssetTypeAtThePlannedPath_ThrowsAndLeavesItUntouched()
The generic UnityEditor.AssetDatabase.LoadAssetAtPath``1(System.String) returns null on a type mismatch — so a completely different asset type sitting at the exact planned path is indistinguishable from nothing being there at all unless probed untyped. It must be refused exactly like a same-type collision.
Declaration
public void ResolveOrCreateByIdInFolder_DifferentAssetTypeAtThePlannedPath_ThrowsAndLeavesItUntouched()
ResolveOrCreateByIdInFolder_ExactMatchInASubfolder_ResolvesItBecauseTheScanRecurses()
Declaration
public void ResolveOrCreateByIdInFolder_ExactMatchInASubfolder_ResolvesItBecauseTheScanRecurses()
ResolveOrCreateByIdInFolder_ExactMatchInFolder_ReturnsItAndCreatesNothing()
Declaration
public void ResolveOrCreateByIdInFolder_ExactMatchInFolder_ReturnsItAndCreatesNothing()
ResolveOrCreateByIdInFolder_ExistingAssetAtADifferentFileName_CreatesNormally()
An asset at a DIFFERENT file name entirely (not merely a different Id) never collides, even when it is the sole existing asset in the folder — the guard is about the exact write path, not "does anything of this type already exist here".
Declaration
public void ResolveOrCreateByIdInFolder_ExistingAssetAtADifferentFileName_CreatesNormally()
ResolveOrCreateByIdInFolder_FolderAlreadyExists_TracksNoFolderToRollBack()
The always-ensure decision rests on this: a folder Unity already reports as valid costs a cache check and nothing else — no AssetDatabase write, and nothing recorded for rollback. Were that untrue, callers that ensure their own folder beforehand would accumulate phantom rollback entries.
Declaration
public void ResolveOrCreateByIdInFolder_FolderAlreadyExists_TracksNoFolderToRollBack()
ResolveOrCreateByIdInFolder_FolderDoesNotExistYet_CreatesItAndTracksItForRollback()
Declaration
public void ResolveOrCreateByIdInFolder_FolderDoesNotExistYet_CreatesItAndTracksItForRollback()
ResolveOrCreateByIdInFolder_IdOfIllegalCharacters_SanitizesThemInsteadOfFallingBack()
NamingSanitizer.FileNameSafe falls back only when sanitizing leaves NOTHING — illegal
characters become underscores, which is a usable file name. So an Id of pure punctuation keeps its
own (sanitized) name rather than taking the fallback.
Declaration
public void ResolveOrCreateByIdInFolder_IdOfIllegalCharacters_SanitizesThemInsteadOfFallingBack()
ResolveOrCreateByIdInFolder_NothingThere_AssignsAFreshGuid()
Declaration
public void ResolveOrCreateByIdInFolder_NothingThere_AssignsAFreshGuid()
ResolveOrCreateByIdInFolder_NothingThere_CreatesAtThePathTheIdSanitizesTo()
Declaration
public void ResolveOrCreateByIdInFolder_NothingThere_CreatesAtThePathTheIdSanitizesTo()
ResolveOrCreateByIdInFolder_NothingThere_TracksThePathSoTheRunCanRollBack()
Declaration
public void ResolveOrCreateByIdInFolder_NothingThere_TracksThePathSoTheRunCanRollBack()
ResolveOrCreateByIdInFolder_OnlyACaseVariantInFolder_CreatesANewAssetBecauseIdsAreCaseSensitive()
Declaration
public void ResolveOrCreateByIdInFolder_OnlyACaseVariantInFolder_CreatesANewAssetBecauseIdsAreCaseSensitive()
ResolveOrCreateByIdInFolder_SameTypeSameIdAlreadyAtThePlannedPath_ResolvesItInsteadOfRefusing()
Proves the same-type/same-Id-at-the-planned-path classification directly against a real on-disk asset, once it is fully visible to the AssetDatabase (forcing the by-Id search index's own lag via UnityEditor.AssetDatabase.StartAssetEditing/UnityEditor.AssetDatabase.StopAssetEditing does not reproduce reliably in this harness — both the index AND a direct path load stay blind to the asset until the batch closes). The classification rule itself: an asset already at the exact planned path is treated as a collision only when it differs by type or Id — same type + same Id resolves it instead of refusing, exercised here once the asset is fully visible to the AssetDatabase.
Declaration
public void ResolveOrCreateByIdInFolder_SameTypeSameIdAlreadyAtThePlannedPath_ResolvesItInsteadOfRefusing()
SetUp()
Declaration
public void SetUp()
TearDown()
Declaration
public void TearDown()