public void TestThrowExceptionIntercept() { AspectImpl aspect = new AspectImpl( new TestThrowExecptionInterceptor(), new ClassNamePointcut(".*") & new MethodAttributePointcut(typeof(TestInterceptAttribute))); AspectWeaver.Instance().Register(aspect); TestAspectWeavedClass wc = new TestAspectWeavedClass(); Console.WriteLine("MethodAttrInterceptTest Start"); wc.Hello(); Console.WriteLine("MethodAttrInterceptTest End"); }
public void TestSignatureIntercept() { try { IAspect aspect = new AspectImpl( new TestInterceptor(), new ClassNamePointcut(".*\\+TestAspectWeavedClass") & new MethodNamePointcut("Hello")); AspectWeaver.Instance().Register(aspect); TestAspectWeavedClass wc = new TestAspectWeavedClass(); Console.WriteLine("MethodSigInterceptTest Start"); wc.Hello(); Console.WriteLine("MethodSigInterceptTest End"); } catch (Exception e) { Console.WriteLine(e.GetType().Name); Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); Assert.Fail(); } }