Exemplo n.º 1
0
        public void ShouldRaiseIfMethodIsNullWhenAddMethod()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

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

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

            behavior.Send("lookup:", null);
        }
Exemplo n.º 4
0
        public void NullIfUnknownMethodInLookup()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

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

            Assert.IsNull(retrievedMethod);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public void CreateBehaviorWithBaseBehavior()
        {
            BaseBehavior baseBehavior = new BaseBehavior();
            IBehavior    behavior     = baseBehavior.CreateDelegated();

            Assert.IsNotNull(behavior);
            Assert.IsNotNull(behavior.Behavior);
            Assert.IsInstanceOfType(behavior, typeof(BaseBehavior));
            Assert.IsInstanceOfType(behavior.Behavior, typeof(BaseBehavior));
            Assert.AreEqual(baseBehavior, behavior.Behavior);
            Assert.IsNotNull(behavior.Parent);
            Assert.IsNotNull(behavior.Methods);
            Assert.AreEqual(behavior.Parent, baseBehavior);
        }
Exemplo 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);
        }