public void Resolve_VeryComplexNotSameInstanceFromContainer2() { // test of resolving a type that has dependent parameter types // to see if the instance is transient IMyContainer container = new IocContainer(); container.Register <System.Xml.XmlDocument, System.Xml.XmlDocument>(LifeCycle.Singleton); container.Register <StringBuilder, StringBuilder>(LifeCycle.Singleton); container.Register <VeryComplexType, VeryComplexType>(); VeryComplexType expected = container.Resolve <VeryComplexType>(); VeryComplexType actual = container.Resolve <VeryComplexType>(); Assert.NotSame(expected, actual); }
public void Register_AddVeryComplexTypeToContainer() { // test of registering a type with multiple dependent parameter types // comparing it with a manually created object of the same type IMyContainer container = new IocContainer(); container.Register <System.Xml.XmlDocument, System.Xml.XmlDocument>(); container.Register <StringBuilder, StringBuilder>(); container.Register <VeryComplexType, VeryComplexType>(); VeryComplexType expected = new VeryComplexType(new System.Xml.XmlDocument(), new StringBuilder()); VeryComplexType actual = container.Resolve <VeryComplexType>(); Assert.IsType <VeryComplexType>(expected); Assert.IsType <System.Xml.XmlDocument>(expected.xml); Assert.IsType <StringBuilder>(expected.sb); Assert.IsType <VeryComplexType>(actual); Assert.IsType <System.Xml.XmlDocument>(actual.xml); Assert.IsType <StringBuilder>(actual.sb); }