public void DoesNotProxyTargetVirtualMethodReturnValueAttributesWithProxyTargetAttributesEqualsFalse() { MarkerClass target = new MarkerClass(); AdvisedSupport advised = new AdvisedSupport(new Type[] { typeof(IMarkerInterface) }); advised.Target = target; advised.ProxyTargetAttributes = false; IAopProxy aopProxy = CreateAopProxy(advised); object proxy = aopProxy.GetProxy(); Assert.IsNotNull(proxy, "The proxy generated by a (valid) call to GetProxy() was null."); MethodInfo method = proxy.GetType().GetMethod("MarkerVirtualMethod"); Assert.IsNotNull(method); object[] attrs = method.ReturnTypeCustomAttributes.GetCustomAttributes(false); Assert.IsNotNull(attrs); Assert.AreEqual(0, attrs.Length, "Should not have attribute applied to the method's return value."); }
public void ProxyTargetVirtualMethodParameterAttributes() { MarkerClass target = new MarkerClass(); AdvisedSupport advised = new AdvisedSupport(new Type[] { typeof(IMarkerInterface) }); advised.Target = target; IAopProxy aopProxy = CreateAopProxy(advised); object proxy = aopProxy.GetProxy(); Assert.IsNotNull(proxy, "The proxy generated by a (valid) call to GetProxy() was null."); MethodInfo method = proxy.GetType().GetMethod("MarkerVirtualMethod"); Assert.IsNotNull(method); object[] attrs = method.GetParameters()[1].GetCustomAttributes(false); Assert.IsNotNull(attrs, "Should have had 1 attribute applied to the method's parameter."); Assert.AreEqual(1, attrs.Length, "Should have had 1 attribute applied to the method's parameter."); Assert.AreEqual(typeof(MarkerAttribute), attrs[0].GetType(), "Wrong System.Type of Attribute applied to the method's parameter."); }