Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8297101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:16:42+00:00 2026-06-08T15:16:42+00:00

This is probably a really lame question but one I need to ask. Why

  • 0

This is probably a really lame question but one I need to ask. Why bother mocking a repository ?

If you’re creating objects with hard coded values and then using Moq to return them as values from method calls on an interface (i.e. without implementation) what exactly are you testing ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:16:44+00:00Added an answer on June 8, 2026 at 3:16 pm

    Like the other answers have said, you do this in order to test the client, not the repository (or database, or external service, or whatever), but there’s two key reasons why we do this:

    1. To ensure repeatability and create exceptional cases: You want to be able to know that what you’re testing doesn’t regress over time. If your repository is changing, you can’t be certain that what works now also worked previously. Furthermore, you can identify exceptional cases that may not appear in the repository right now (perhaps a user without a Social Security number, or something similarly obscure but possible) and include them in your test, thereby ensuring future compatibility.

    2. To remove dependencies: You want to make testing as simple and as fast as possible. Every external resource a test relies on is one more barrier to regular testing. If you mock your repository, then tests can be run against your client even if the repository doesn’t exist, or is missing.

      For example, if a program hooks into a "real" database, their testing suite might use a local (or even in memory) SQLite database to test their DB behavior, and that way the person running the tests doesn’t need to configure or connect to an actual database, and any changes or errors that occur don’t impact a shared database resource.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a really dumb question with a simple answer but... I am
This is probably a really newbie question (well, I'm pretty sure it is), but
This is probably really easy for most of you. But I'm in need of
This is probably a really dumb question, but I'm finding conflicting information. I have
This is probably a really stupid MSBuild question but if I have <ItemGroup> <Dll
This is probably a really noob question, but the fact of the matter is
Alright, this is probably a really silly question but I am new to Python/Django
This is probably a really dumb question, but it's virtually impossible to google the
This is probably a really basic question, but I'm new to this and relying
this is probably a really stupid question, but I am big R newbie and.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.