public void ShouldBeAbleToCreateAnExecutor() { var proxy = new ProxyBase {backingObject = new Face(), interceptors = new IInterceptor[0]}; var invocation = new Invocation(proxy.interceptors); invocation.Start(typeof(IFace).GetMethods()[0], new object[0], args => (proxy.backingObject as IFace).Foo()); invocation.ReturnValue.ShouldBe(10); ((Face) proxy.backingObject).called.ShouldBe(true); }
public void ShouldBeAbleToInterceptWithMultipleInterceptors() { var list = new List<int>(); var proxy = new ProxyBase { backingObject = new InterceptedFace(list), interceptors = new IInterceptor[] { new TailInterceptor(list), new FaceInterceptor(list) } }; var invocation = new Invocation(proxy.interceptors); invocation.Start(typeof(IFace).GetMethods()[0], new object[0], args => (proxy.backingObject as IFace).Foo()); invocation.ReturnValue.ShouldBe(10); list.ShouldBe(new List<int>{0,1,2,3,4}); }