Namespace Valheim.Testing.Doubles
Classes
- DoubledGame
The game build the doubles copy, which both game captures in the doubles' tests must come from: the ZPackage bytes record Version, the member list NetworkVersion. Change them only with the game pin, and recapture both.
- TerrainAssert
Assertions over terrain compiler doubles. Each throws TerrainAssertException naming the first offending vertices.
- TerrainSnapshot
A copy of one zone compiler's per-vertex state: level and smooth deltas, the modified-height flags, the paint mask (RGBA) and the modified-paint flags. Compare it with the compiler after a write to see exactly which vertices the write touched, including a flag set without a value change.
- TerrainWorld
A WorldGenerator over the toolkit's composable terrain (ITerrain).
- TestOnlyAttribute
Marks a doubles type or member the game does not have: a test switch, a recorder or a fixture shorthand. Mod code that calls one compiles against the doubles and fails against the game. The doubles' tests refuse an unmarked member the game lacks and a marked one it has (docs/packages/Valheim.Testing.Doubles.members.txt lists both).
- ValheimWorldScope
The game's process-wide state for one test. Created, it records every static the doubles keep (the singletons such as
WorldGenerator,ZDOMan,ZoneSystem,ZNetScene,ZNet,ZRoutedRpc,ObjectDBand Jotunn'sNetworkManager; the loaded heightmaps, terrain modifiers, Unity objects and pending destroys; the log capture, console commands, cheat gates, local player and player list; the registries' hooks, localization, input, preferences, config disk, heightmap builder, clock and the random generatorRandom.InitStateinstalled, not its position in its sequence) plus the server and dedicated flags of theZNetit found; disposed, it ends the test's frame (UnityEngine.Object.EndOfFrame) and restores the statics through StaticOverride in reverse order, each even when another fails. A second Dispose does nothing. It restores references, except the game's three static readonly lists of heightmaps, terrain modifiers and players, whose contents are restored in place. Other objects are not deep-copied, so a test that mutates one it did not install (adds a peer to the existingZNet, a ZDO to the existingZDOMan) leaves that change behind. Use the builder methods to install fresh, isolated objects instead (WithZdos(), WithScene(), WithNetwork(bool), WithCommands(), ...). A mod's own statics are the mod's to scope, with StaticOverride. The doubles are process-wide like the game's, so tests using them must not run in parallel (disable xUnit parallelization for the assembly).
Structs
- TerrainChange
One terrain vertex whose compiler state differs from a snapshot: its index, world position and what changed.
Enums
- UnityOrder
Where Unity promises no order, which order the doubles use (WithUnityOrder(UnityOrder)): Awake, OnEnable and OnDisable across the objects of a hierarchy that is activated, deactivated or instantiated; each phase of
Object.RunFrame(Start, Update, coroutines and Invoke, LateUpdate, end-of-frame coroutines) across behaviours; OnDestroy across the objectsEndOfFramedestroys and within a destroyed hierarchy; andFindObjectsByTypewithFindObjectsSortMode.None(soFindAnyObjectByType). What Unity does promise is kept in both: one behaviour's own sequence (Awake, OnEnable, Start, Update, ...), a behaviour waking at once inAddComponenton an active object, every behaviour finishing a frame phase before the next phase, andFindObjectsSortMode.InstanceID. Unity's script execution order (DefaultExecutionOrder, the project settings) is not modelled.