Skip to Content
Building RESTful Web Services with .NET Core
book

Building RESTful Web Services with .NET Core

by Gaurav Aroraa, Tadit Dash
May 2018
Intermediate to advanced
334 pages
7h 25m
English
Packt Publishing
Content preview from Building RESTful Web Services with .NET Core

Stubs and mocking

Stubs are canned responses to calls made during a test, whereas mocks are meant to set expectations. They can be further explained as follows:

  • Stubs: In the stubs object, we always get a valid stubbed response. The response doesn't care what input you provided. In any circumstance, the output will be the same.
  • Mocks: In the mock object, we can test or validate methods that can be called on mocked objects. This is a fake object that validates whether a unit test failed or passed. In other words, we can say that mock objects are just replicas of our actual object.

In the previous section, Writing unit tests, we used the moq framework to implement the mocked objects.

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 RESTful Web Services with ASP.NET Core 3

Hands-On RESTful Web Services with ASP.NET Core 3

Samuele Resca
Microservices in .NET Core

Microservices in .NET Core

Christian Horsdal Gammelgaard

Publisher Resources

ISBN: 9781788291576Supplemental Content