dotnet / dotnet/EntityFramework.Docs
Tweak wording on repository pattern
- Dominant language
- Mermaid
- Stars
- 1.7k
- Forks
- 2k
- Avg merge
- 7d 23h
- Merged PRs (30d)
- 16
Description
I have often used the Repository pattern and your comparison of the Repository pattern to other testing strategies is a bit misleading.
| Feature | Repository Pattern | Should Be | Reason |
|--------|--------|--------|--------|
| Test double type | Stub/mock | Stub/mock | This is fine - but this affects all other items in the list |
| Raw SQL? | Yes | No | No DB query is being executed by the Stub/mock so how is raw SQL being tested? |
| Transactions? | Yes | No | No DB is attached to the Stub/mock so how are transactions being tested? |
| Provider-specific translations?| Yes| No | No Provider is used by the Stub/mock so how are these being tested? |
| Exact query behavior?| Yes| No | No DB query is being executed by the Stub/mock so how is exact query behavior being tested? |
| Can use LINQ anywhere in the application?| No | No | This is correct |
As much as I like the repository pattern, it seems misplaced in this article. It doesn't test any of the listed features. As stated in the description of the Repository Pattern above:
> ...tests against the real database are still likely to be needed for the queries exposed by the repository.
But it's not just queries that will need tested - - all the features listed will still need tested using one of the other strategies.
I suggest removing the Repository Pattern from this article.
---
#### Document Details
⚠ *Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.*
* ID: 5bda9745-35bb-81d2-4b57-7fbb8879eb71
* Version Independent ID: 5bda9745-35bb-81d2-4b57-7fbb8879eb71
* Content: [Choosing a testing strategy - EF Core](https://learn.microsoft.com/en-us/ef/core/testing/choosing-a-testing-strategy)
* Content Source: [entity-framework/core/testing/choosing-a-testing-strategy.md](https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/testing/choosing-a-testing-strategy.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @roji
* Microsoft Alias: **avickers**
Contributor guide
Assessment
This issue has not been assessed yet.