public void ShouldNotInterceptConstructorsWhenIntereptingAllMethodCalls() { var modifiedTargetType = GetModifiedTargetType((name, type) => type.InterceptAllMethodCalls()); var instance = Activator.CreateInstance(modifiedTargetType); var aroundInvoke = new SampleAroundInvoke(); var provider = new SampleAroundInvokeProvider(aroundInvoke); AroundInvokeMethodCallRegistry.AddProvider(provider); var targetMethod = modifiedTargetType.GetMethod("DoSomething"); targetMethod.Invoke(instance, null); Assert.IsTrue(aroundInvoke.BeforeInvokeWasCalled); Assert.IsTrue(aroundInvoke.AfterInvokeWasCalled); }
public void ShouldCallStaticAroundInvokeProvider() { var modifiedTargetType = GetModifiedTargetType(); var instance = Activator.CreateInstance(modifiedTargetType); var aroundInvoke = new SampleAroundInvoke(); var provider = new SampleAroundInvokeProvider(aroundInvoke); AroundInvokeMethodCallRegistry.AddProvider(provider); var targetMethod = modifiedTargetType.GetMethod("DoSomething"); targetMethod.Invoke(instance, null); Assert.IsTrue(aroundInvoke.BeforeInvokeWasCalled); Assert.IsTrue(aroundInvoke.AfterInvokeWasCalled); }
public override void Term() { AroundInvokeMethodCallRegistry.Clear(); }
protected override void Term() { AroundInvokeMethodCallRegistry.Clear(); }