One of the benefits of adopting WPF Attached Behaviour to adding a dynamic behaviour to WPF controls is that you could unit test the implementation and still use MVVM.

The idea of this post is to demonstrate how to setup and run tests for a attached behaviours. This testing is for the implementation covered in an earlier post. It seemed to me testing is the next natural thing to talk about. Ideally the implementation of the attached behaviour can be split into smaller more responsible classes. You could argue the following tests are more of an integration tests rather than unit tests. You can always do extra refactoring but for the purpose of learning i believe that’s good enough.

Alternate Binding

Unit testing the binding string probably is the most important bit to test.