public void CanInterceptVoidNoArgMethods() { ClassWithDefaultCtor instance = WireupHelper.GetInterceptingInstance <ClassWithDefaultCtor>(); instance.MethodOne(); Assert.IsTrue(instance.OneWasCalled); }
public void CallingMethodInvokesHandlers() { MethodInfo methodOne = typeof(ClassWithDefaultCtor).GetMethod("MethodOne"); ClassWithDefaultCtor instance = WireupHelper.GetInterceptingInstance <ClassWithDefaultCtor>(); IInterceptingProxy pm = (IInterceptingProxy)instance; CallCountHandler handler = new CallCountHandler(); PostCallCountHandler postHandler = new PostCallCountHandler(); HandlerPipeline pipeline = new HandlerPipeline(new ICallHandler[] { postHandler, handler }); PipelineManager manager = new PipelineManager(); manager.SetPipeline(methodOne, pipeline); pm.AddInterceptionBehavior(new PolicyInjectionBehavior(manager)); instance.MethodOne(); Assert.AreEqual(1, handler.CallCount); Assert.AreEqual(1, postHandler.CallsCompleted); }