public void DifferentThreads_DifferentObjects_RegisterClassWithDependencyPropertyAndDependencyMethodWithDifferentTypes_Success() { var c = new Container(); c.RegisterType<IEmptyClass, EmptyClass>().AsPerThread(); c.RegisterType<ISampleClassWithInterfaceAsParameter, SampleClassWithInterfaceAsParameter>().AsPerThread(); ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes sampleClass1 = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes(); ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes sampleClass2 = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes(); var thread1 = new Thread(() => { c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction); }); thread1.Start(); thread1.Join(); var thread2 = new Thread(() => { c.BuildUp(sampleClass2, ResolveKind.PartialEmitFunction); }); thread2.Start(); thread2.Join(); Assert.IsNotNull(sampleClass1.SampleClass); Assert.IsNotNull(sampleClass1.EmptyClass); Assert.AreNotEqual(sampleClass1.SampleClass, sampleClass1.EmptyClass); Assert.AreEqual(sampleClass1.SampleClass.EmptyClass, sampleClass1.EmptyClass); Assert.IsNotNull(sampleClass2.SampleClass); Assert.IsNotNull(sampleClass2.EmptyClass); Assert.AreNotEqual(sampleClass2.SampleClass, sampleClass2.EmptyClass); Assert.AreEqual(sampleClass2.SampleClass.EmptyClass, sampleClass2.EmptyClass); Assert.AreNotEqual(sampleClass1, sampleClass2); Assert.AreNotEqual(sampleClass1.SampleClass, sampleClass2.SampleClass); Assert.AreNotEqual(sampleClass1.EmptyClass, sampleClass2.EmptyClass); }
public void DifferentObjects_BuildUpInterfaceWithDependencyPropertyAndDependencyMethodWithDifferentTypes_SEmptyClassAsSingleton_Success() { var c = new Container(); c.RegisterType<IEmptyClass, EmptyClass>().AsSingleton(); c.RegisterType<ISampleClassWithInterfaceAsParameter, SampleClassWithInterfaceAsParameter>(); ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes sampleClass1 = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes(); ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes sampleClass2 = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes(); c.BuildUp(sampleClass1, ResolveKind.PartialEmitFunction); c.BuildUp(sampleClass2, ResolveKind.PartialEmitFunction); Assert.IsNotNull(sampleClass1.SampleClass); Assert.IsNotNull(sampleClass1.EmptyClass); Assert.AreNotEqual(sampleClass1.SampleClass, sampleClass1.EmptyClass); Assert.AreEqual(sampleClass1.SampleClass.EmptyClass, sampleClass1.EmptyClass); Assert.IsNotNull(sampleClass2.SampleClass); Assert.IsNotNull(sampleClass2.EmptyClass); Assert.AreNotEqual(sampleClass2.SampleClass, sampleClass2.EmptyClass); Assert.AreEqual(sampleClass2.SampleClass.EmptyClass, sampleClass2.EmptyClass); Assert.AreNotEqual(sampleClass1, sampleClass2); Assert.AreEqual(sampleClass1.EmptyClass, sampleClass2.EmptyClass); Assert.AreNotEqual(sampleClass1.SampleClass, sampleClass2.SampleClass); Assert.AreEqual(sampleClass1.SampleClass.EmptyClass, sampleClass2.SampleClass.EmptyClass); }
public void RegisterClassWithDependencyPropertyAndDependencyMethodWithDifferentTypes_Success() { var c = new Container(); c.RegisterType<IEmptyClass, EmptyClass>(); c.RegisterType<ISampleClassWithInterfaceAsParameter, SampleClassWithInterfaceAsParameter>(); ISampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes sampleClass = new SampleClassWithInterfaceDependencyPropertyAndDependencyMethodWithDifferentTypes(); c.BuildUp(sampleClass, ResolveKind.PartialEmitFunction); Assert.IsNotNull(sampleClass.SampleClass); Assert.IsNotNull(sampleClass.EmptyClass); Assert.AreNotEqual(sampleClass.SampleClass, sampleClass.EmptyClass); Assert.AreNotEqual(sampleClass.SampleClass.EmptyClass, sampleClass.EmptyClass); }