Introducing
Your new presentation assistant.
Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.
Trending searches
MKE DOT NET
Sept 9th, 2017
© Copyright 2017 John M. Wright
wrightfully.com/mocktalk
Brought to you in part by:
Need a dev job? Have a dev job to fill?
Stack Overflow's got you covered!
stackoverflowbusiness.com/talent
stackoverflow.com/jobs
mock
mock.VerifyAllExpectations();
mock.AssertWasCalled(x => x.MyMethod());
mock
vs
stub
vs
stub
A rose by any other name
would smell as sweet
work about the same
mock types
A Matter of Syntax
Code Examples (aka: What can you do?)
Unconstrained Code Examples
Example Test using a Mock
Code being tested
Using Moq Syntax
Typemock Syntax
Code being tested
MS Fakes Syntax
[assembly: InternalsVisibleTo("Your.TestAssembly")]
Generated Classes:
Code Examples (aka: What can you do?)
Hijacked Code:
Moq Syntax
RhinoMocks Syntax
NSubstitute Syntax
Typemock Syntax
MS Fakes Syntax
Throwing Exceptions
All that, plus:
Mocking Multiple Calls
Alternate Implementations
What can
I expect?
Creating and Checking Expectations
dynamic
Unconstrained
Constrained
My test
value
Stipulate A Return Value
partial
mock
substitute
More Info @
wrightfully.com/mocktalk
http://mimiandeunice.com/2011/07/19/expectations/
dynamic
mock
shim
partial
Unconstrained
Great for testing "legacy" code.
Best fit for code written with testing in mind.
fake
Return Value Based On Input
strict
Constrained
Moq Syntax
RhinoMocks Syntax
NSubstitute Syntax
Typemock Syntax
MS Fakes Syntax
strict
mock
Moq Syntax
RhinoMocks Syntax
NSubstitute Syntax
Typemock Syntax
MS Fakes Syntax