XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing
4.1.21
dotnet add package XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing --version 4.1.21
NuGet\Install-Package XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing -Version 4.1.21
<PackageReference Include="XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing" Version="4.1.21" />
<PackageVersion Include="XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing" Version="4.1.21" />
<PackageReference Include="XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing" />
paket add XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing --version 4.1.21
#r "nuget: XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing, 4.1.21"
#:package XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing@4.1.21
#addin nuget:?package=XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing&version=4.1.21
#tool nuget:?package=XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing&version=4.1.21
XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing
Test helpers for consumer applications that depend on the Portal Servers API client. Provides in-memory fakes of IServersApiClient, DTO factory methods, and DI extensions for integration tests.
Installation
dotnet add package XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing
Quick Start — Integration Tests
Replace the real client with fakes in your test DI container:
var serverId = Guid.NewGuid();
services.AddFakeServersApiClient(client =>
{
client.FakeQueryApi.AddResponse(serverId,
ServersDtoFactory.CreateQueryStatusResponse(
serverName: "Test Server",
map: "mp_crossfire",
playerCount: 12,
maxPlayers: 24));
client.FakeRconApi.AddStatusResponse(serverId,
ServersDtoFactory.CreateRconStatusResponse());
client.FakeRconApi.AddMapsResponse(serverId,
ServersDtoFactory.CreateRconMapCollection());
});
Quick Start — Unit Tests
Create and configure the fake client directly:
var fakeClient = new FakeServersApiClient();
var serverId = Guid.NewGuid();
fakeClient.FakeQueryApi.AddResponse(serverId,
ServersDtoFactory.CreateQueryStatusResponse(
serverName: "My Server",
map: "mp_crash",
playerCount: 8));
var sut = new ServerMonitor(fakeClient);
var status = await sut.GetStatus(serverId);
Assert.Equal("My Server", status?.ServerName);
Assert.Equal(8, status?.PlayerCount);
DTO Factories
ServersDtoFactory provides static factory methods with sensible defaults:
ServersDtoFactory.CreateQueryStatusResponse(serverName: "Server", map: "mp_crossfire", playerCount: 10);
ServersDtoFactory.CreateQueryPlayer(name: "Player1", score: 25);
ServersDtoFactory.CreateRconStatusResponse();
ServersDtoFactory.CreateRconPlayer(name: "Admin", ping: 30);
ServersDtoFactory.CreateRconMapCollection();
ServersDtoFactory.CreateRconMap(mapName: "mp_crash", gameType: "war");
ServersDtoFactory.CreateRconCurrentMap(mapName: "mp_crossfire");
ServersDtoFactory.CreateServerMapsCollection();
ServersDtoFactory.CreateServerMap(name: "mp_broadcast");
Configuring Error Responses
fakeClient.FakeQueryApi.AddErrorResponse(serverId,
HttpStatusCode.NotFound, "ServerNotFound", "Server does not exist");
fakeClient.FakeQueryApi.SetDefaultBehavior(DefaultBehavior.ReturnError);
Tracking Calls
The fake APIs expose operation logs to verify interactions:
Assert.Contains(serverId, fakeClient.FakeQueryApi.QueriedServerIds);
Assert.NotEmpty(fakeClient.FakeRconApi.OperationLog);
Assert.NotEmpty(fakeClient.FakeMapsApi.OperationLog);
Resetting State Between Tests
fakeClient.Reset(); // Clears all configured responses and tracked operations
License
This project is licensed under the GPL-3.0-only license.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- MX.Api.Abstractions (>= 2.3.77)
- XtremeIdiots.Portal.Integrations.Servers.Abstractions.V1 (>= 4.1.21)
- XtremeIdiots.Portal.Integrations.Servers.Api.Client.V1 (>= 4.1.21)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- MX.Api.Abstractions (>= 2.3.77)
- XtremeIdiots.Portal.Integrations.Servers.Abstractions.V1 (>= 4.1.21)
- XtremeIdiots.Portal.Integrations.Servers.Api.Client.V1 (>= 4.1.21)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.1.21 | 96 | 9/1/2026 |
| 4.1.17 | 94 | 8/30/2026 |
| 4.1.16 | 91 | 8/30/2026 |
| 4.1.14 | 184 | 8/3/2026 |
| 4.1.13 | 112 | 8/3/2026 |
| 4.1.12 | 111 | 8/2/2026 |
| 4.1.11 | 107 | 8/2/2026 |
| 4.1.9 | 129 | 7/28/2026 |
| 4.1.5 | 123 | 7/18/2026 |
| 4.1.3 | 155 | 7/8/2026 |
| 4.1.2 | 122 | 7/8/2026 |
| 4.1.1 | 127 | 7/7/2026 |
| 4.0.9 | 118 | 7/6/2026 |
| 4.0.7 | 128 | 7/2/2026 |
| 4.0.6 | 125 | 7/1/2026 |
| 4.0.5 | 121 | 7/1/2026 |
| 4.0.4 | 127 | 7/1/2026 |
| 4.0.1 | 126 | 6/30/2026 |
| 3.0.2 | 121 | 6/30/2026 |
| 3.0.1 | 130 | 6/30/2026 |