public void InterceptorCreatesProxyInstance() { IInstanceInterceptor interceptor = new InterfaceInterceptor(); ImplementsInterfaceOne target = new ImplementsInterfaceOne(); IInterceptingProxy proxy = interceptor.CreateProxy(typeof(IInterfaceOne), target); IInterfaceOne intercepted = (IInterfaceOne)proxy; intercepted.TargetMethod(); Assert.IsTrue(target.TargetMethodCalled); }
public void GeneratedProxyCallsInterceptionBehaviors() { IInstanceInterceptor interceptor = new InterfaceInterceptor(); ImplementsInterfaceOne target = new ImplementsInterfaceOne(); IInterceptingProxy proxy = interceptor.CreateProxy(typeof(IInterfaceOne), target); CallCountInterceptionBehavior interceptionBehavior = new CallCountInterceptionBehavior(); proxy.AddInterceptionBehavior(interceptionBehavior); IInterfaceOne intercepted = (IInterfaceOne)proxy; intercepted.TargetMethod(); intercepted.TargetMethod(); intercepted.TargetMethod(); Assert.AreEqual(3, interceptionBehavior.CallCount); }
public void GeneratedProxyCallsHandlers() { IInstanceInterceptor interceptor = new InterfaceInterceptor(); ImplementsInterfaceOne target = new ImplementsInterfaceOne(); IInterceptingProxy proxy = interceptor.CreateProxy(typeof(IInterfaceOne), target); CallCountHandler handler = new CallCountHandler(); proxy.SetPipeline(typeof(IInterfaceOne).GetMethod("TargetMethod"), new HandlerPipeline(new ICallHandler[] { handler })); IInterfaceOne intercepted = (IInterfaceOne)proxy; intercepted.TargetMethod(); intercepted.TargetMethod(); intercepted.TargetMethod(); Assert.AreEqual(3, handler.CallCount); }
public IInterfaceOne mirrorOne(IInterfaceOne value) { return value; }
public UsingImplentation(IInterfaceOne one, IInterfaceTwo two) { this.one = one; this.two = two; }
public InterfaceOneInterceptor(IInterfaceOne target) { this.target = target; pipelines = new PipelineManager(); }
public IInterfaceOne mirrorOne(IInterfaceOne value) { return(value); }