public void InterfaceInterceptionWithoutAdditionalInterfaces() { DoNothingInterceptionBehavior.Reset(); IInterceptionBehavior[] behaviourArray = new IInterceptionBehavior[1]; behaviourArray[0] = new DoNothingInterceptionBehavior(); IInterfaceA target = new ImplementsInterface(); IInterfaceA proxy = Intercept.ThroughProxy(target, new TransparentProxyInterceptor(), behaviourArray); proxy.TargetMethod(); Assert.AreEqual("Called", DoNothingInterceptionBehavior.PreCalled); Assert.AreEqual("Called", DoNothingInterceptionBehavior.PostCalled); }
public void ShouldFindAttributeOnInterface() { CustomInterceptor interceptor = new CustomInterceptor(); MethodInfo method = typeof(IInterfaceWithAttribute).GetMethod("DoSomething"); IInvocation invocation = Substitute.For <IInvocation>(); invocation.Request.Method.Returns(method); ImplementsInterface instance = new ImplementsInterface(); invocation.Request.Target.Returns(instance); CustomAttribute[] attributes = interceptor.GetAllAttributes(invocation); Assert.AreEqual(1, attributes.Length, "The wrong number of attributes were found."); }
public void SimpleInstantiation() { InterfaceToBeShared inst = new ImplementsInterface(); }