public void UseExternallyControlledLifetimeResolve() { IQuickInjectContainer parentuc = new QuickInjectContainer(); parentuc.RegisterType <UnityTestClass>(new ExternallyControlledLifetimeManager()); UnityTestClass parentinstance = parentuc.Resolve <UnityTestClass>(); parentinstance.Name = "Hello World Ob1"; UnityTestClass parentinstance1 = parentuc.Resolve <UnityTestClass>(); Assert.AreSame(parentinstance.Name, parentinstance1.Name); }
public void RegisterWithParentAndChild() { //create unity container var parentuc = new QuickInjectContainer(); //register type UnityTestClass parentuc.RegisterType <UnityTestClass>(new ContainerControlledLifetimeManager()); UnityTestClass mytestparent = parentuc.Resolve <UnityTestClass>(); mytestparent.Name = "Hello World"; IQuickInjectContainer childuc = parentuc.CreateChildContainer(); childuc.RegisterType <UnityTestClass>(new ContainerControlledLifetimeManager()); UnityTestClass mytestchild = childuc.Resolve <UnityTestClass>(); Assert.AreNotSame(mytestparent.Name, mytestchild.Name); }
public void UseContainerControlledLifetime() { UnityTestClass obj1 = new UnityTestClass(); obj1.Name = "InstanceObj"; var parentuc = new QuickInjectContainer(); parentuc.RegisterType <UnityTestClass>(new ContainerControlledLifetimeManager()); UnityTestClass parentinstance = parentuc.Resolve <UnityTestClass>(); parentinstance.Name = "Hello World Ob1"; parentinstance = null; GC.Collect(); UnityTestClass parentinstance1 = parentuc.Resolve <UnityTestClass>(); Assert.AreSame("Hello World Ob1", parentinstance1.Name); }
public void UseContainerControlledLifetime() { UnityTestClass obj1 = new UnityTestClass(); obj1.Name = "InstanceObj"; var parentuc = new QuickInjectContainer(); parentuc.RegisterType<UnityTestClass>(new ContainerControlledLifetimeManager()); UnityTestClass parentinstance = parentuc.Resolve<UnityTestClass>(); parentinstance.Name = "Hello World Ob1"; parentinstance = null; GC.Collect(); UnityTestClass parentinstance1 = parentuc.Resolve<UnityTestClass>(); Assert.AreSame("Hello World Ob1", parentinstance1.Name); }