开发者

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 pub开发者_StackOverflow社区lic 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 watch this awesome video by Jason Dolinger (I used to work with him, he knows his stuff!!) he touches on Unit Testing within a MVVM world. It's not extensive, but it should give you some idea.

http://www.lab49.com/files/videos/Jason%20Dolinger%20MVVM.wmv


Check out Prism from Microsoft's Patterns & Practices Group, download here: http://compositewpf.codeplex.com/

Includes multiple example code solutions and extensive unit tests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜