public void CanBindSubclassToSuperClass() { const string defaultKey = "default"; TestEmptyChildClass childObj = new TestEmptyChildClass(); IoCObjectContainer iocCon = new IoCObjectContainer(); iocCon.Bind <TestEmptyClass>(childObj, defaultKey); Assert.AreSame(childObj, iocCon.Get(typeof(TestEmptyClass), defaultKey)); }
public void CanGet() { TestEmptyClass defaultSingleton = StaticContainer.Get <TestEmptyClass>(); Assert.AreSame(DEFAULT_EMPTY_CLASS, defaultSingleton); TestEmptyClass customSingleton = StaticContainer.Get <TestEmptyClass>(CUSTOM_ID); Assert.AreSame(CUSTOM_EMPTY_CLASS, customSingleton); TestEmptyClass prototype = StaticContainer.Get <TestEmptyClass>(PROTOTYPE_ID); Assert.AreNotSame(PROTOTYPE_EMPTY_CLASS, prototype); Assert.AreEqual(typeof(TestEmptyClass), prototype.GetType()); TestEmptyChildClass childClass = (TestEmptyChildClass)StaticContainer.Get <TestEmptyClass>(SUBCLASS_ID); Assert.AreSame(EMPTY_CHILD_CLASS, childClass); }