.NET Unit Testing w/ Microsoft Fakes (TechCamp Memphis Spring 2012)
Upcoming SlideShare
Loading in...5
×
 

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

on

  • 1,405 views

 

Statistics

Views

Total Views
1,405
Views on SlideShare
1,405
Embed Views
0

Actions

Likes
0
Downloads
13
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

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

  • .NET Unit Testing http://wp.me/pjaaL-1o with Microsoft Fakes (Beta)@lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  • June 22-24, 2012http://givecampmemphis.org@lancehilliard -- .NET Unit Testing with Microsoft Fakes (Beta) -- http://gplus.to/lance
  • 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
  • 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
  • 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
  • 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
  • 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+: 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