public void Test_retry_interceptor() { var counter = new Counter(); var a = new SimpleInterceptor(counter); var b = new RetryInterceptor(10); var c = new SimpleInterceptor(counter); var inv = new TestInvocation(); Assert.AreEqual(0, inv.ProceedCount); Assert.AreEqual(0, inv.InvokeCount); var chain = new AopInterceptorChain(new IInterceptor[] { a, b, c }); chain.Intercept(inv); // check invocation ultimately invoked 10 times, but NOT via the Proceed() method Assert.AreEqual(0, inv.ProceedCount); Assert.AreEqual(10, inv.InvokeCount); // check each interceptor called correct number of times Assert.AreEqual(1, a.InterceptCount); Assert.AreEqual(1, b.InterceptCount); Assert.AreEqual(10, c.InterceptCount); }
public void Test_basic_interception_chain() { var counter = new Counter(); var a = new SimpleInterceptor(counter); var b = new SimpleInterceptor(counter); var c = new SimpleInterceptor(counter); var inv = new TestInvocation(); Assert.IsFalse(inv.Proceeded); Assert.IsFalse(inv.Invoked); var chain = new AopInterceptorChain(new[] { a, b, c }); chain.Intercept(inv); // check invocation ultimately invoked, but NOT via the Proceed() method Assert.IsFalse(inv.Proceeded); Assert.IsTrue(inv.Invoked); // check each interceptor called in correct order Assert.AreEqual(0, a.InterceptIndex); Assert.AreEqual(1, b.InterceptIndex); Assert.AreEqual(2, c.InterceptIndex); }
public void Test_empty_interception_chain() { var inv = new TestInvocation(); Assert.IsFalse(inv.Proceeded); Assert.IsFalse(inv.Invoked); var chain = new AopInterceptorChain(new IInterceptor[0]); chain.Intercept(inv); // check invocation ultimately invoked, but NOT via the Proceed() method Assert.IsFalse(inv.Proceeded); Assert.IsTrue(inv.Invoked); }
public void Test_interceptor_does_not_proceed() { var counter = new Counter(); var a = new SimpleInterceptor(counter, false); var inv = new TestInvocation(); Assert.IsFalse(inv.Proceeded); Assert.IsFalse(inv.Invoked); var chain = new AopInterceptorChain(new[] { a }); chain.Intercept(inv); // check invocation not invoked Assert.IsFalse(inv.Proceeded); Assert.IsFalse(inv.Invoked); // check each interceptor called in correct order Assert.AreEqual(0, a.InterceptIndex); }
public void Test_basic_interception_chain() { var counter = new Counter(); var a = new SimpleInterceptor(counter); var b = new SimpleInterceptor(counter); var c = new SimpleInterceptor(counter); var inv = new TestInvocation(); Assert.IsFalse(inv.Proceeded); Assert.IsFalse(inv.Invoked); var chain = new AopInterceptorChain(new[] {a, b, c}); chain.Intercept(inv); // check invocation ultimately invoked, but NOT via the Proceed() method Assert.IsFalse(inv.Proceeded); Assert.IsTrue(inv.Invoked); // check each interceptor called in correct order Assert.AreEqual(0, a.InterceptIndex); Assert.AreEqual(1, b.InterceptIndex); Assert.AreEqual(2, c.InterceptIndex); }