public void UnityNotEnumerable() { UnityContainer c = new UnityContainer(); c.RegisterInstance <IServiceScopeFactory>(new UnityServiceScopeFactory(c)); var sp = new UnityServiceProvider(c); c.RegisterInstance <IServiceProvider>(sp); c.RegisterSingleton <IFoo, Foo>(); var service = sp.GetRequiredService <IFoo>(); service.Should().NotBeNull(); }
public void UnityEnumerable() { UnityContainer c = new UnityContainer(); c.RegisterInstance <IServiceScopeFactory>(new UnityServiceScopeFactory(c)); var sp = new UnityServiceProvider(c); c.RegisterInstance <IServiceProvider>(sp); c.RegisterSingleton <IFoo, Foo>("a"); c.RegisterSingleton <IFoo, Foo2>("b"); var services = sp.GetRequiredService <IEnumerable <IFoo> >().ToArray(); services.Length.Should().Be(2); }