diff --git a/test/Autofac.Specification.Test/LoadContextScopeTests.cs b/test/Autofac.Specification.Test/LoadContextScopeTests.cs index 33dacac51..77ad1ba91 100644 --- a/test/Autofac.Specification.Test/LoadContextScopeTests.cs +++ b/test/Autofac.Specification.Test/LoadContextScopeTests.cs @@ -153,6 +153,38 @@ public void CanLoadInstanceOfScanAssemblyAndUnloadItAfterEnumerable() WaitForUnload(loadContextRef); } + [Fact] + public void EnumerableCanContainItemsFromParentAndLoadedScope() + { + var builder = new ContainerBuilder(); + + builder.RegisterInstance("string").As(); + + using var rootContainer = builder.Build(); + + LoadAssemblyAndTest( + rootContainer, + out var loadContextRef, + (builder, assembly) => builder.RegisterType(assembly.GetType("A.Service1")).As(), + (scope, loadContext, assembly) => + { + var resolved = scope.Resolve>(); + + Assert.Collection( + resolved, + firstItem => + { + Assert.Equal("string", firstItem); + }, + secondItem => + { + Assert.IsType(assembly.GetType("A.Service1"), secondItem); + }); + }); + + WaitForUnload(loadContextRef); + } + [Fact] public void CannotUseDefaultLoadContextForNewLifetimeScope() {