Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public void ShouldRaiseIfMethodIsNullWhenAddMethod()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

            behavior.Send("methodAt:put:", "aMethod", null);
        }
Ejemplo n.º 4
0
        public void ShouldRaiseIfSelectorIsNullWhenAddMethod()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

            behavior.Send("methodAt:put:", null, new MockMethod());
        }
Ejemplo n.º 5
0
        public void ShouldRaiseIfSelectorIsNullWhenLookup()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

            behavior.Send("lookup:", null);
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        public void NullIfUnknownMethodInLookup()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

            IMethod retrievedMethod = (IMethod)behavior.Send("lookup:", "unknownMethod");

            Assert.IsNull(retrievedMethod);
        }
Ejemplo n.º 8
0
        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);
        }