public void ResolveInterfaceWithCycleInConstructorWithClassDependencyMethodAfterBuildUpObjectOfThisInterface_Failed() { var c = new Container(); c.RegisterType<IEmptyClass, EmptyClass>(); c.RegisterType<ISampleClassWithInterfaceMethod, SampleClassWithCycleInConstructorWithInterfaceDependencyMethod>(); ISampleClassWithInterfaceMethod sampleClass1 = new SampleClassWithCycleInConstructorWithInterfaceDependencyMethod(null); c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction); var sampleClass2 = c.Resolve<SampleClassWithCycleInConstructorWithInterfaceDependencyMethod>(ResolveKind.PartialEmitFunction); Assert.IsNotNull(sampleClass1); Assert.IsNotNull(sampleClass1.EmptyClass); Assert.IsNull(sampleClass2); }
public void ResolveInterfaceWithCycleInConstructorWithClassDependencyMethodAfterBuildUpObjectOfThisInterface_Failed() { var c = new Container(); c.RegisterType<IEmptyClass, EmptyClass>().AsPerThread(); c.RegisterType<ISampleClassWithInterfaceMethod, SampleClassWithCycleInConstructorWithInterfaceDependencyMethod>(); ISampleClassWithInterfaceMethod sampleClass1 = new SampleClassWithCycleInConstructorWithInterfaceDependencyMethod(null); SampleClassWithCycleInConstructorWithInterfaceDependencyMethod sampleClass2 = null; Exception exception = null; var thread = new Thread(() => { try { c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction); sampleClass2 = c.Resolve<SampleClassWithCycleInConstructorWithInterfaceDependencyMethod>(ResolveKind.PartialEmitFunction); } catch (Exception ex) { exception = ex; } }); thread.Start(); thread.Join(); if (exception != null) { throw exception; } Assert.IsNotNull(sampleClass1); Assert.IsNotNull(sampleClass1.EmptyClass); Assert.IsNull(sampleClass2); }