What is the proper way to unit test classes which use PostSharp aspects ? Example:
class MyViewModel
{
[AsyncOperationInformView]
public async Task DoSmth()
{
... code
}
}
I thought I could unit test my AsyncOperationInformView
aspect and then add unit test in MyViewModel
to check is aspect "appended" to method DoSmth()
(without testing aspect logic in view model tests). Is it valid and good approach? If so how to do that (how to check is aspect "appended") ? If not - why it's bad idea and what's the correct way?
I was going to use PostsSharp and had the same thought.
For unit testing, you will need to build without PostSharp, then, build with PostSharp weaving for acceptance testing.
You might, if it's appropriate, assert that the annotation AsyncOperationInformView
is present, but don't test for it's behaviour as this is the responsibility of higher level testing.