Namespace Valheim.Testing
Classes
- CompositeTerrain
Ordered fixture composition. Last matching region wins for height, biome and river facts together. This is explicit replacement, not native biome blending. Use pure terrain inputs and predicates when sharing a fixture across workers.
- GridDumpTerrain
Terrain read from an evenly spaced grid of samples, such as a CSV world dump. Nodes sit at
OriginX + i * Spacing,OriginZ + j * Spacing; the covered area is the closed rectangle from the origin to MaxX/MaxZ, so the last row and column are inside.- Height, river weight and river width: at a node, the node's value unchanged (a query within 1e-4 of a cell of a node is that node); between nodes, bilinear between the four surrounding nodes. Bilinear is an approximation of the dumped world between its samples, not a replay.
- Biome: the nearest node's label, never an average. A node owns the half-open cell from half a spacing below it to half a spacing above it on each axis, so a query exactly halfway takes the node at larger x (or z).
- Outside the covered area every query throws System.ArgumentOutOfRangeException; there is no edge clamping or extrapolation. A missing biome or river layer throws System.NotSupportedException.
Immutable after construction and safe for concurrent readers.
- LayeredDumpTerrain
Read-only composition of pinned native world dumps. Ordinary terrain facts use the finest containing grid; base height uses only the explicitly designated lattice, even where another finer grid contains the point. Equal-spacing grids may not overlap, including at an edge. Outside every containing layer, queries fail. Node values retain the CSV precision; between-node heights and river fields are bilinear approximations, while biomes use the selected grid's nearest node. Safe for concurrent readers after loading.
- PlaneTerrain
A deterministic plane with constant biome and no river: height is origin height plus x and z grades.
- StaticOverride
Sets static fields, static properties and environment variables for one test and puts back the values they had before, not a default the test assumes:
using var plain = StaticOverride.Set(() => MyMod.Meander, 0f).And(() => MyMod.Enabled, false).AndEnvironment("MYMOD_DEBUG", "1");Dispose restores in reverse order, restores every entry even when one restore throws, and does nothing the second time. If a step of the chain throws (a readonly field, say), what the chain had already set is restored before the error reaches the caller, since its using statement never ran. Keep<T>(Expression<Func<T>>) records a value without changing it, for statics the code under test changes itself. Statics and environment variables are process-wide, so tests that override them must not run in parallel with tests that read them.
- SyntheticTerrain
Deterministic pseudo-Valheim world: an island with a gaussian hill profile, a mountain ridge, and an optional river channel crossing it. Heights use the same conventions as the game (sea level 30, deep water below 28).
- TerrainBiomeMismatch
A biome that differs at one coordinate.
- TerrainImage
A rendered RGB image, row 0 at the top.
- TerrainParity
Golden parity between two terrain sources: samples both on one lattice over an area and reports where they disagree. Samples sit at
MinX + i * step,MinZ + j * stepup to and including the area's maximum, so a lattice matching a grid's spacing and origin lands on its nodes. Heights pass within an absolute tolerance in metres. Biomes, when compared, must be equal. River weights, when a tolerance is given, pass within it; river width is not compared. A source that refuses a coordinate fails the comparison with its own exception: choose an area both sources cover. Neither source is treated as correct; the names only say which value is which in the report.
- TerrainParityPoint
One compared coordinate; Difference is actual minus expected (NaN when either is not finite).
- TerrainParityReport
What Compare(ITerrain, ITerrain, TerrainArea, float, float, bool, float?, int) found. Worst lists hold the largest differences whether or not they fail.
- TerrainRegion
A declared region replacing all terrain facts within its boundary.
- TerrainRenderer
Renders an ITerrain into an RGB image for review. The image covers Area with square pixels of MetresPerPixel; +x points right and +z points up (north up). Each pixel shows the terrain sampled once at its centre. Contours are drawn over the terrain, then polylines in the order added, then points. The same inputs give the same bytes on every platform, provided the terrain itself answers the same heights. A terrain that refuses a coordinate (outside a grid, an uncaptured replay sample, a missing biome layer) fails the render; nothing is painted in its place. A picture of an input is not evidence the game agrees.
- WorldDumpManifest
One pinned ValheimCLI world-dump CSV and the facts recorded when it was captured.
WorldDump.CaptureAsyncin Valheim.Testing.Game writes it as JSON beside the CSV after checking the game's reply against the file; nobody needs to write one by hand. The CSV holds no world identity, so WorldUid, Seed and GameBuild come from the same pinned session, and Sha256 binds them to the exact file. Command and Reply are kept as evidence of how the file was made; Verify() does not interpret them, because their grammar belongs to ValheimCLI.
Structs
- RenderColor
An opaque 8-bit sRGB colour.
- TerrainArea
A closed world rectangle on the horizontal x/z plane, in metres.
Interfaces
- ITerrain
A declared terrain input. Horizontal x/z and returned height y are in metres; it does not run Valheim's generator.
Enums
- TerrainBiome
Biome labels used by declared terrain inputs; Unknown means no biome was supplied.