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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing" Version="4.1.21" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing" Version="4.1.21" />
                    
Directory.Packages.props
<PackageReference Include="XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
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"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing@4.1.21
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing&version=4.1.21
                    
Install as a Cake Addin
#tool nuget:?package=XtremeIdiots.Portal.Integrations.Servers.Api.Client.Testing&version=4.1.21
                    
Install as a Cake Tool

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed