Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ Consider encapsulating DbContext in integration tests #324

Open
3 tasks
matt-goldman-ssw opened this issue May 29, 2024 · 0 comments
Open
3 tasks

✅ Consider encapsulating DbContext in integration tests #324

matt-goldman-ssw opened this issue May 29, 2024 · 0 comments
Labels
Type: Feature A suggested idea for this project

Comments

@matt-goldman-ssw
Copy link
Contributor

Cc: @danielmackay

Hi @SSWConsulting/ssw-saw

Pain

Because the DbContext is scoped, the instance injected into the tests is different to the instance injected into the query handler. This can result in unexpected effects - as a scoped DbContext is a unit of work, saving changes in one instance will not reliably be reflected in other instances.

Suggested Solution

The DbContext could be encapsulated, with the test base exposing only an AddEntity method and a Query method.

Acceptance Criteria

Acceptance Criteria defines the requirements that must be met for the story to be completed. This is WHAT must be done.

See https://www.ssw.com.au/rules/acceptance-criteria.

  1. When I write unit tests and integration tests, existing test examples are clear and I can replicate them and get expected test outcomes
  2. Shared or common classes do not expose properties or methods that could allow me to write tests in a way that does not align with our intended best practice
  3. The testing apparatus guides me into the pit of success

Tasks

Tasks help developers to track small bits of work needed to meet the ACs. This is HOW the work will be done.

Tasks

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature A suggested idea for this project
Projects
Development

No branches or pull requests

1 participant