Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some c# projects to look at for good implementation of unit tests?

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?

like image 937
nportelli Avatar asked Aug 17 '10 19:08

nportelli


3 Answers

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.

like image 190
jsmith Avatar answered Nov 15 '22 11:11

jsmith


NerdDinner is a good, relatively simple ASP.NET MVC application that includes a full suite of unit tests.

like image 36
Dave Swersky Avatar answered Nov 15 '22 12:11

Dave Swersky


Roy Osherove did some interesting / cranky videos about test quality in well known open source code.

like image 1
Mark Simpson Avatar answered Nov 15 '22 10:11

Mark Simpson