public void Can_resolve_one_instance()
        {
            var builder = new ContainerBuilder();

            builder.Register<IDictionary<string, string>>(c => new Dictionary<string, string>());

            var container = builder.Build();

            IServiceLocator locator = new LightCoreAdapter(container);

            var dictionary = locator.GetInstance(typeof(IDictionary<string, string>));

            Assert.IsNotNull(dictionary);
            Assert.IsInstanceOf<IDictionary<string, string>>(dictionary);
        }
예제 #2
0
        public void Can_resolve_one_instance()
        {
            var builder = new ContainerBuilder();

            builder.RegisterFactory <IDictionary <string, string> >(c => new Dictionary <string, string>());

            var container = builder.Build();

            IServiceLocator locator = new LightCoreAdapter(container);

            var dictionary = locator.GetInstance(typeof(IDictionary <string, string>));

            dictionary.Should().NotBeNull();
            dictionary.Should().BeAssignableTo <IDictionary <string, string> >();
        }
        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);
        }
        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);
        }
예제 #5
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> > >();
        }
예제 #6
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> >();
        }
 public LightCoreServiceLocatorAdapter(IContainer container)
 {
     // You need a reference to LightCore.CommonServiceLocator.dll.
     this.container = new LightCoreAdapter(container);
 }