Table of Contents

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.

TerrainAssertException
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, ObjectDB and Jotunn's NetworkManager; 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 generator Random.InitState installed, not its position in its sequence) plus the server and dedicated flags of the ZNet it 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 existing ZNet, a ZDO to the existing ZDOMan) 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 objects EndOfFrame destroys and within a destroyed hierarchy; and FindObjectsByType with FindObjectsSortMode.None (so FindAnyObjectByType). What Unity does promise is kept in both: one behaviour's own sequence (Awake, OnEnable, Start, Update, ...), a behaviour waking at once in AddComponent on an active object, every behaviour finishing a frame phase before the next phase, and FindObjectsSortMode.InstanceID. Unity's script execution order (DefaultExecutionOrder, the project settings) is not modelled.