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); } }
internal ForwardingInterceptor(IProxied mock) { this.mock = mock; }
internal InvocationAdapter(CastleInvocation invocation, IProxied mock) { this.invocation = invocation; this.mock = mock; }