Path: redb-identity/tests/redb.Identity.Client.Tests/Setup/ServiceCollectionExtensionsTests.cs Snapshot: redb-identity, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-identity Page: https://redbase.app/src/dev-2026-12-06/redb-identity/tests/redb.Identity.Client.Tests/Setup/ServiceCollectionExtensionsTests.cs ---- using AwesomeAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using redb.Identity.Client; using redb.Identity.Client.Auth; using Xunit; namespace redb.Identity.Client.Tests.Setup; public sealed class ServiceCollectionExtensionsTests { [Fact] public void AddIdentityClient_Registers_Typed_HttpClient() { var services = new ServiceCollection(); services.AddIdentityClient(o => { o.BaseUrl = new Uri("https://identity.test/"); o.Authority = new Uri("https://identity.test/"); o.Timeout = TimeSpan.FromSeconds(7); }); // Provide a default token provider so the typed-client construction does not fail when used. services.AddSingleton(); using var sp = services.BuildServiceProvider(); var client = sp.GetRequiredService(); client.Should().BeOfType(); } [Fact] public void AddIdentityClient_Configures_BaseAddress_And_Timeout() { var services = new ServiceCollection(); services.AddIdentityClient(o => { o.BaseUrl = new Uri("https://identity.example.com/"); o.Authority = new Uri("https://identity.example.com/"); o.Timeout = TimeSpan.FromSeconds(11); }); services.AddSingleton(); using var sp = services.BuildServiceProvider(); var client = (IdentityClient)sp.GetRequiredService(); // Reach into the typed-client's HttpClient via the private field set in the ctor. var http = (HttpClient)typeof(IdentityClient) .GetField("_http", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)! .GetValue(client)!; http.BaseAddress.Should().Be(new Uri("https://identity.example.com/")); http.Timeout.Should().Be(TimeSpan.FromSeconds(11)); } [Fact] public void IdentityClientOptions_Has_Sensible_Defaults() { var opts = new IdentityClientOptions(); opts.BaseUrl.Should().Be(new Uri("https://localhost/")); opts.Timeout.Should().Be(TimeSpan.FromSeconds(30)); opts.Scopes.Should().ContainSingle().Which.Should().Be("identity:manage"); opts.ClientId.Should().BeNull(); opts.ClientSecret.Should().BeNull(); opts.ScimBaseUrl.Should().BeNull(); } private sealed class NullTokenProvider : IAccessTokenProvider { public Task GetAccessTokenAsync(CancellationToken ct = default) => Task.FromResult(null); } }