Example #1
0
        public T CreateProxy <T>(IProxied interceptable, Type[] interfaces, object[] arguments)
        {
            var mockType = typeof(T);

            interfaces = interfaces.Concat(new[] { typeof(IMocked) }).ToArray();

            if (mockType.IsInterface)
            {
                return((T)generator.CreateInterfaceProxyWithoutTarget(mockType, interfaces, new ForwardingInterceptor(interceptable)));
            }

            try
            {
                return((T)generator.CreateClassProxy(mockType, interfaces, new ProxyGenerationOptions(), arguments, new ForwardingInterceptor(interceptable)));
            }
            catch (TypeLoadException e)
            {
                throw;
                //throw new ArgumentException(Resources.InvalidMockClass, e);
            }
            catch (MissingMethodException e)
            {
                throw;
                //throw new ArgumentException(Resources.ConstructorNotFound, e);
            }
        }
Example #2
0
 internal ForwardingInterceptor(IProxied mock)
 {
     this.mock = mock;
 }
Example #3
0
 internal InvocationAdapter(CastleInvocation invocation, IProxied mock)
 {
     this.invocation = invocation;
     this.mock       = mock;
 }