added some stuff

This commit is contained in:
JogmansonReal
2026-10-16 23:43:29 -07:00
parent 55175acdf6
commit 5c047bd19c
8 changed files with 470 additions and 1 deletions
+56
View File
@@ -0,0 +1,56 @@
# ServerTests
xUnit suite for the server and for the parts of the client patch that must agree with
it. The folder is `ServerTests/` but the project file (and assembly) is
`Server.Tests.csproj` / `Server.Tests.dll`, root namespace `RadicadeServer.Tests`.
## Running
```bash
# whole suite
dotnet test ServerTests/Server.Tests.csproj
# a single feature area
dotnet test ServerTests/Server.Tests.csproj --filter FullyQualifiedName~GiftTests
# one test
dotnet test ServerTests/Server.Tests.csproj --filter DisplayName~WeeklyChallenge
```
Around 1,600 tests run in well under a minute. On the current checkout roughly
1,605 pass, 1 is skipped and a handful fail (storefront capture count, some
catalog/locker and weekly-challenge rollover tests) — treat the run output as the
source of truth rather than the README.
## How the tests are wired
- **Database providers.** Tests never touch SQL Server. They build a context through
`TestDbContextFactory`, which uses `Microsoft.EntityFrameworkCore.InMemory` where a
fast stand-in is enough and `Microsoft.EntityFrameworkCore.Sqlite` where real
relational behaviour matters.
- **Static configuration.** A lot of server behaviour is configured through static
fields on `DBConfig` (for example `DBConfig.SteamApiKey`, `DBConfig.AdminApiKey`,
`DBConfig.JwtKey`). Tests assign throwaway values such as `"unit-test-steam-api-key"`
and restore the previous value in a `finally` block.
- **Fixtures.** `Fixtures/*.json` are linked from `Server/RadicadeServer-Config/`
(`avatar.json`, `merged-avatar.json`, `equipment*.json`, `consumables.json`,
`avatar-item-lookup.json`, `2022-avatar.json`) and copied to the output directory;
`Fixtures/split-tests-20230301.json` lives in the repository itself.
- **Shared client sources.** `NameserverRedirect.cs` and `ImageSignatureRequest.cs`
from `2023Patch/RadicadeEacBypass/` are compiled into this test assembly, so the
host-redirect map and image-signature contract are asserted server-side.
- **Test doubles.** Helpers such as `TestDbContextFactory`, `SetBody`, `CreateEventAsync`
and the various request builders keep test bodies focused on the assertion.
## Adding tests
Follow the existing shape: one class per feature area, `[Fact]`/`[Theory]` per case,
names that read as a sentence about the behaviour (`AvatarUnlockCatalog_Preserves…`).
Prefer asserting the exact JSON shape the 2023 client expects over asserting internal
state, since response-shape conformance is what most of this suite protects.
## Known warnings
The build emits `xUnit1031` warnings in `RecNetShapeConformanceTests.cs` where tests
block on tasks (`.Result`/`.GetAwaiter().GetResult()`). They are pre-existing; the
inline fix is to make the test `async` and `await`.