MX.GeoLocation.Api.Client.Testing 1.2.18

dotnet add package MX.GeoLocation.Api.Client.Testing --version 1.2.18
                    
NuGet\Install-Package MX.GeoLocation.Api.Client.Testing -Version 1.2.18
                    
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="MX.GeoLocation.Api.Client.Testing" Version="1.2.18" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MX.GeoLocation.Api.Client.Testing" Version="1.2.18" />
                    
Directory.Packages.props
<PackageReference Include="MX.GeoLocation.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 MX.GeoLocation.Api.Client.Testing --version 1.2.18
                    
#r "nuget: MX.GeoLocation.Api.Client.Testing, 1.2.18"
                    
#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 MX.GeoLocation.Api.Client.Testing@1.2.18
                    
#: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=MX.GeoLocation.Api.Client.Testing&version=1.2.18
                    
Install as a Cake Addin
#tool nuget:?package=MX.GeoLocation.Api.Client.Testing&version=1.2.18
                    
Install as a Cake Tool

MX.GeoLocation.Api.Client.Testing

Test helpers for consumer applications that depend on the GeoLocation API client. Provides in-memory fakes of IGeoLocationApiClient, DTO factory methods, and DI extensions for integration tests.

Installation

dotnet add package MX.GeoLocation.Api.Client.Testing

Quick Start — Integration Tests

Replace the real client with fakes in your test DI container:

services.AddFakeGeoLocationApiClient(client =>
{
    client.V1Lookup.AddResponse("8.8.8.8",
        GeoLocationDtoFactory.CreateGeoLocation(
            address: "8.8.8.8",
            cityName: "Mountain View",
            countryName: "United States"));
});

Quick Start — Unit Tests

Create and configure the fake client directly:

var fakeClient = new FakeGeoLocationApiClient();

fakeClient.V1Lookup.AddResponse("1.1.1.1",
    GeoLocationDtoFactory.CreateGeoLocation(cityName: "San Francisco"));

fakeClient.V1_1Lookup.AddCityResponse("1.1.1.1",
    GeoLocationDtoFactory.CreateCityGeoLocation(cityName: "San Francisco"));

var sut = new MyService(fakeClient);
var result = await sut.LookupAddress("1.1.1.1");

Assert.Equal("San Francisco", result?.CityName);

DTO Factories

GeoLocationDtoFactory provides static factory methods with sensible defaults:

GeoLocationDtoFactory.CreateGeoLocation(address: "10.0.0.1", cityName: "London");
GeoLocationDtoFactory.CreateCityGeoLocation(countryName: "UK");
GeoLocationDtoFactory.CreateInsightsGeoLocation(cityName: "Berlin");
GeoLocationDtoFactory.CreateNetworkTraits(isp: "Cloudflare");
GeoLocationDtoFactory.CreateAnonymizer(isAnonymousVpn: true);
GeoLocationDtoFactory.CreateApiInfo(version: "1.0.0");

Configuring Error Responses

fakeClient.V1Lookup.AddErrorResponse("invalid-host",
    HttpStatusCode.NotFound, "NotFound", "Address not found");

fakeClient.V1Lookup.SetDefaultBehavior(DefaultLookupBehavior.ReturnError);

Tracking Calls

The fake APIs expose read-only collections to verify interactions:

Assert.Contains("8.8.8.8", fakeClient.V1Lookup.LookedUpAddresses);
Assert.Contains("old-record", fakeClient.V1Lookup.DeletedAddresses);
Assert.Contains("1.1.1.1", fakeClient.V1_1Lookup.CityLookedUpAddresses);

Resetting State Between Tests

fakeClient.Reset(); // Clears all configured responses and tracked calls

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
1.2.18 0 3/7/2026
1.2.16 73 3/2/2026
1.2.4 90 2/21/2026
1.2.2 91 2/20/2026
1.2.1 84 2/19/2026
1.0.28 84 2/19/2026
1.0.27 82 2/19/2026