Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • ok i start understanding it.. but now let say the above 2 classes are inside my real asp.net MVC project. so i will have 2 repository classes; Test and the Real repository classes and both of them inherit from the IRepository() class, so now when i write this inside my controller class private IPostRepository posts; BlogPost post = posts.Find(id); so on run-time which Find() method the controller class will use the one inside the test repository or the one inside the real repository ?? Commented Jun 27, 2017 at 11:28
  • 1
    @johnG: You don't need two repository classes if you use an object mocking library. If you don't want to use an object mocking library, then you would need two repository classes that implement the same interface. Commented Jun 27, 2017 at 13:59
  • let say i did not use object mocking, so i will end up creating two repositories Test & Live. and the two repository classes will be refereeing the IRepository... so if inside my controller class, i create a new IRepository object and i define to use a method named GetAllUsers() so which GetAllUsers() method will be used the one inside the Test or the one inside the real repository ? Commented Jun 28, 2017 at 15:53
  • @johnGu: you will need to implement GetAllUsers() in the test repository as well (I'm a little late getting back to you on this comment, sorry). Commented Oct 2, 2021 at 13:28