File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
test/Autofac.Specification.Test Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -153,6 +153,38 @@ public void CanLoadInstanceOfScanAssemblyAndUnloadItAfterEnumerable()
153153 WaitForUnload ( loadContextRef ) ;
154154 }
155155
156+ [ Fact ]
157+ public void EnumerableCanContainItemsFromParentAndLoadedScope ( )
158+ {
159+ var builder = new ContainerBuilder ( ) ;
160+
161+ builder . RegisterInstance ( "string" ) . As < object > ( ) ;
162+
163+ using var rootContainer = builder . Build ( ) ;
164+
165+ LoadAssemblyAndTest (
166+ rootContainer ,
167+ out var loadContextRef ,
168+ ( builder , assembly ) => builder . RegisterType ( assembly . GetType ( "A.Service1" ) ) . As < object > ( ) ,
169+ ( scope , loadContext , assembly ) =>
170+ {
171+ var resolved = scope . Resolve < IEnumerable < object > > ( ) ;
172+
173+ Assert . Collection (
174+ resolved ,
175+ firstItem =>
176+ {
177+ Assert . Equal ( "string" , firstItem ) ;
178+ } ,
179+ secondItem =>
180+ {
181+ Assert . IsType ( assembly . GetType ( "A.Service1" ) , secondItem ) ;
182+ } ) ;
183+ } ) ;
184+
185+ WaitForUnload ( loadContextRef ) ;
186+ }
187+
156188 [ Fact ]
157189 public void CannotUseDefaultLoadContextForNewLifetimeScope ( )
158190 {
You can’t perform that action at this time.
0 commit comments