volosoft / castle-windsor-ms-adapter

Castle Windsor ASP.NET Core / Microsoft.Extensions.DependencyInjection Adapter
https://www.nuget.org/packages/Castle.Windsor.MsDependencyInjection
MIT License
85 stars 29 forks source link

Can not resolve registered IEnumerable<T> #7

Closed hikalkan closed 7 years ago

hikalkan commented 7 years ago

See unit test:

        [Fact]
        public void Should_Resolve_Registered_Enumerable()
        {
            var collection = new ServiceCollection();

            collection.AddSingleton((IEnumerable<MyTestClass3>) new List<MyTestClass3>
            {
                new MyTestClass3(),
                new MyTestClass3(),
                new MyTestClass3()
            });

            var serviceProvider = CreateServiceProvider(collection);

            using (var scope = serviceProvider.CreateScope())
            {
                var singletonEnumerable = scope.ServiceProvider.GetService<IEnumerable<MyTestClass3>>();
                var list = singletonEnumerable.ToList();
                list.Count.ShouldBe(3);
            }
        }

We directly registered IEnumerable (instead of multiple implementation of MyTestClass3). This test can not pass since it tries to return multiple implementation of MyTestClass3 as first, and can not find!