HomeChallengesRepsProblemsLeaderboardTake a challenge

Stop calling the real thing

A test that hits a real database and a real mail server. Replace both, and assert on the calls.

Intermediate18 min on the clock5 graded checks · 100 pointsTesting an ASP.NET Core APIPro
Graded by reading your code against the checklist below.

What you build

  • Replace the repository and the mailer with mocks
  • Set up the repository to return a known id
  • Pass the mocks into the service under test
  • Verify the save happened exactly once, with the right order
  • Leave no real database or mail client in the test

Done means

No real dependencies, a stubbed return value, and a verified call with Times.Once.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. The dependencies are doubles+20Standing in for the real thing
  2. The double is told what to return+20Standing in for the real thing
  3. The doubles are the ones the service uses+15Standing in for the real thing
  4. The call is verified, with a count+25Standing in for the real thing
  5. No real database or mail server is constructed+20Standing in for the real thing

What it teaches

The rest of Testing an ASP.NET Core API