Path: redb/redb.Tests.Integration/Tests/Unit/RootProviderDetectionTests.cs Snapshot: redb, 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 Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Tests.Integration/Tests/Unit/RootProviderDetectionTests.cs ---- using Microsoft.Extensions.DependencyInjection; using redb.Core; namespace redb.Tests.Integration.Tests.Unit; /// /// The fact rests on: in Microsoft.Extensions.DependencyInjection the root /// scope's provider - what a service resolved from the container itself receives - is its own /// , and a child scope's provider is not. A change of the container would fail here, /// not in production. /// public class RootProviderDetectionTests { private sealed class Probe { public Probe(IServiceProvider serviceProvider) => FromRoot = RedbServiceProviders.IsRoot(serviceProvider); public bool FromRoot { get; } } [Fact] public void TheRootProvider_IsRecognised_AndAScopeIsNot() { var services = new ServiceCollection(); services.AddScoped(); using var root = services.BuildServiceProvider(); root.GetRequiredService().FromRoot.Should().BeTrue("resolved from the container itself"); using var scope = root.CreateScope(); scope.ServiceProvider.GetRequiredService().FromRoot.Should().BeFalse("resolved from a scope"); } }