I have inherited a functional but confusing WPF MVVM application. To my annoyance, there have been virtually no single tests that make the adoption of MVVM somewhat pointless. So I decided to add some of them.
After grasping low-hanging fruit, I begin to run into trouble. There is a lot of interdependent code, especially inside the properties and methods that are used in views. For example, for a single call, you can specify a chain of events "change of properties", which, in turn, cause other calls, etc.
This is very difficult to verify because you have to write huge layouts and set up a large number of properties to test individual functions. Of course, you only need to do this once per class, and then reuse your layout and ViewModel for each test. But this is still a pain, and it seems to me that this is the wrong way. It would be better, of course, to try to break the code and make it more modular.
I'm not sure how realistic this is in MVVM. And I'm in a vicious circle, because without good tests, I worry about breaking the assembly with refactoring to write good tests. The fact that WPF MVVM is an additional concern because nothing tracks the relationship between View and ViewModel - a careless name change can completely break something.
I work in C # VS2013 and grabbed a trial version of ReSharper to see if it helps. This is fun to use, but so far it is not. My unit testing experience is small.
So - how can I approach this reasonably, methodically and safely? And how can I use my existing tools (and look at any other tools) to help?
source share