SlideShare une entreprise Scribd logo
1  sur  18
Using Rhino Mocks for Effective Unit Testing Mike Clement Utah Code Camp Spring 2011 mike@softwareontheside.com @mdclement
Unit Testing Defined “A piece of code that invokes another piece of code and checks the correctness of some assumptions afterward.”
Good Unit Tests Automated and repeatable Easy to implement Remain for future use Anyone should be able to run it Run easily (push of a button) Run quickly
Simple Unit Tests No dependencies
Simple Unit Test Demo Prime Factors
More Complex Unit Tests Simple only gets you so far Need more sophisticated mechanisms Isolation or Mocking Frameworks to the rescue! Does necessitate classes/methods designed for testing
Test Doubles Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists. Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an in memory database is a good example).
More Test Doubles (Stubs) Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it 'sent', or maybe only how many messages it 'sent'. In Rhino Mocks: an object that you use in order to pass to the code under test.  expectations will never be verified.  properties will automatically behave like normal properties, and you can't set expectations on them. IMPORTANT: A stub will never cause a test to fail. MockRepository.GenerateStub<T>()
Rhino Mocks Features Choice of "Arrange, Act, and Assert" or "Explicit record, replay, and verify" models for expectations. Support for Generics, C# Lambda expressions, and other C# 3.0 and .NET 3.5 features Working with strongly typed mocks. Expectations based on: Arguments matching Constraints matching Custom callback to verify the expected arguments using your own code Calling your delegates to decide what to do Setting actions on methods, return specific value, or throw an exception. Much more.
Stubs Demo
Simple and Inline Constraints Specify repository.Stub(x => x.UpdateSession(session)) Ignore All IgnoreArguments() Arg<T>.Is.Anything Arg<T>.Is.Null
Arg Constraints Arg<T>.Is Equal(object), NotEqual(object)	Comparison using Equals GreaterThan(object), LessThan(object), LessThanOrEqual(object), GreaterThanOrEqual(object)	Comparison using >, <, >= and <= operators Same(object), NotSame(object)	Reference equality Anything()	No constraints Null(), NotNull()	Reference is null or not null TypeOf(Type), TypeOf<T>()	Argument is of a certain type Matching<T>(Predicate<T>)	Argument matches a predicate (.NET 3.5: see Arg<T>.Matches). Example: Arg<string>.Is.Matching(delegate(string s) { return s.Length == 2; } IsIn(object)	Enumerable argument includes the specified object Arg<T>.List OneOf(IEnumerable)	Argument is in the specified list Equal(IEnumerable)	All items in the enumerable argument are compared to the items in the specified list. Count(AbstractConstraint)	Constraints to the Count property of the argument. Element(int, AbstractConstraint)	Element at the specified index meets the constraint. ContainsAll(IEnumerable)	The enumerable argument contains at least the specified items. Arg<T>.Property AllPropertiesMatch(object)	All the public properties and public fields are compared to the properties in the specified object. The comparesion is recusive if public properties or fields are complex types. IsNotNull(string propertyName), IsNull(string propertyName)	Property of the given name is or is not null Value(string propertyName, object expectedValue)	The property of the given name is equal to the expected value. Value(string propertyName, AbstractConstraint constraint)	Property of the given Name meets the constraint. Arg.Text StartsWith(string), EndsWith(string), Contains(string)	String starts with, ends with or contains the specified text Like(string regex)	Property matches to the regular expression Arg<T>.Matches Arg<T>.Matches(Expression)	Only in .NET 3.5 you can specify the constraint as a lambda expression, e.g. Arg<int>.Matches(x => x > 3) Arg<T>.Matches(AbstractConstraint)	Specify Rhino Mocks Constraints, e.g. Arg<int>.Matches(Is.GreaterThan(0) && Is.LessThan(10)) http://www.ayende.com/wiki/Rhino+Mocks+3.5.ashx#ConstraintsReference
More Test Doubles (Mocks) Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to receive. An object that we can set expectations on, and which will verify that the expected actions have indeed occurred.  http://martinfowler.com/articles/mocksArentStubs.html
Mocks Strict vs. Dynamic Use Dynamic Mocks… Strict not recommended MockRepository.GenerateMock<T>()
Mocks Demo
Events! [Test]  public void RaisingEvent ()  {  varmocks = new MockRepository(); IView view = mocks.DynamicMock<IView>(); Presenter p = new Presenter(view);view.Raise(x => x.Load += null, this, EventArgs.Empty);Assert.IsTrue(p.OnLoadCalled);  }
Good Unit Testing Resources! The Art of Unit Testing: With Examples in .Net Pragmatic Unit Testing in C# with NUnit, 2nd Edition http://www.ayende.com/wiki/Rhino+Mocks.ashx
Thank you to our sponsors! Platinum Sponsors Gold Sponsors Silver Sponsors Bronze Sponsors

Contenu connexe

Tendances

Unit Testing Standards - Recommended Best Practices
Unit Testing Standards - Recommended Best PracticesUnit Testing Standards - Recommended Best Practices
Unit Testing Standards - Recommended Best Practices
Vitaliy Kulikov
 

Tendances (19)

Learning php 7
Learning php 7Learning php 7
Learning php 7
 
Mocking with Mockito
Mocking with MockitoMocking with Mockito
Mocking with Mockito
 
The Little Wonders of C# 6
The Little Wonders of C# 6The Little Wonders of C# 6
The Little Wonders of C# 6
 
Test doubles and EasyMock
Test doubles and EasyMockTest doubles and EasyMock
Test doubles and EasyMock
 
Best practices unit testing
Best practices unit testing Best practices unit testing
Best practices unit testing
 
Write codeforhumans
Write codeforhumansWrite codeforhumans
Write codeforhumans
 
Unit Testing Standards - Recommended Best Practices
Unit Testing Standards - Recommended Best PracticesUnit Testing Standards - Recommended Best Practices
Unit Testing Standards - Recommended Best Practices
 
OCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIsOCA Java SE 8 Exam Chapter 3 Core Java APIs
OCA Java SE 8 Exam Chapter 3 Core Java APIs
 
C++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing FrameworkC++ Unit Test with Google Testing Framework
C++ Unit Test with Google Testing Framework
 
Effective Java - Chapter 3: Methods Common to All Objects
Effective Java - Chapter 3: Methods Common to All ObjectsEffective Java - Chapter 3: Methods Common to All Objects
Effective Java - Chapter 3: Methods Common to All Objects
 
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
OCA Java SE 8 Exam Chapter 4 Methods EncapsulationOCA Java SE 8 Exam Chapter 4 Methods Encapsulation
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
 
More Little Wonders of C#/.NET
More Little Wonders of C#/.NETMore Little Wonders of C#/.NET
More Little Wonders of C#/.NET
 
Test-Driven Development of Xtext DSLs
Test-Driven Development  of Xtext DSLsTest-Driven Development  of Xtext DSLs
Test-Driven Development of Xtext DSLs
 
Unit testing.pptx [repaired]
Unit testing.pptx [repaired]Unit testing.pptx [repaired]
Unit testing.pptx [repaired]
 
A04
A04A04
A04
 
Template Method Design Pattern
Template Method Design PatternTemplate Method Design Pattern
Template Method Design Pattern
 
Control statements
Control statementsControl statements
Control statements
 
C# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringC# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoring
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
 

En vedette

FizzBuzz Guided Kata
FizzBuzz Guided KataFizzBuzz Guided Kata
FizzBuzz Guided Kata
Mike Clement
 

En vedette (9)

Put the Tests Before the Code
Put the Tests Before the CodePut the Tests Before the Code
Put the Tests Before the Code
 
Software Craftsmanship and Agile Code Games
Software Craftsmanship and Agile Code GamesSoftware Craftsmanship and Agile Code Games
Software Craftsmanship and Agile Code Games
 
Play to Learn: Agile Games with Cards and Dice
Play to Learn: Agile Games with Cards and DicePlay to Learn: Agile Games with Cards and Dice
Play to Learn: Agile Games with Cards and Dice
 
Thinking in F#
Thinking in F#Thinking in F#
Thinking in F#
 
Transformation Priority Premise: TDD Test Order Matters
Transformation Priority Premise: TDD Test Order MattersTransformation Priority Premise: TDD Test Order Matters
Transformation Priority Premise: TDD Test Order Matters
 
Power of Patterns: Refactoring to (or away from) Patterns
Power of Patterns: Refactoring to (or away from) PatternsPower of Patterns: Refactoring to (or away from) Patterns
Power of Patterns: Refactoring to (or away from) Patterns
 
FizzBuzz Guided Kata
FizzBuzz Guided KataFizzBuzz Guided Kata
FizzBuzz Guided Kata
 
The Quest for Continuous Delivery at Pluralsight
The Quest for Continuous Delivery at PluralsightThe Quest for Continuous Delivery at Pluralsight
The Quest for Continuous Delivery at Pluralsight
 
Mob Programming for Continuous Learning
Mob Programming for Continuous LearningMob Programming for Continuous Learning
Mob Programming for Continuous Learning
 

Similaire à Using Rhino Mocks for Effective Unit Testing

Introduction to Intermediate Java
Introduction to Intermediate JavaIntroduction to Intermediate Java
Introduction to Intermediate Java
Philip Johnson
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 

Similaire à Using Rhino Mocks for Effective Unit Testing (20)

Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocks
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
 
JAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programmingJAVA Tutorial- Do's and Don'ts of Java programming
JAVA Tutorial- Do's and Don'ts of Java programming
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
First fare 2010 java-introduction
First fare 2010 java-introductionFirst fare 2010 java-introduction
First fare 2010 java-introduction
 
Modern C++
Modern C++Modern C++
Modern C++
 
Unit testing
Unit testingUnit testing
Unit testing
 
Java 7 new features
Java 7 new featuresJava 7 new features
Java 7 new features
 
Introduction to Boost regex
Introduction to Boost regexIntroduction to Boost regex
Introduction to Boost regex
 
Java Unit Test - JUnit
Java Unit Test - JUnitJava Unit Test - JUnit
Java Unit Test - JUnit
 
Introduction to Intermediate Java
Introduction to Intermediate JavaIntroduction to Intermediate Java
Introduction to Intermediate Java
 
Test Driven
Test DrivenTest Driven
Test Driven
 
Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)Back-2-Basics: .NET Coding Standards For The Real World (2011)
Back-2-Basics: .NET Coding Standards For The Real World (2011)
 
Can't Dance The Lambda
Can't Dance The LambdaCan't Dance The Lambda
Can't Dance The Lambda
 
Java generics final
Java generics finalJava generics final
Java generics final
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 
Google mock training
Google mock trainingGoogle mock training
Google mock training
 
A la découverte des google/mock (aka gmock)
A la découverte des google/mock (aka gmock)A la découverte des google/mock (aka gmock)
A la découverte des google/mock (aka gmock)
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 

Plus de Mike Clement

Code Katas Spring 2012
Code Katas Spring 2012Code Katas Spring 2012
Code Katas Spring 2012
Mike Clement
 
Bowling Game Kata in C# Adapted
Bowling Game Kata in C# AdaptedBowling Game Kata in C# Adapted
Bowling Game Kata in C# Adapted
Mike Clement
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
Mike Clement
 

Plus de Mike Clement (11)

Collaboration Principles from Mob Programming
Collaboration Principles from Mob ProgrammingCollaboration Principles from Mob Programming
Collaboration Principles from Mob Programming
 
Focus on Flow: Lean Principles in Action
Focus on Flow: Lean Principles in ActionFocus on Flow: Lean Principles in Action
Focus on Flow: Lean Principles in Action
 
Taming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touchTaming scary production code that nobody wants to touch
Taming scary production code that nobody wants to touch
 
Develop your sense of code smell
Develop your sense of code smellDevelop your sense of code smell
Develop your sense of code smell
 
Maps over Backlogs: User Story Mapping to Share the Big Picture
Maps over Backlogs: User Story Mapping to Share the Big PictureMaps over Backlogs: User Story Mapping to Share the Big Picture
Maps over Backlogs: User Story Mapping to Share the Big Picture
 
Escaping the Pitfalls of Software Product Development
Escaping the Pitfalls of Software Product DevelopmentEscaping the Pitfalls of Software Product Development
Escaping the Pitfalls of Software Product Development
 
Code Katas Spring 2012
Code Katas Spring 2012Code Katas Spring 2012
Code Katas Spring 2012
 
Linq (from the inside)
Linq (from the inside)Linq (from the inside)
Linq (from the inside)
 
Bowling Game Kata in C# Adapted
Bowling Game Kata in C# AdaptedBowling Game Kata in C# Adapted
Bowling Game Kata in C# Adapted
 
Code Katas: Practicing Your Craft
Code Katas: Practicing Your CraftCode Katas: Practicing Your Craft
Code Katas: Practicing Your Craft
 
Software Craftsmanship
Software CraftsmanshipSoftware Craftsmanship
Software Craftsmanship
 

Dernier

Dernier (20)

HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Using Rhino Mocks for Effective Unit Testing

  • 1. Using Rhino Mocks for Effective Unit Testing Mike Clement Utah Code Camp Spring 2011 mike@softwareontheside.com @mdclement
  • 2. Unit Testing Defined “A piece of code that invokes another piece of code and checks the correctness of some assumptions afterward.”
  • 3. Good Unit Tests Automated and repeatable Easy to implement Remain for future use Anyone should be able to run it Run easily (push of a button) Run quickly
  • 4. Simple Unit Tests No dependencies
  • 5. Simple Unit Test Demo Prime Factors
  • 6. More Complex Unit Tests Simple only gets you so far Need more sophisticated mechanisms Isolation or Mocking Frameworks to the rescue! Does necessitate classes/methods designed for testing
  • 7. Test Doubles Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists. Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an in memory database is a good example).
  • 8. More Test Doubles (Stubs) Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test. Stubs may also record information about calls, such as an email gateway stub that remembers the messages it 'sent', or maybe only how many messages it 'sent'. In Rhino Mocks: an object that you use in order to pass to the code under test. expectations will never be verified. properties will automatically behave like normal properties, and you can't set expectations on them. IMPORTANT: A stub will never cause a test to fail. MockRepository.GenerateStub<T>()
  • 9. Rhino Mocks Features Choice of "Arrange, Act, and Assert" or "Explicit record, replay, and verify" models for expectations. Support for Generics, C# Lambda expressions, and other C# 3.0 and .NET 3.5 features Working with strongly typed mocks. Expectations based on: Arguments matching Constraints matching Custom callback to verify the expected arguments using your own code Calling your delegates to decide what to do Setting actions on methods, return specific value, or throw an exception. Much more.
  • 11. Simple and Inline Constraints Specify repository.Stub(x => x.UpdateSession(session)) Ignore All IgnoreArguments() Arg<T>.Is.Anything Arg<T>.Is.Null
  • 12. Arg Constraints Arg<T>.Is Equal(object), NotEqual(object) Comparison using Equals GreaterThan(object), LessThan(object), LessThanOrEqual(object), GreaterThanOrEqual(object) Comparison using >, <, >= and <= operators Same(object), NotSame(object) Reference equality Anything() No constraints Null(), NotNull() Reference is null or not null TypeOf(Type), TypeOf<T>() Argument is of a certain type Matching<T>(Predicate<T>) Argument matches a predicate (.NET 3.5: see Arg<T>.Matches). Example: Arg<string>.Is.Matching(delegate(string s) { return s.Length == 2; } IsIn(object) Enumerable argument includes the specified object Arg<T>.List OneOf(IEnumerable) Argument is in the specified list Equal(IEnumerable) All items in the enumerable argument are compared to the items in the specified list. Count(AbstractConstraint) Constraints to the Count property of the argument. Element(int, AbstractConstraint) Element at the specified index meets the constraint. ContainsAll(IEnumerable) The enumerable argument contains at least the specified items. Arg<T>.Property AllPropertiesMatch(object) All the public properties and public fields are compared to the properties in the specified object. The comparesion is recusive if public properties or fields are complex types. IsNotNull(string propertyName), IsNull(string propertyName) Property of the given name is or is not null Value(string propertyName, object expectedValue) The property of the given name is equal to the expected value. Value(string propertyName, AbstractConstraint constraint) Property of the given Name meets the constraint. Arg.Text StartsWith(string), EndsWith(string), Contains(string) String starts with, ends with or contains the specified text Like(string regex) Property matches to the regular expression Arg<T>.Matches Arg<T>.Matches(Expression) Only in .NET 3.5 you can specify the constraint as a lambda expression, e.g. Arg<int>.Matches(x => x > 3) Arg<T>.Matches(AbstractConstraint) Specify Rhino Mocks Constraints, e.g. Arg<int>.Matches(Is.GreaterThan(0) && Is.LessThan(10)) http://www.ayende.com/wiki/Rhino+Mocks+3.5.ashx#ConstraintsReference
  • 13. More Test Doubles (Mocks) Mocks are objects pre-programmed with expectations which form a specification of the calls they are expected to receive. An object that we can set expectations on, and which will verify that the expected actions have indeed occurred. http://martinfowler.com/articles/mocksArentStubs.html
  • 14. Mocks Strict vs. Dynamic Use Dynamic Mocks… Strict not recommended MockRepository.GenerateMock<T>()
  • 16. Events! [Test] public void RaisingEvent () { varmocks = new MockRepository(); IView view = mocks.DynamicMock<IView>(); Presenter p = new Presenter(view);view.Raise(x => x.Load += null, this, EventArgs.Empty);Assert.IsTrue(p.OnLoadCalled); }
  • 17. Good Unit Testing Resources! The Art of Unit Testing: With Examples in .Net Pragmatic Unit Testing in C# with NUnit, 2nd Edition http://www.ayende.com/wiki/Rhino+Mocks.ashx
  • 18. Thank you to our sponsors! Platinum Sponsors Gold Sponsors Silver Sponsors Bronze Sponsors