コード例 #1
0
        public void Can_resolve_all_instances_of_type_object()
        {
            var builder = new ContainerBuilder();

            for (int i = 0; i < 10; i++)
            {
                builder.Register(c => new object());
            }

            var container = builder.Build();

            IServiceLocator locator = new LightCoreAdapter(container);

            var instances = locator.GetAllInstances(typeof(object));

            Assert.IsNotNull(instances);
            Assert.IsInstanceOf<IEnumerable<object>>(instances);
        }
コード例 #2
0
        public void Can_resolve_all_instances_generic()
        {
            var builder = new ContainerBuilder();

            for (int i = 0; i < 10; i++)
            {
                builder
                    .Register(c => new List<string>());
            }

            var container = builder.Build();

            IServiceLocator locator = new LightCoreAdapter(container);

            var instances = locator.GetAllInstances<IList<string>>();

            Assert.IsNotNull(instances);
            Assert.IsInstanceOf<IEnumerable<IList<string>>>(instances);
        }
コード例 #3
0
        public void Can_resolve_all_instances_generic()
        {
            var builder = new ContainerBuilder();

            for (int i = 0; i < 10; i++)
            {
                builder
                .RegisterFactory(c => new List <string>());
            }

            var container = builder.Build();

            IServiceLocator locator = new LightCoreAdapter(container);

            var instances = locator.GetAllInstances <List <string> >().ToList();

            instances.Should().NotBeNull();
            instances.Should().BeAssignableTo <List <List <string> > >();
        }
コード例 #4
0
        public void Can_resolve_all_instances_of_type_object()
        {
            var builder = new ContainerBuilder();

            for (int i = 0; i < 10; i++)
            {
                builder.RegisterFactory(c => new object());
            }

            var container = builder.Build();

            IServiceLocator locator = new LightCoreAdapter(container);

            var instances = locator.GetAllInstances(typeof(object));


            instances.Should().NotBeNull();
            instances.Should().BeAssignableTo <IEnumerable <object> >();
        }