4. Mock Frameworks
What
they do?
Allow you to create mock objects
Allow you to set behavior of mock objects
So on…
Frameworks
NMock
Moq
MS Fakes
Etc….
5. MS Fakes
Two kind of mocking
Stubs – implementation of interfaces and abstract
class, developers provide method implementation
using delegates
Stubs
Shims
No stubs for static methods, static constructors/finalizers,
private methods and sealed types
Shims – run time method interceptors. Developers
can provide their own implementation for almost any
method
No shims for abstract methods
6. MS Fakes (Cont.)
When to use.
Legacy code that was not design for testability
3rd Party APIs
Resource for which you have no source code
Why
Because unconstrained
You don’t need to create fake by inheritance
You don’t need to implement dependency
injection
You don’t need to write code with interfaces