.NET Unit Testing                                                                                    http://wp.me/pjaaL-1o...
June 22-24, 2012http://givecampmemphis.org@lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus....
Why should I be unit testing?• You have:  • No idea what you’re doing to your code  • No idea what they’re doing to your c...
A “unit” is what you isolate.• Your method has dependencies:  • The logging thing (the analytics thing?)  • The database t...
Keep the “unit”. Lose the rest.• “Faking” – also known as:  • Stubbing – test classes instead of dependencies  • Mocking –...
How do I use Microsoft Fakes?• Stubs (similar to Moq, Rhino Mocks, etc.)    • faking “well-designed” dependencies (recomme...
Onto the Code! @lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
Thank You for letting me share.• Say Hello!  •    Blog: http://notworthrepeating.blogspot.com (slides/code)  •    Google+:...
Upcoming SlideShare
Loading in …5
×

.NET Unit Testing w/ Microsoft Fakes (TechCamp Memphis Spring 2012)

1,390 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,390
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
19
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

.NET Unit Testing w/ Microsoft Fakes (TechCamp Memphis Spring 2012)

  1. 1. .NET Unit Testing http://wp.me/pjaaL-1o with Microsoft Fakes (Beta)@lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  2. 2. June 22-24, 2012http://givecampmemphis.org@lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  3. 3. Why should I be unit testing?• You have: • No idea what you’re doing to your code • No idea what they’re doing to your code • No idea what’s going to change in the future• You need: • To protect your code from you • To protect your code from them • To protect today’s work from tomorrow’s changes @lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  4. 4. A “unit” is what you isolate.• Your method has dependencies: • The logging thing (the analytics thing?) • The database thing (the web service thing?) • The thing that gets input from the UI• You need: • To test your unit’s logic, not dependencies • To control your dependencies • To test all logic anytime the code changes @lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  5. 5. Keep the “unit”. Lose the rest.• “Faking” – also known as: • Stubbing – test classes instead of dependencies • Mocking – frameworks instead of dependencies • Isolating – what’s my “unit”? Key question!• You need: • To remove the unknowns of dependencies • To test the “unit” in different scenarios • To design your code independent of testing tools @lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  6. 6. How do I use Microsoft Fakes?• Stubs (similar to Moq, Rhino Mocks, etc.) • faking “well-designed” dependencies (recommended)• Shims (similar to Isolator, Just Mock Pro, etc.) • faking “poorly-designed” dependencies (powerful) • performance overhead; runtime code rewriting• Verify • the “unit” used dependencies as expected • no verify support (yet?) @lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  7. 7. Onto the Code! @lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  8. 8. Thank You for letting me share.• Say Hello! • Blog: http://notworthrepeating.blogspot.com (slides/code) • Google+: http://gplus.to/lance Twitter: @lancehilliard • Email: lance@digitalcreations.cc• Relevant Reading • Isolating Unit Test Methods with Microsoft Fakes (MSDN) http://tinyurl.com/msfakes • Using stubs to isolate calls to virtual functions • Using shims to isolate calls to non-virtual functions • Code generation, compilation, and naming conventions• Recommended Reading • The Clean Coder: A Code of Conduct for Professional Programmers http://tinyurl.com/thecleancoder @lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance

×