Namespace Valheim.Testing.Game.Fakes
Classes
- FakeClientDataDirectory
For no-game tests only: within this scope (the current async flow), a simulated game client keeps its data in Directory, so DefaultSaveDirectory(ClientPlatform) returns it on every platform. A hosted-world test can then place its fixture in a temporary folder while every rule about the client's data directory still runs, including the macOS rule that refuses any other SaveDirectory. A real macOS client always uses the signed-in user's own directory (Valheim 1.0.16 ignores
-savedirthere); never use this scope in a run with a game. This scope is the only way to change the default: there is no environment variable, setter or plan field. Scopes nest: disposing one restores the one it was opened in. Dispose the innermost first; disposing an outer scope while an inner one is open throws and changes nothing, so a stale directory never stays in effect.
- FakeDataRoot
For no-game tests only: within this scope (the current async flow), ValheimTesting's own folder on this machine is Directory instead of
%LOCALAPPDATA%\ValheimTesting(macOS~/Library/Application Support/ValheimTesting, Linux$XDG_DATA_HOME/ValheimTesting). The run journal that records every copy this process makes (Copy(string, string, IReadOnlyDictionary<string, string>), a run's runtime copies), the default host lock, leases and runs, and DataRoot all move with it, so a test that copies a fixture never adds a run to the machine'svalheim-test env status, and a test killed mid-run never leaves one that makesenv preflightrefuse real runs. A copy keeps journalling where it was made, whichever flow retires it. Never use this scope in a run with a game: the machine's tools would not see that run. This scope is the only way to change the folder: there is no environment variable, setter or plan field. Scopes nest: disposing one restores the one it was opened in. Dispose the innermost first; disposing an outer scope while an inner one is open throws and changes nothing.
- FakeOwnedProcess
The toolkit's one fake IOwnedProcess, for an owned server or client: exits when the test says so (Exit(int)) or when stopped. Launched by a FakeOwnedServer, it records its stops there and follows that server's switches. Created on its own, for example as the client process of
ClientSession.Launch, its own IgnoreQuit and StopFailure decide how a stop ends.
- FakeOwnedServer
A scripted owned dedicated server for testing startup, readiness, identity, restart and teardown logic without a game. Launch(string) starts a FakeOwnedProcess; Connect() returns a transport that answers the session capability (token, PID, save root, complete, dedicated) and the strict pins like a server with a session adapter. Switches make each failure happen; gates hold a step open until the test releases it. Events records launch/probe/pins/stop/dispose/disconnect with the boot number, in order.
- ScriptedAccess
A scripted client's test access (ClientAccess(Func<bool>, Func<bool>?, bool)).
- ScriptedTransport
A ValheimCLI transport that answers from a script, for testing scenarios without a game. Built in: strict pins (
cli_expect, holding unless PinsHold is false), the extension listing (cli_extensions) of the extensions registered with Extension(string, string, Func<IReadOnlyList<string>, object>, bool, int, string), their commands, and confirmed saves (Saves(bool)). Commands registered with On(string, Func<string, CommandResult>) or OnPrefix(string, Func<string, CommandResult>) are answered first. Anything unscripted throws, so a scenario cannot silently issue a command its test did not expect. Commands records every command.
- TempRuntime
A temporary runtime directory with a BepInEx log, for startup-event tests. Deleted on dispose.