| Garry's profileGarry Shutler's spaceBlogLists | Help |
|
1/26/2008 More fluent assertions using extension methodsI'm a great believer in making your unit tests as easy to read and understand as possible. I was thinking about how I could improve my tests the other day and thought about using extension methods to create a more fluent way of creating complex assertions. This has allowed me to create a complex assertion like:
Which I hope you'll agree reads a lot easier than those three assumptions on separate lines. Also, note that I have added the ability to use a predicate for when there isn't a method which quite matches your needs. Here's the code for the extension methods:
And here are the tests for the extension methods:
I'd love to hear some feedback on what you think of this style. TrackbacksThe trackback URL for this entry is: http://garryshutler.spaces.live.com/blog/cns!63AE3374C229159C!153.trak Weblogs that reference this entry
|
|
|