コード例 #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);
        }
コード例 #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);
        }
コード例 #3
0
        public void ShouldRaiseIfMethodIsNullWhenAddMethod()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

            behavior.Send("methodAt:put:", "aMethod", null);
        }
コード例 #4
0
        public void ShouldRaiseIfSelectorIsNullWhenAddMethod()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

            behavior.Send("methodAt:put:", null, new MockMethod());
        }
コード例 #5
0
        public void ShouldRaiseIfSelectorIsNullWhenLookup()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

            behavior.Send("lookup:", null);
        }
コード例 #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;
        }
コード例 #7
0
        public void NullIfUnknownMethodInLookup()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

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

            Assert.IsNull(retrievedMethod);
        }
コード例 #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);
        }