SlideShare una empresa de Scribd logo
1 de 13
Stubs, Shims, and Mocks, oh my! 
Unit Testing with Visual Studio Fakes 
Consulting/Training
Consulting/Training 
About Me 
 Microsoft Client Development MVP 
 ASPInsider 
 Twitter: @joelcochran 
 Email: joelcochran@gmail.com 
 Blog: joelcochran.com 
 Lead Developer, WintellectNOW
Consulting/Training 
About Wintellect 
Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull out all the stops 
to help our customers achieve their goals through advanced software-based consulting and training solutions. 
consulting 
Wintellect helps you build better software, faster, 
tackling the tough projects and solving the software 
and technology questions that help you transform 
your business. 
 Architecture, Analysis and Design 
 Full lifecycle software development 
 Debugging and Performance tuning 
 Database design and development 
training 
Wintellect's courses are written and taught by some of 
the biggest and most respected names in the Microsoft 
programming industry. 
 Learn from the best. Access the same training 
Microsoft’s developers enjoy 
 Real world knowledge and solutions on both current 
and cutting edge technologies 
 Flexibility in training options – onsite, virtual, on 
demand 
who we are
Wintellect’s On-Demand Video Training Solution 
Try it free 
Code: <INSERT CODE HERE> WintellectNOW.com 
COCHRAN-13 
Authors Enjoy: 
 Royalty Income 
 Personal Branding 
 Cross-Sell Opps 
 Free library access 
Subscribers Enjoy: 
 Expert Instructors 
 Quality Content 
 Practical Application 
 All Devices 
Consulting/Training Individuals | Businesses | Enterprise Organizations
What are Microsoft (Visual Studio) Fakes? 
 A tool for generating code entry and isolation endpoints 
 Generates “fake” assemblies and includes them in your project 
 Fakes then contain Stub and Shim classes 
 Included with Visual Studio 2012 and 2013 [requires Ultimate] 
Consulting/Training
Consulting/Training 
Stubs 
 Easily create Mock objects based on Interfaces 
 Encourages good design 
 Often requires refactoring
Consulting/Training 
Demo Title, if Desired
Consulting/Training 
Shims 
 Used for more difficult test items 
 Or when you cannot refactor 
 Shims are considered evil 
 Use sparingly 
 Refactor as soon as possible 
 Remove Shims
Consulting/Training 
Demo Title, if Desired
Consulting/Training 
Configuration 
 Editing the Config files 
 Allows you to minimize generated code 
 Enabling Diagnostics 
 Don’t forget to turn on Diagnostics in VS Options
Consulting/Training 
Demo Title, if Desired
Consulting/Training 
Additional Resources 
 Testing un-testable code: 
http://channel9.msdn.com/Events/TechEd/Europe/2012/DEV411 
 Isolating Code Under Test with Microsoft Fakes: 
http://msdn.microsoft.com/en-us/library/hh549175(v=vs.110).aspx 
 Peter Provost’s blog (search for Fakes): 
http://www.peterprovost.org/blog/
Consulting/Training 
Questions?

Más contenido relacionado

La actualidad más candente

Selenium Training - Eduxfactor.pptx
Selenium Training - Eduxfactor.pptxSelenium Training - Eduxfactor.pptx
Selenium Training - Eduxfactor.pptxbasanthbliss99
 
Selenium Training - Eduxfactor-converted.pdf
Selenium Training - Eduxfactor-converted.pdfSelenium Training - Eduxfactor-converted.pdf
Selenium Training - Eduxfactor-converted.pdfbasanthbliss99
 
Selenium Training - Eduxfactor-converted.pdf
Selenium Training - Eduxfactor-converted.pdfSelenium Training - Eduxfactor-converted.pdf
Selenium Training - Eduxfactor-converted.pdfAkhilkumar590509
 
Development without Testers: Myth or Real Option?
Development without Testers: Myth or Real Option?Development without Testers: Myth or Real Option?
Development without Testers: Myth or Real Option?Mikalai Alimenkou
 
Blurring the Lines between ECM and CCMS
Blurring the Lines between ECM and CCMSBlurring the Lines between ECM and CCMS
Blurring the Lines between ECM and CCMSLavaCon
 
Microsoft student partners fy14 reruitment
Microsoft student partners fy14 reruitmentMicrosoft student partners fy14 reruitment
Microsoft student partners fy14 reruitmentNiket Chandrawanshi
 
Kristin Stanley Assignment3
Kristin Stanley Assignment3Kristin Stanley Assignment3
Kristin Stanley Assignment3Kristin Stanley
 
Outsourcing php india
Outsourcing php indiaOutsourcing php india
Outsourcing php indiataishaaben
 
Code smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsCode smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsClint Edmonson
 
Decide on technology stack & data architecture
Decide on technology stack & data architectureDecide on technology stack & data architecture
Decide on technology stack & data architectureSV.CO
 
Unexpected benefits of .net development outsourcing. 2
Unexpected benefits of .net development outsourcing. 2Unexpected benefits of .net development outsourcing. 2
Unexpected benefits of .net development outsourcing. 2AnupamSingh211
 

La actualidad más candente (11)

Selenium Training - Eduxfactor.pptx
Selenium Training - Eduxfactor.pptxSelenium Training - Eduxfactor.pptx
Selenium Training - Eduxfactor.pptx
 
Selenium Training - Eduxfactor-converted.pdf
Selenium Training - Eduxfactor-converted.pdfSelenium Training - Eduxfactor-converted.pdf
Selenium Training - Eduxfactor-converted.pdf
 
Selenium Training - Eduxfactor-converted.pdf
Selenium Training - Eduxfactor-converted.pdfSelenium Training - Eduxfactor-converted.pdf
Selenium Training - Eduxfactor-converted.pdf
 
Development without Testers: Myth or Real Option?
Development without Testers: Myth or Real Option?Development without Testers: Myth or Real Option?
Development without Testers: Myth or Real Option?
 
Blurring the Lines between ECM and CCMS
Blurring the Lines between ECM and CCMSBlurring the Lines between ECM and CCMS
Blurring the Lines between ECM and CCMS
 
Microsoft student partners fy14 reruitment
Microsoft student partners fy14 reruitmentMicrosoft student partners fy14 reruitment
Microsoft student partners fy14 reruitment
 
Kristin Stanley Assignment3
Kristin Stanley Assignment3Kristin Stanley Assignment3
Kristin Stanley Assignment3
 
Outsourcing php india
Outsourcing php indiaOutsourcing php india
Outsourcing php india
 
Code smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software OdorsCode smells and Other Malodorous Software Odors
Code smells and Other Malodorous Software Odors
 
Decide on technology stack & data architecture
Decide on technology stack & data architectureDecide on technology stack & data architecture
Decide on technology stack & data architecture
 
Unexpected benefits of .net development outsourcing. 2
Unexpected benefits of .net development outsourcing. 2Unexpected benefits of .net development outsourcing. 2
Unexpected benefits of .net development outsourcing. 2
 

Similar a Fakes

This isn't what you think it is
This isn't what you think it isThis isn't what you think it is
This isn't what you think it isJoel Cochran
 
Host a Website on Linux or Windows - Take Your Pick with Microsoft Azure
Host a Website on Linux or Windows - Take Your Pick with Microsoft AzureHost a Website on Linux or Windows - Take Your Pick with Microsoft Azure
Host a Website on Linux or Windows - Take Your Pick with Microsoft AzureTuan Yang
 
Emilia Ciardi - MVP e start-up: anche oggi una feature domani - Codemotion Mi...
Emilia Ciardi - MVP e start-up: anche oggi una feature domani - Codemotion Mi...Emilia Ciardi - MVP e start-up: anche oggi una feature domani - Codemotion Mi...
Emilia Ciardi - MVP e start-up: anche oggi una feature domani - Codemotion Mi...Codemotion
 
Choosing the Right Demo Environment (Salesforce Partners)
Choosing the Right Demo Environment (Salesforce Partners)Choosing the Right Demo Environment (Salesforce Partners)
Choosing the Right Demo Environment (Salesforce Partners)Salesforce Partners
 
Soft Serve Presentation
Soft Serve PresentationSoft Serve Presentation
Soft Serve PresentationIurii Turok
 
IBM developerWorks overview
IBM developerWorks overviewIBM developerWorks overview
IBM developerWorks overviewbobleah
 
Introducing TDD to your project
Introducing TDD to your projectIntroducing TDD to your project
Introducing TDD to your projectBastian Feder
 
How to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software DeveloperHow to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software Developerjeetendra mandal
 
Visual Studio Enterprise 2015 Overview atidan
Visual Studio Enterprise 2015 Overview   atidanVisual Studio Enterprise 2015 Overview   atidan
Visual Studio Enterprise 2015 Overview atidanDavid J Rosenthal
 
Visual Studio 2008 Overview
Visual Studio 2008 OverviewVisual Studio 2008 Overview
Visual Studio 2008 OverviewRoman Okolovich
 
TDD with BizTalk
TDD with BizTalkTDD with BizTalk
TDD with BizTalkBen Carey
 
Tom van Ees - Academic and Commercial software Development
Tom van Ees - Academic and Commercial software DevelopmentTom van Ees - Academic and Commercial software Development
Tom van Ees - Academic and Commercial software DevelopmentDavinci software
 
6 weeks summer training in faridabad
6 weeks summer training in faridabad6 weeks summer training in faridabad
6 weeks summer training in faridabadWoxa Technologies
 

Similar a Fakes (20)

This isn't what you think it is
This isn't what you think it isThis isn't what you think it is
This isn't what you think it is
 
Impetus12
Impetus12Impetus12
Impetus12
 
aaaaaaaaaa
aaaaaaaaaaaaaaaaaaaa
aaaaaaaaaa
 
sd
sdsd
sd
 
Impetus
ImpetusImpetus
Impetus
 
Host a Website on Linux or Windows - Take Your Pick with Microsoft Azure
Host a Website on Linux or Windows - Take Your Pick with Microsoft AzureHost a Website on Linux or Windows - Take Your Pick with Microsoft Azure
Host a Website on Linux or Windows - Take Your Pick with Microsoft Azure
 
Emilia Ciardi - MVP e start-up: anche oggi una feature domani - Codemotion Mi...
Emilia Ciardi - MVP e start-up: anche oggi una feature domani - Codemotion Mi...Emilia Ciardi - MVP e start-up: anche oggi una feature domani - Codemotion Mi...
Emilia Ciardi - MVP e start-up: anche oggi una feature domani - Codemotion Mi...
 
Choosing the Right Demo Environment (Salesforce Partners)
Choosing the Right Demo Environment (Salesforce Partners)Choosing the Right Demo Environment (Salesforce Partners)
Choosing the Right Demo Environment (Salesforce Partners)
 
Insy Labs
Insy LabsInsy Labs
Insy Labs
 
VS TFS 2010 - Part1
VS TFS 2010 - Part1VS TFS 2010 - Part1
VS TFS 2010 - Part1
 
Career Portfolio
Career PortfolioCareer Portfolio
Career Portfolio
 
Soft Serve Presentation
Soft Serve PresentationSoft Serve Presentation
Soft Serve Presentation
 
IBM developerWorks overview
IBM developerWorks overviewIBM developerWorks overview
IBM developerWorks overview
 
Introducing TDD to your project
Introducing TDD to your projectIntroducing TDD to your project
Introducing TDD to your project
 
How to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software DeveloperHow to become a Software Engineer Carrier Path for Software Developer
How to become a Software Engineer Carrier Path for Software Developer
 
Visual Studio Enterprise 2015 Overview atidan
Visual Studio Enterprise 2015 Overview   atidanVisual Studio Enterprise 2015 Overview   atidan
Visual Studio Enterprise 2015 Overview atidan
 
Visual Studio 2008 Overview
Visual Studio 2008 OverviewVisual Studio 2008 Overview
Visual Studio 2008 Overview
 
TDD with BizTalk
TDD with BizTalkTDD with BizTalk
TDD with BizTalk
 
Tom van Ees - Academic and Commercial software Development
Tom van Ees - Academic and Commercial software DevelopmentTom van Ees - Academic and Commercial software Development
Tom van Ees - Academic and Commercial software Development
 
6 weeks summer training in faridabad
6 weeks summer training in faridabad6 weeks summer training in faridabad
6 weeks summer training in faridabad
 

Fakes

  • 1. Stubs, Shims, and Mocks, oh my! Unit Testing with Visual Studio Fakes Consulting/Training
  • 2. Consulting/Training About Me  Microsoft Client Development MVP  ASPInsider  Twitter: @joelcochran  Email: joelcochran@gmail.com  Blog: joelcochran.com  Lead Developer, WintellectNOW
  • 3. Consulting/Training About Wintellect Founded by top experts on Microsoft – Jeffrey Richter, Jeff Prosise, and John Robbins – we pull out all the stops to help our customers achieve their goals through advanced software-based consulting and training solutions. consulting Wintellect helps you build better software, faster, tackling the tough projects and solving the software and technology questions that help you transform your business.  Architecture, Analysis and Design  Full lifecycle software development  Debugging and Performance tuning  Database design and development training Wintellect's courses are written and taught by some of the biggest and most respected names in the Microsoft programming industry.  Learn from the best. Access the same training Microsoft’s developers enjoy  Real world knowledge and solutions on both current and cutting edge technologies  Flexibility in training options – onsite, virtual, on demand who we are
  • 4. Wintellect’s On-Demand Video Training Solution Try it free Code: <INSERT CODE HERE> WintellectNOW.com COCHRAN-13 Authors Enjoy:  Royalty Income  Personal Branding  Cross-Sell Opps  Free library access Subscribers Enjoy:  Expert Instructors  Quality Content  Practical Application  All Devices Consulting/Training Individuals | Businesses | Enterprise Organizations
  • 5. What are Microsoft (Visual Studio) Fakes?  A tool for generating code entry and isolation endpoints  Generates “fake” assemblies and includes them in your project  Fakes then contain Stub and Shim classes  Included with Visual Studio 2012 and 2013 [requires Ultimate] Consulting/Training
  • 6. Consulting/Training Stubs  Easily create Mock objects based on Interfaces  Encourages good design  Often requires refactoring
  • 8. Consulting/Training Shims  Used for more difficult test items  Or when you cannot refactor  Shims are considered evil  Use sparingly  Refactor as soon as possible  Remove Shims
  • 10. Consulting/Training Configuration  Editing the Config files  Allows you to minimize generated code  Enabling Diagnostics  Don’t forget to turn on Diagnostics in VS Options
  • 12. Consulting/Training Additional Resources  Testing un-testable code: http://channel9.msdn.com/Events/TechEd/Europe/2012/DEV411  Isolating Code Under Test with Microsoft Fakes: http://msdn.microsoft.com/en-us/library/hh549175(v=vs.110).aspx  Peter Provost’s blog (search for Fakes): http://www.peterprovost.org/blog/