public void RedefineLookup() { BaseBehavior baseBehavior = new BaseBehavior(); IBehavior behavior = baseBehavior.CreateDelegated(); IMethod method = new BaseLookupMethod(); behavior.Send("methodAt:put:", "lookup:", method); IMethod newMethod = (IMethod)behavior.Send("lookup:", "lookup:"); Assert.IsNotNull(newMethod); Assert.AreEqual(method, newMethod); }
public void AddMethodAndLookup() { BaseBehavior baseBehavior = new BaseBehavior(); IBehavior behavior = baseBehavior.CreateDelegated(); IMethod method = new MockMethod(); behavior.Send("methodAt:put:", "aMethod", method); IMethod retrievedMethod = (IMethod)behavior.Send("lookup:", "aMethod"); Assert.IsNotNull(retrievedMethod); Assert.AreEqual(method, retrievedMethod); }
public void ShouldRaiseIfMethodIsNullWhenAddMethod() { BaseBehavior baseBehavior = new BaseBehavior(); IBehavior behavior = baseBehavior.CreateDelegated(); behavior.Send("methodAt:put:", "aMethod", null); }
public void ShouldRaiseIfSelectorIsNullWhenAddMethod() { BaseBehavior baseBehavior = new BaseBehavior(); IBehavior behavior = baseBehavior.CreateDelegated(); behavior.Send("methodAt:put:", null, new MockMethod()); }
public void ShouldRaiseIfSelectorIsNullWhenLookup() { BaseBehavior baseBehavior = new BaseBehavior(); IBehavior behavior = baseBehavior.CreateDelegated(); behavior.Send("lookup:", null); }
public Machine() { BaseBehavior behavior = new BaseBehavior(); IBehavior objectBehavior = behavior.CreateDelegated(); objectBehavior.Parent = null; behavior.Parent = objectBehavior; this.Object = new BaseObject(); this.Object.Behavior = objectBehavior; objectBehavior.Send("methodAt:put:", "vtable", new BaseBehaviorMethod()); objectBehavior.Send("methodAt:put:", "delegated", new BaseObjectDelegateMethod()); this.Behavior = behavior; }
public void NullIfUnknownMethodInLookup() { BaseBehavior baseBehavior = new BaseBehavior(); IBehavior behavior = baseBehavior.CreateDelegated(); IMethod retrievedMethod = (IMethod)behavior.Send("lookup:", "unknownMethod"); Assert.IsNull(retrievedMethod); }
public void RedefineAddMethod() { BaseBehavior baseBehavior = new BaseBehavior(); IBehavior behavior = baseBehavior.CreateDelegated(); IMethod method = new BaseAddMethodMethod(); behavior.Send("methodAt:put:", "methodAt:put:", method); IMethod newMethod = (IMethod)behavior.Send("lookup:", "methodAt:put:"); Assert.IsNotNull(newMethod); Assert.AreEqual(method, newMethod); IMethod anotherMethod = new MockMethod(); behavior.Send("methodAt:put:", "anotherMethod", anotherMethod); newMethod = (IMethod)behavior.Send("lookup:", "anotherMethod"); Assert.AreEqual(anotherMethod, newMethod); }