public void AdviceInvokedCorrectly() { CountingBeforeAdvice getDescriptionCounter = ctx.GetObject("getDescriptionCounter") as CountingBeforeAdvice; Assert.IsNotNull(getDescriptionCounter); ITestObject testObject = GetTestObject(); Assert.AreEqual(0, getDescriptionCounter.GetCalls("GetDescription"), "Incorrect initial getDescription count"); testObject.GetDescription(); Assert.AreEqual(1, getDescriptionCounter.GetCalls("GetDescription"), "Incorrect getDescription count"); }
private void DecoratorProxyAssertions(ITestObject testObject) { CountingBeforeAdvice cba = (CountingBeforeAdvice)ctx.GetObject("countingBeforeAdvice"); NopInterceptor nop = (NopInterceptor)ctx.GetObject("nopInterceptor"); Assert.AreEqual(0, cba.GetCalls()); Assert.AreEqual(0, nop.Count); Assert.IsTrue(AopUtils.IsDecoratorAopProxy(testObject), testObject + " is not an AOP Proxy"); //extra advice calls are due to test IsDecoratorAopProxy and call to .GetType in impl Assert.AreEqual(1, nop.Count); Assert.AreEqual(1, cba.GetCalls()); int age = 5; testObject.Age = age; Assert.AreEqual(age, testObject.Age); Assert.AreEqual(3, nop.Count); Assert.AreEqual(3, cba.GetCalls()); }