public void ShouldFindAttributesInInterfaceAndClass() { CustomInterceptor interceptor = new CustomInterceptor(); MethodInfo method = typeof(IInterfaceWithAttribute).GetMethod("DoSomething"); IInvocation invocation = Substitute.For <IInvocation>(); invocation.Request.Method.Returns(method); AttributeInheritedAndReproduced instance = new AttributeInheritedAndReproduced(); invocation.Request.Target.Returns(instance); CustomAttribute[] attributes = interceptor.GetAllAttributes(invocation); Assert.AreEqual(2, attributes.Length, "The wrong number of attributes were found."); }
public void ShouldFindAttributeOnAbstractClass() { CustomInterceptor interceptor = new CustomInterceptor(); MethodInfo method = typeof(AbstractClassWithAttribute).GetMethod("DoSomething"); IInvocation invocation = Substitute.For <IInvocation>(); invocation.Request.Method.Returns(method); ImplementsAbstractClass instance = new ImplementsAbstractClass(); invocation.Request.Target.Returns(instance); CustomAttribute[] attributes = interceptor.GetAllAttributes(invocation); Assert.AreEqual(1, attributes.Length, "The wrong number of attributes were found."); }