Not something too large, yet no 2+2=4 type of examples either. Specifically it would be nice if it were WPF and MVVM. I'm confused on what to test for the view model.
How do you test what is in Lambda's? Do you? Do you make a function public just so you can test it. Or do you just test the final result?
I use the Nunit test suite with WPF/MVVM. Here is a decent tutorial to get you started.
When I write my unit tests, what I test for depends on what the object is doing. Most cases the Final Result is enough. I primarily test my public methods/attributes, to make sure based on known circumstances the outcome is what is expected. (Remember, with TDD, your suppose to write your tests before you write your code.)
CodeProject has several Nunit projects that you can download and step through, that's how I got started.
Test things like boundaries, success/failure, and equivalency. The more you practice, the more things you'll think of to test for, and the more comfortable you will get with it.
Update - More Complex Projects
If you want more advanced, here are some projects that include Mocks, which for me, was the hardest thing to grasp with Unit Testing.
NerdDinner is a good, relatively simple ASP.NET MVC application that includes a full suite of unit tests.
Roy Osherove did some interesting / cranky videos about test quality in well known open source code.
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