SlideShare una empresa de Scribd logo
1 de 16
Vincent Grondin  .NET Solution Architect C# Most Valuable Professional User Group Leader .NET Montreal Comparing 3 mocking frameworks
1 license of Isolator to win… Go to:   http://www.typemock.com/win In the User Group box, enter :         Vincent Grondin VCC 1
Content description Why should we mock behaviors? Existing mocking framework families Review of the application we are using today Exploring different mocking frameworks Without mocking framework Moq JustMock Isolator 2
3 Why should we mock behaviors?
Why should we mock behaviors? Isolate the code to test fromit’s infrastructure Render your code predictable Accelerate unit tests execution Simulate the execution of parts of your code Facilitate parallel developments 4
Existing mocking framework families Pffft !  We don’t need no mocking framework, boss ! Frameworks based on DynamicProxies (Castle project) Frameworks based on the .NET Profiler API 5
Pffft !  We don’t need no mocking framework, boss ! Easier said than done…  Deep understanding of these concepts: Interfaces Polymorphism using interfaces Dependency injection Service Locator « Wrapper classes »  (static methods) Maintain all your mocks into your code base plus all the code for your project… Wait before you throw me tomatoes !!! On top of all this you’re going to have to adapt your architecture so that your code becomes testable. 6
Pffft !  We don’t need no mocking framework, boss ! 7
There are two main families… Frameworks based on the Dynamic Proxies What’s a proxy? Ok… then what’s a Dynamic Proxy? Existing frameworks? MoQ Rhino Mocks Nmock3 FakeItEasy and many others… Limitations? Unable to mockstaticmethods or classes. Unable to mock “sealed - MustInherit” classes. Unable to intercept calls to non “virtual – Overridable” methods. Hard (but not impossible) to mock internal types (private classes). 8
There are two main families… Frameworks based on the .NET Profiler API What’s the .NET Profiler API? Always been accessible inside the CLR… OnFunctionEntered / Exited OnExceptionUnhandled OnExceptionCatched OnClassLoaded / Unloaded OnEventFired Existing frameworks? JustMock from Telerik Moles from Microsoft Isolator from TypeMock Limitations? Your imagination…    9
Review of the application we are using today 10
Exploring different mocking frameworks Moq(Open Source) JustMock  (Telerik) Isolator  (TypeMock) 11
Steps to follow… Have a good knowledge of the code you’re about to test Understand clearly what needs to be mocked in this code In your test, identify which mock to use to test your code 12
Without mocking framework Demo 13
Moq (Open Source) Most important class: Mock<T> Important methods and properties: Mock<T>.Setup Used to designate the method to mock (“Arrange” section of a test) ISetup.Returns Determines what will be returned when method in “Setup” is called Mock<T>.Object Reference to the dynamically created mock Demo 14
JustMock (Telerik) Most important class: Mock (static class) Important methods: Mock.Create<T> Used to create a mock of any type Mock.Arrange Used to designate the method to mock ActionExpectation.Returns  / FuncExpectation.Returns Determines what will be returned when the method named in “Arrange” is called. ActionExpectation.DoInstead  / FuncExpectation.DoInstead Replaces the call to the method specified in “Arrange” with another method call. Demo 15

Más contenido relacionado

La actualidad más candente

Finding and exploiting novel flaws in Java software (SyScan 2015)
Finding and exploiting novel flaws in Java software (SyScan 2015)Finding and exploiting novel flaws in Java software (SyScan 2015)
Finding and exploiting novel flaws in Java software (SyScan 2015)David Jorm
 
How to improve code quality for iOS apps?
How to improve code quality for iOS apps?How to improve code quality for iOS apps?
How to improve code quality for iOS apps?Kate Semizhon
 
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...Xebia Nederland BV
 
Robot framework - Lord of the Rings
Robot framework - Lord of the RingsRobot framework - Lord of the Rings
Robot framework - Lord of the RingsAsheesh Mehdiratta
 
Code Obfuscation for Android & WP7
Code Obfuscation for Android & WP7Code Obfuscation for Android & WP7
Code Obfuscation for Android & WP7Jeff Bollinger
 
QA Best Practices
QA  Best PracticesQA  Best Practices
QA Best PracticesJames York
 
Ni week 2019 - LabVIEW Unit Testing Outlook & Tutorial
Ni week 2019 - LabVIEW Unit Testing Outlook & TutorialNi week 2019 - LabVIEW Unit Testing Outlook & Tutorial
Ni week 2019 - LabVIEW Unit Testing Outlook & TutorialIncQuery Labs
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And MockingJoe Wilson
 
Robot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MRobot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MAgile Testing Alliance
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDDDror Helper
 
Robot framework Gowthami Goli
Robot framework Gowthami GoliRobot framework Gowthami Goli
Robot framework Gowthami GoliGowthami Buddi
 
Static code analysis
Static code analysisStatic code analysis
Static code analysisRune Sundling
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseUTC Fire & Security
 

La actualidad más candente (20)

Exception handling in ASP .NET
Exception handling in ASP .NETException handling in ASP .NET
Exception handling in ASP .NET
 
AspectMock
AspectMockAspectMock
AspectMock
 
Finding and exploiting novel flaws in Java software (SyScan 2015)
Finding and exploiting novel flaws in Java software (SyScan 2015)Finding and exploiting novel flaws in Java software (SyScan 2015)
Finding and exploiting novel flaws in Java software (SyScan 2015)
 
How to improve code quality for iOS apps?
How to improve code quality for iOS apps?How to improve code quality for iOS apps?
How to improve code quality for iOS apps?
 
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
TestWorks Conf Robot framework - the unsung hero of test automation - Michael...
 
Robot framework - Lord of the Rings
Robot framework - Lord of the RingsRobot framework - Lord of the Rings
Robot framework - Lord of the Rings
 
Code Obfuscation for Android & WP7
Code Obfuscation for Android & WP7Code Obfuscation for Android & WP7
Code Obfuscation for Android & WP7
 
Exception
ExceptionException
Exception
 
QA Best Practices
QA  Best PracticesQA  Best Practices
QA Best Practices
 
Ni week 2019 - LabVIEW Unit Testing Outlook & Tutorial
Ni week 2019 - LabVIEW Unit Testing Outlook & TutorialNi week 2019 - LabVIEW Unit Testing Outlook & Tutorial
Ni week 2019 - LabVIEW Unit Testing Outlook & Tutorial
 
Unit Testing And Mocking
Unit Testing And MockingUnit Testing And Mocking
Unit Testing And Mocking
 
Robot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh MRobot Framework : Lord of the Rings By Asheesh M
Robot Framework : Lord of the Rings By Asheesh M
 
Unit tests & TDD
Unit tests & TDDUnit tests & TDD
Unit tests & TDD
 
Robot framework Gowthami Goli
Robot framework Gowthami GoliRobot framework Gowthami Goli
Robot framework Gowthami Goli
 
Static code analysis
Static code analysisStatic code analysis
Static code analysis
 
클린 테스트
클린 테스트클린 테스트
클린 테스트
 
Mocking 101
Mocking 101Mocking 101
Mocking 101
 
Test driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + EclipseTest driven development in .Net - 2010 + Eclipse
Test driven development in .Net - 2010 + Eclipse
 
Code Quality Management iOS
Code Quality Management iOSCode Quality Management iOS
Code Quality Management iOS
 
Introduction to Robot Framework
Introduction to Robot FrameworkIntroduction to Robot Framework
Introduction to Robot Framework
 

Destacado

Pension 100 k+ december 2014 (slide share)
Pension 100 k+ december 2014 (slide share)Pension 100 k+ december 2014 (slide share)
Pension 100 k+ december 2014 (slide share)Dirk Ligtenberg
 
Climate Change
Climate ChangeClimate Change
Climate ChangeOgunkua
 
How To DRM Digital Content Distribution with Apps
How To DRM Digital Content Distribution with AppsHow To DRM Digital Content Distribution with Apps
How To DRM Digital Content Distribution with AppsHugh Whitehouse
 
Lambdas and Extension using VS2010
Lambdas and Extension using VS2010Lambdas and Extension using VS2010
Lambdas and Extension using VS2010vgrondin
 
Alergía a la proteina de la leche de vaca
Alergía a la proteina de la leche de vacaAlergía a la proteina de la leche de vaca
Alergía a la proteina de la leche de vacaKarene Perez
 
Dermatitis del pañal
Dermatitis del pañalDermatitis del pañal
Dermatitis del pañalKarene Perez
 
Verbien aikamuodot pp esitys
Verbien aikamuodot pp esitysVerbien aikamuodot pp esitys
Verbien aikamuodot pp esityskrakova
 
enfermedad de hirschsprung
enfermedad de hirschsprungenfermedad de hirschsprung
enfermedad de hirschsprungKarene Perez
 
Suora ja epäsuora esitys
Suora ja epäsuora esitysSuora ja epäsuora esitys
Suora ja epäsuora esityskrakova
 
Luvut ja numerot tekstissä
Luvut ja numerot tekstissäLuvut ja numerot tekstissä
Luvut ja numerot tekstissäkrakova
 
Write The A+ Anaylsis Paper[1]
Write The A+ Anaylsis Paper[1]Write The A+ Anaylsis Paper[1]
Write The A+ Anaylsis Paper[1]jennetteculpepper
 
Lause, virke, päälause ja sivulause
Lause, virke, päälause ja sivulauseLause, virke, päälause ja sivulause
Lause, virke, päälause ja sivulausekrakova
 
Lause, lauseke ja lauseenjäsennys
Lause, lauseke ja lauseenjäsennysLause, lauseke ja lauseenjäsennys
Lause, lauseke ja lauseenjäsennyskrakova
 
Pilkun käyttäminen
Pilkun käyttäminenPilkun käyttäminen
Pilkun käyttäminenkrakova
 

Destacado (18)

Pension 100 k+ december 2014 (slide share)
Pension 100 k+ december 2014 (slide share)Pension 100 k+ december 2014 (slide share)
Pension 100 k+ december 2014 (slide share)
 
Climate Change
Climate ChangeClimate Change
Climate Change
 
Factor-A
Factor-AFactor-A
Factor-A
 
How To DRM Digital Content Distribution with Apps
How To DRM Digital Content Distribution with AppsHow To DRM Digital Content Distribution with Apps
How To DRM Digital Content Distribution with Apps
 
Lambdas and Extension using VS2010
Lambdas and Extension using VS2010Lambdas and Extension using VS2010
Lambdas and Extension using VS2010
 
Alergía a la proteina de la leche de vaca
Alergía a la proteina de la leche de vacaAlergía a la proteina de la leche de vaca
Alergía a la proteina de la leche de vaca
 
Dermatitis del pañal
Dermatitis del pañalDermatitis del pañal
Dermatitis del pañal
 
Verbien aikamuodot pp esitys
Verbien aikamuodot pp esitysVerbien aikamuodot pp esitys
Verbien aikamuodot pp esitys
 
enfermedad de hirschsprung
enfermedad de hirschsprungenfermedad de hirschsprung
enfermedad de hirschsprung
 
Hipersensibilidad
HipersensibilidadHipersensibilidad
Hipersensibilidad
 
Suora ja epäsuora esitys
Suora ja epäsuora esitysSuora ja epäsuora esitys
Suora ja epäsuora esitys
 
Escarlatina
EscarlatinaEscarlatina
Escarlatina
 
Luvut ja numerot tekstissä
Luvut ja numerot tekstissäLuvut ja numerot tekstissä
Luvut ja numerot tekstissä
 
Write The A+ Anaylsis Paper[1]
Write The A+ Anaylsis Paper[1]Write The A+ Anaylsis Paper[1]
Write The A+ Anaylsis Paper[1]
 
Lause, virke, päälause ja sivulause
Lause, virke, päälause ja sivulauseLause, virke, päälause ja sivulause
Lause, virke, päälause ja sivulause
 
Lause, lauseke ja lauseenjäsennys
Lause, lauseke ja lauseenjäsennysLause, lauseke ja lauseenjäsennys
Lause, lauseke ja lauseenjäsennys
 
Pilkun käyttäminen
Pilkun käyttäminenPilkun käyttäminen
Pilkun käyttäminen
 
Menggambar teknik
Menggambar teknikMenggambar teknik
Menggambar teknik
 

Similar a Mocking vtcc3 - en

Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Steven Smith
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfBruceLee275640
 
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckCut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckTheo Jungeblut
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeAleksandar Bozinovski
 
.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development명신 김
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0Michael Vorburger
 
System verilog important
System verilog importantSystem verilog important
System verilog importantelumalai7
 
Medium Trust for Umbraco
Medium Trust for UmbracoMedium Trust for Umbraco
Medium Trust for UmbracoWarren Buckley
 
Java Programming
Java ProgrammingJava Programming
Java ProgrammingTracy Clark
 
Clean Code Part II - Dependency Injection at SoCal Code Camp
Clean Code Part II - Dependency Injection at SoCal Code CampClean Code Part II - Dependency Injection at SoCal Code Camp
Clean Code Part II - Dependency Injection at SoCal Code CampTheo Jungeblut
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworksYuri Visser
 
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampCut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampTheo Jungeblut
 
Metasploit Computer security testing tool
Metasploit  Computer security testing toolMetasploit  Computer security testing tool
Metasploit Computer security testing toolmedoelkang600
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstEnea Gabriel
 
Enterprise Java: Just What Is It and the Risks, Threats, and Exposures It Poses
Enterprise Java: Just What Is It and the Risks, Threats, and Exposures It PosesEnterprise Java: Just What Is It and the Risks, Threats, and Exposures It Poses
Enterprise Java: Just What Is It and the Risks, Threats, and Exposures It PosesAlex Senkevitch
 

Similar a Mocking vtcc3 - en (20)

Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013Common ASP.NET Design Patterns - Telerik India DevCon 2013
Common ASP.NET Design Patterns - Telerik India DevCon 2013
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdf
 
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckCut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
 
Metasploit framwork
Metasploit framworkMetasploit framwork
Metasploit framwork
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable Code
 
Unit Tests with Microsoft Fakes
Unit Tests with Microsoft FakesUnit Tests with Microsoft Fakes
Unit Tests with Microsoft Fakes
 
Acceleo Code Generation
Acceleo Code GenerationAcceleo Code Generation
Acceleo Code Generation
 
.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development.NET Fundamentals and Business Application Development
.NET Fundamentals and Business Application Development
 
OpenDaylight Developer Experience 2.0
 OpenDaylight Developer Experience 2.0 OpenDaylight Developer Experience 2.0
OpenDaylight Developer Experience 2.0
 
OIVM
OIVMOIVM
OIVM
 
System verilog important
System verilog importantSystem verilog important
System verilog important
 
Medium Trust for Umbraco
Medium Trust for UmbracoMedium Trust for Umbraco
Medium Trust for Umbraco
 
Intro To AOP
Intro To AOPIntro To AOP
Intro To AOP
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Clean Code Part II - Dependency Injection at SoCal Code Camp
Clean Code Part II - Dependency Injection at SoCal Code CampClean Code Part II - Dependency Injection at SoCal Code Camp
Clean Code Part II - Dependency Injection at SoCal Code Camp
 
Lunch and learn as3_frameworks
Lunch and learn as3_frameworksLunch and learn as3_frameworks
Lunch and learn as3_frameworks
 
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code CampCut your Dependencies - Dependency Injection at Silicon Valley Code Camp
Cut your Dependencies - Dependency Injection at Silicon Valley Code Camp
 
Metasploit Computer security testing tool
Metasploit  Computer security testing toolMetasploit  Computer security testing tool
Metasploit Computer security testing tool
 
Elements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code FirstElements of DDD with ASP.NET MVC & Entity Framework Code First
Elements of DDD with ASP.NET MVC & Entity Framework Code First
 
Enterprise Java: Just What Is It and the Risks, Threats, and Exposures It Poses
Enterprise Java: Just What Is It and the Risks, Threats, and Exposures It PosesEnterprise Java: Just What Is It and the Risks, Threats, and Exposures It Poses
Enterprise Java: Just What Is It and the Risks, Threats, and Exposures It Poses
 

Último

Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Falcon Invoice Discounting
 
CROSS CULTURAL NEGOTIATION BY PANMISEM NS
CROSS CULTURAL NEGOTIATION BY PANMISEM NSCROSS CULTURAL NEGOTIATION BY PANMISEM NS
CROSS CULTURAL NEGOTIATION BY PANMISEM NSpanmisemningshen123
 
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGBerhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGpr788182
 
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGBerhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGpr788182
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxCynthia Clay
 
Mckinsey foundation level Handbook for Viewing
Mckinsey foundation level Handbook for ViewingMckinsey foundation level Handbook for Viewing
Mckinsey foundation level Handbook for ViewingNauman Safdar
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Adnet Communications
 
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165meghakumariji156
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1kcpayne
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPanhandleOilandGas
 
GUWAHATI 💋 Call Girl 9827461493 Call Girls in Escort service book now
GUWAHATI 💋 Call Girl 9827461493 Call Girls in  Escort service book nowGUWAHATI 💋 Call Girl 9827461493 Call Girls in  Escort service book now
GUWAHATI 💋 Call Girl 9827461493 Call Girls in Escort service book nowkapoorjyoti4444
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting
 
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service AvailableNashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Availablepr788182
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...daisycvs
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...pujan9679
 
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...meghakumariji156
 
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All TimeCall 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All Timegargpaaro
 
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTSDurg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTSkajalroy875762
 

Último (20)

Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
Unveiling Falcon Invoice Discounting: Leading the Way as India's Premier Bill...
 
CROSS CULTURAL NEGOTIATION BY PANMISEM NS
CROSS CULTURAL NEGOTIATION BY PANMISEM NSCROSS CULTURAL NEGOTIATION BY PANMISEM NS
CROSS CULTURAL NEGOTIATION BY PANMISEM NS
 
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGBerhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
 
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDINGBerhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
Berhampur 70918*19311 CALL GIRLS IN ESCORT SERVICE WE ARE PROVIDING
 
Putting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptxPutting the SPARK into Virtual Training.pptx
Putting the SPARK into Virtual Training.pptx
 
Mckinsey foundation level Handbook for Viewing
Mckinsey foundation level Handbook for ViewingMckinsey foundation level Handbook for Viewing
Mckinsey foundation level Handbook for Viewing
 
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
Lundin Gold - Q1 2024 Conference Call Presentation (Revised)
 
HomeRoots Pitch Deck | Investor Insights | April 2024
HomeRoots Pitch Deck | Investor Insights | April 2024HomeRoots Pitch Deck | Investor Insights | April 2024
HomeRoots Pitch Deck | Investor Insights | April 2024
 
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165Lucknow Housewife Escorts  by Sexy Bhabhi Service 8250092165
Lucknow Housewife Escorts by Sexy Bhabhi Service 8250092165
 
Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1Katrina Personal Brand Project and portfolio 1
Katrina Personal Brand Project and portfolio 1
 
PHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation FinalPHX May 2024 Corporate Presentation Final
PHX May 2024 Corporate Presentation Final
 
GUWAHATI 💋 Call Girl 9827461493 Call Girls in Escort service book now
GUWAHATI 💋 Call Girl 9827461493 Call Girls in  Escort service book nowGUWAHATI 💋 Call Girl 9827461493 Call Girls in  Escort service book now
GUWAHATI 💋 Call Girl 9827461493 Call Girls in Escort service book now
 
Falcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investorsFalcon Invoice Discounting: The best investment platform in india for investors
Falcon Invoice Discounting: The best investment platform in india for investors
 
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service AvailableNashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
Nashik Call Girl Just Call 7091819311 Top Class Call Girl Service Available
 
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
Quick Doctor In Kuwait +2773`7758`557 Kuwait Doha Qatar Dubai Abu Dhabi Sharj...
 
WheelTug Short Pitch Deck 2024 | Byond Insights
WheelTug Short Pitch Deck 2024 | Byond InsightsWheelTug Short Pitch Deck 2024 | Byond Insights
WheelTug Short Pitch Deck 2024 | Byond Insights
 
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
Ooty Call Gril 80022//12248 Only For Sex And High Profile Best Gril Sex Avail...
 
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
Escorts in Nungambakkam Phone 8250092165 Enjoy 24/7 Escort Service Enjoy Your...
 
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All TimeCall 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
Call 7737669865 Vadodara Call Girls Service at your Door Step Available All Time
 
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTSDurg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
Durg CALL GIRL ❤ 82729*64427❤ CALL GIRLS IN durg ESCORTS
 

Mocking vtcc3 - en

  • 1. Vincent Grondin .NET Solution Architect C# Most Valuable Professional User Group Leader .NET Montreal Comparing 3 mocking frameworks
  • 2. 1 license of Isolator to win… Go to: http://www.typemock.com/win In the User Group box, enter : Vincent Grondin VCC 1
  • 3. Content description Why should we mock behaviors? Existing mocking framework families Review of the application we are using today Exploring different mocking frameworks Without mocking framework Moq JustMock Isolator 2
  • 4. 3 Why should we mock behaviors?
  • 5. Why should we mock behaviors? Isolate the code to test fromit’s infrastructure Render your code predictable Accelerate unit tests execution Simulate the execution of parts of your code Facilitate parallel developments 4
  • 6. Existing mocking framework families Pffft ! We don’t need no mocking framework, boss ! Frameworks based on DynamicProxies (Castle project) Frameworks based on the .NET Profiler API 5
  • 7. Pffft ! We don’t need no mocking framework, boss ! Easier said than done… Deep understanding of these concepts: Interfaces Polymorphism using interfaces Dependency injection Service Locator « Wrapper classes » (static methods) Maintain all your mocks into your code base plus all the code for your project… Wait before you throw me tomatoes !!! On top of all this you’re going to have to adapt your architecture so that your code becomes testable. 6
  • 8. Pffft ! We don’t need no mocking framework, boss ! 7
  • 9. There are two main families… Frameworks based on the Dynamic Proxies What’s a proxy? Ok… then what’s a Dynamic Proxy? Existing frameworks? MoQ Rhino Mocks Nmock3 FakeItEasy and many others… Limitations? Unable to mockstaticmethods or classes. Unable to mock “sealed - MustInherit” classes. Unable to intercept calls to non “virtual – Overridable” methods. Hard (but not impossible) to mock internal types (private classes). 8
  • 10. There are two main families… Frameworks based on the .NET Profiler API What’s the .NET Profiler API? Always been accessible inside the CLR… OnFunctionEntered / Exited OnExceptionUnhandled OnExceptionCatched OnClassLoaded / Unloaded OnEventFired Existing frameworks? JustMock from Telerik Moles from Microsoft Isolator from TypeMock Limitations? Your imagination…  9
  • 11. Review of the application we are using today 10
  • 12. Exploring different mocking frameworks Moq(Open Source) JustMock (Telerik) Isolator (TypeMock) 11
  • 13. Steps to follow… Have a good knowledge of the code you’re about to test Understand clearly what needs to be mocked in this code In your test, identify which mock to use to test your code 12
  • 15. Moq (Open Source) Most important class: Mock<T> Important methods and properties: Mock<T>.Setup Used to designate the method to mock (“Arrange” section of a test) ISetup.Returns Determines what will be returned when method in “Setup” is called Mock<T>.Object Reference to the dynamically created mock Demo 14
  • 16. JustMock (Telerik) Most important class: Mock (static class) Important methods: Mock.Create<T> Used to create a mock of any type Mock.Arrange Used to designate the method to mock ActionExpectation.Returns / FuncExpectation.Returns Determines what will be returned when the method named in “Arrange” is called. ActionExpectation.DoInstead / FuncExpectation.DoInstead Replaces the call to the method specified in “Arrange” with another method call. Demo 15
  • 17. Isolator (TypeMock) Most important class: Isolate (which should probably be static but isn’t) Important methods: Isolate.Fake.Instance<> Used to create a mock of any type Isolate.WhenCalled<> Used to designate the method to mock IReturnValueHandler.WillReturn Determines what will be returned when the method named in “WhenCalled” is called. IReturnValueHandler.DoInstead Replaces the call to the method specified in “WhenCalled” with another method call. Demo 16
  • 18. 17