C# 9.0 : Record Type Simplifies Unit Testing

C# 9 Record Type simplifies unit tests



Now Let’s Discuss Code:

Persons Controller:

Person Class:

New Person Request Class:

Person Response:

Person Service Interface:

Person Service Implementation

Person Repository Interface

Person Repository Implementation

Person Service Test class

Debug the Test:

Mock person object
Mock person object


Developer, Blogger, Mathematician having 15+ years of experience in Software development and delivery using C#, ASP.NET, WebAPI, Angular etc.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store