public void testIComponentAdapterReturnsSame() { ITouchable touchable = new SimpleTouchable(); IComponentAdapter IComponentAdapter = new InstanceComponentAdapter(typeof(ITouchable), touchable); Assert.AreSame(touchable, IComponentAdapter.GetComponentInstance(null)); }
public void TestChildOverridesParent() { parent.RegisterComponentImplementation(typeof(SimpleTouchable)); child.RegisterComponentImplementation(typeof(SimpleTouchable)); SimpleTouchable parentTouchable = (SimpleTouchable)parent.GetComponentInstance(typeof(SimpleTouchable)); SimpleTouchable childTouchable = (SimpleTouchable)child.GetComponentInstance(typeof(SimpleTouchable)); Assert.AreEqual(1, child.ComponentInstances.Count); Assert.IsFalse(parentTouchable.Equals(childTouchable)); }
public void TestDependsOnTouchableWithTouchableSpecifiedAsConstant() { DefaultPicoContainer pico = new DefaultPicoContainer(); SimpleTouchable touchable = new SimpleTouchable(); pico.RegisterComponentImplementation(typeof(DependsOnTouchable), typeof(DependsOnTouchable), new IParameter[] { new ConstantParameter(touchable) }); object o = pico.ComponentInstances; Assert.IsTrue(touchable.WasTouched); }
public void WillOmitSelfFromCollection() { IMutablePicoContainer pico = GetDefaultPicoContainer(); pico.RegisterComponentImplementation(typeof(SimpleTouchable)); pico.RegisterComponentImplementation(typeof(TouchableObserver)); ITouchable observer = (ITouchable)pico.GetComponentInstanceOfType(typeof(TouchableObserver)); Assert.IsNotNull(observer); observer.Touch(); SimpleTouchable touchable = (SimpleTouchable)pico.GetComponentInstanceOfType(typeof(SimpleTouchable)); Assert.IsTrue(touchable.WasTouched); }
public virtual void SerializedContainerCanRetrieveImplementation() { SimpleTouchable touchable = (SimpleTouchable)GetTouchableFromSerializedContainer(); Assert.IsTrue(touchable.WasTouched); }