i'm using Unity to do AOP, could someone give me some idea how to unit test them?
Does your "aspect" implementation is a class that implements ICallHandler (or very similar IInterceptionBehavior in Unity 2.0) and is already added to intercepted object's execution pipeline?
If so, you can test it separately quite ordinarily. What you test is Invoke method - call it with mock created for IMethodInvocation, set up to have your object's state before invoking the aspect and with GetNextHandlerDelegate to mock object set up to represent your intercepted object call.
You can then assert:
Invoke's result (IMethodReturn
object) - i.e. test whether the
return result was properly altered,
whether the exception was thrown etc.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With