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

Mocking methods, properties, and callback

Before the methods of the mock objects can be used in the test, they need to be set up. This setup is preferably done in the constructor of the test class after the mock object is created and before the object is injected into the class that requires the dependency.

First, the data to be returned by the method to be set up will have to be created; this is the dummy data to be used in the test:

List<Loan> loans = new List<Loan>{    new Loan{Amount = 120000, Rate = 12.5, ServiceYear = 5, HasDefaulted = false },    new Loan {Amount = 150000, Rate = 12.5, ServiceYear = 4, HasDefaulted = true },    new Loan { Amount = 200000, Rate = 12.5, ServiceYear = 5, HasDefaulted = false }};

At the point of setting up the ...

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