2.7 KiB
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
# 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 usesMicrosoft.EntityFrameworkCore.InMemorywhere a fast stand-in is enough andMicrosoft.EntityFrameworkCore.Sqlitewhere real relational behaviour matters. - Static configuration. A lot of server behaviour is configured through static
fields on
DBConfig(for exampleDBConfig.SteamApiKey,DBConfig.AdminApiKey,DBConfig.JwtKey). Tests assign throwaway values such as"unit-test-steam-api-key"and restore the previous value in afinallyblock. - Fixtures.
Fixtures/*.jsonare linked fromServer/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.jsonlives in the repository itself. - Shared client sources.
NameserverRedirect.csandImageSignatureRequest.csfrom2023Patch/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,CreateEventAsyncand 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.