public void AttributesOnTargetClassesWithInterfaceProxy() { ProxyGenerator _generator = new ProxyGenerator(); AttributeCheckerInterceptor interceptor = new AttributeCheckerInterceptor(); object proxy = _generator.CreateProxy(typeof(IMyInterface), interceptor, new MyInterfaceImpl()); IMyInterface inter = (IMyInterface)proxy; Assert.AreEqual(45, inter.Calc(20, 25)); Assert.IsTrue(interceptor.LastMethodHasAttribute); Assert.IsTrue(interceptor.LastTargethasAttribute); Assert.AreEqual(48, inter.Calc(20, 25, 1, 2)); Assert.IsTrue(interceptor.LastMethodHasAttribute); Assert.IsTrue(interceptor.LastTargethasAttribute); inter.Name = "hammett"; Assert.IsFalse(interceptor.LastMethodHasAttribute); Assert.IsTrue(interceptor.LastTargethasAttribute); }
public void AttributesOnTargetClassesWithInterfaceProxy() { ProxyGenerator _generator = new ProxyGenerator(); AttributeCheckerInterceptor interceptor = new AttributeCheckerInterceptor(); object proxy = _generator.CreateProxy(typeof (IMyInterface), interceptor, new MyInterfaceImpl()); IMyInterface inter = (IMyInterface) proxy; Assert.AreEqual(45, inter.Calc(20, 25)); Assert.IsTrue(interceptor.LastMethodHasAttribute); Assert.IsTrue(interceptor.LastTargethasAttribute); Assert.AreEqual(48, inter.Calc(20, 25, 1, 2)); Assert.IsTrue(interceptor.LastMethodHasAttribute); Assert.IsTrue(interceptor.LastTargethasAttribute); inter.Name = "hammett"; Assert.IsFalse(interceptor.LastMethodHasAttribute); Assert.IsTrue(interceptor.LastTargethasAttribute); }