Skip to Content
C# and .NET Core Test-Driven Development
book

C# and .NET Core Test-Driven Development

by Ayobami Adewole
May 2018
Intermediate to advanced content levelIntermediate to advanced
300 pages
7h 35m
English
Packt Publishing
Content preview from C# and .NET Core Test-Driven Development

Mocks and stubs

Mocks and stubs are both similar because they are used to replace class dependencies or collaborators and most mocking frameworks provide the features to create both. Stubs can be hand-rolled in the same manner you hand-roll mocks.

So what really differentiates mocks from stubs? Mocks are used to test collaboration. This includes verifying the expectations of the actual collaborator. Mocks are programmed to have the expectation containing the details of method invocations to be received, while stubs are used to simulate collaborators. Let's explain this further with an illustration.

A stub can be used to represent the result from a database. In place of a database call to return a set of data, a C# list can be created with ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Design Patterns with C# and .NET Core

Hands-On Design Patterns with C# and .NET Core

Gaurav Aroraa, Jeffrey Chilberto
.NET Core in Action

.NET Core in Action

Dustin Metzgar

Publisher Resources

ISBN: 9781788292481Supplemental Content