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))); }
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))); }
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)); }
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)); }
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)); }
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)); }