Пример #1
0
        public override IMessage Invoke(IMessage msg)
        {
            var mcm = msg as IMethodCallMessage;
            if (mcm == null)
                return null;

            if (IsEqualsCall(mcm))
                return ReturnValue(HandleEquals(mcm), mcm);

            if (IsGetHashCodeCall(mcm))
                return ReturnValue(GetHashCode(), mcm);

            if (IsGetTypeCall(mcm))
                return ReturnValue(GetProxiedType(), mcm);

            if (IsToStringCall(mcm))
            {
                var type = GetProxiedType();
                var hashCode = GetHashCode();
                var value = string.Format("RemotingMock_{0}<{1}>", hashCode, type.Name);

                return ReturnValue(value, mcm);
            }

            var invocation = new RemotingInvocation(this, mcm);
            interceptor.Intercept(invocation);

            return ReturnValue(invocation.ReturnValue, invocation.Arguments, mcm);
        }
Пример #2
0
        public override IMessage Invoke(IMessage msg)
        {
            var mcm = msg as IMethodCallMessage;

            if (mcm == null)
            {
                return(null);
            }

            if (IsEqualsCall(mcm))
            {
                return(ReturnValue(HandleEquals(mcm), mcm));
            }

            if (IsGetHashCodeCall(mcm))
            {
                return(ReturnValue(GetHashCode(), mcm));
            }

            if (IsGetTypeCall(mcm))
            {
                return(ReturnValue(GetProxiedType(), mcm));
            }

            if (IsToStringCall(mcm))
            {
                var type     = GetProxiedType();
                var hashCode = GetHashCode();
                var value    = string.Format("RemotingMock_{0}<{1}>", hashCode, type.Name);

                return(ReturnValue(value, mcm));
            }

            var invocation = new RemotingInvocation(this, mcm);

            interceptor.Intercept(invocation);

            return(ReturnValue(invocation.ReturnValue, invocation.Arguments, mcm));
        }