Ejemplo n.º 1
0
        public void GetServiceTest1()
        {
            var itype     = typeof(IService1);
            var container = new IocContainer();

            Assert.False(container.ContainsService(itype));
            Assert.NotNull(container.GetService(itype));
            Assert.False(container.ContainsService(typeof(IService_NotFound)));
            Assert.Null(container.GetService(typeof(IService_NotFound)));
        }
Ejemplo n.º 2
0
        public void GetServiceTest1()
        {
            var itype = typeof(IService1);
            var container = new IocContainer();

            Assert.False(container.ContainsService(itype));
            Assert.NotNull(container.GetService(itype));
            Assert.False(container.ContainsService(typeof(IService_NotFound)));
            Assert.Null(container.GetService(typeof(IService_NotFound)));
        }
Ejemplo n.º 3
0
        public void ContainsServiceServiceTest1()
        {
            var container      = new IocContainer();
            var childContainer = new IocContainer(container);
            var itype          = typeof(IService2);

            childContainer.AddService(itype, lmp => new XService2(), promote: true);
            Assert.True(childContainer.ContainsService(itype));
            childContainer.RemoveService(itype);
            Assert.False(childContainer.ContainsService(itype));
            Assert.True(childContainer.ContainsService(itype, true));
        }
Ejemplo n.º 4
0
        public void RemoveServiceTest2()
        {
            var container      = new IocContainer();
            var childContainer = new IocContainer(container);
            var itype          = typeof(IService2);

            childContainer.AddService(itype, lmp => new XService2(), promote: true);
            Assert.True(container.ContainsService(itype));
            Assert.True(childContainer.ContainsService(itype));
            container.AddService(itype, lmp => new DefaultService2());
            Assert.IsAssignableFrom <XService2>(childContainer.GetService(itype));
            Assert.IsAssignableFrom <DefaultService2>(container.GetService(itype));
            childContainer.RemoveService(itype, true);
            Assert.False(container.ContainsService(itype));
            Assert.False(childContainer.ContainsService(itype));
        }
Ejemplo n.º 5
0
 public void RemoveServiceTest1()
 {
     var container = new IocContainer();
     var childContainer = new IocContainer(container);
     var itype = typeof(IService2);
     childContainer.AddService(itype, lmp => new XService2(), promote: true);
     Assert.True(container.ContainsService(itype));
     Assert.True(childContainer.ContainsService(itype));
     container.AddService(itype, lmp => new DefaultService2());
     Assert.IsAssignableFrom<XService2>(childContainer.GetService(itype));
     Assert.IsAssignableFrom<DefaultService2>(container.GetService(itype));
     childContainer.RemoveService(itype);
     Assert.IsAssignableFrom<DefaultService2>(childContainer.GetService(itype));
     Assert.IsAssignableFrom<DefaultService2>(container.GetService(itype));
     Assert.False(childContainer.ContainsService(itype));
 }
Ejemplo n.º 6
0
 public void ContainsServiceServiceTest1()
 {
     var container = new IocContainer();
     var childContainer = new IocContainer(container);
     var itype = typeof(IService2);
     childContainer.AddService(itype, lmp => new XService2(), promote: true);
     Assert.True(childContainer.ContainsService(itype));
     childContainer.RemoveService(itype);
     Assert.False(childContainer.ContainsService(itype));
     Assert.True(childContainer.ContainsService(itype, true));
 }