public SampleClassWithCycleInConstructorWithClassDependencyMethod(SampleClassWithCycleInConstructorWithClassDependencyMethod sampleClass) { }
public void ResolveClassWithCycleInConstructorWithClassDependencyMethodAfterBuildUpObjectOfThisClass_Failed() { var c = new Container(); c.RegisterType<EmptyClass>(); c.RegisterType<SampleClassWithCycleInConstructorWithClassDependencyMethod>(); var sampleClass1 = new SampleClassWithCycleInConstructorWithClassDependencyMethod(null); c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction); var sampleClass2 = c.Resolve<SampleClassWithCycleInConstructorWithClassDependencyMethod>(ResolveKind.PartialEmitFunction); Assert.IsNotNull(sampleClass1); Assert.IsNotNull(sampleClass1.EmptyClass); Assert.IsNull(sampleClass2); }
public void ResolveClassWithCycleInConstructorWithClassDependencyMethodAfterBuildUpObjectOfThisClass_Failed() { var c = new Container(); c.RegisterType<EmptyClass>().AsPerThread(); c.RegisterType<SampleClassWithCycleInConstructorWithClassDependencyMethod>(); var sampleClass1 = new SampleClassWithCycleInConstructorWithClassDependencyMethod(null); SampleClassWithCycleInConstructorWithClassDependencyMethod sampleClass2 = null; Exception exception = null; var thread = new Thread(() => { try { c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction); sampleClass2 = c.Resolve<SampleClassWithCycleInConstructorWithClassDependencyMethod>(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); }