Skip to content

Conversation

fiseni
Copy link
Collaborator

@fiseni fiseni commented Aug 5, 2023

Closes #359. More details on the related issue.

This PR contains the following improvements.

  • Created a brand new DatabaseFixture. We'll create a unique database per each instance, and we'll delete the database on disposal.
  • We seed the database with test data (we actually write data, and not using HasData).
  • The tests won't reuse a shared DbContext, instead, we create a separate context for each test. This will lead to more reliable tests (especially while testing Include features).
  • We can define collection fixtures now. All tests part of the same collection will work against the same database. For now, we have a single ReadCollection that is utilized for all repository read actions.
  • For write actions, either we define a separate collection or utilize the ClassFixture instead.
  • The fixtures for EF Core and EF6 are consistent now.
  • Other improvements and cleanup.

@fiseni fiseni requested review from ardalis and removed request for ardalis August 5, 2023 16:43
@fiseni
Copy link
Collaborator Author

fiseni commented Aug 5, 2023

Note to self: The connection to the database fails. It happens randomly for a given project, usually 2 of them succeed completely and 1 one of them fails (and they shift randomly). I suspect now that we're creating DbContext for each test separately, we face connection pool exhaustion perhaps?

Btw, locally there is no issue at all; neither running from Test Explorer, nor through cli, nor through Docker. It has to do something with the environment in CI.

System.Data.SqlClient.SqlException : Connection Timeout Expired.  The timeout period elapsed while attempting to consume the pre-login handshake acknowledgement.  This could be because the pre-login handshake failed or the server was unable to respond back in time.  The duration spent while attempting to connect to this server was - [Pre-Login] initialization=20164; handshake=24; 

@fiseni fiseni requested a review from ardalis August 6, 2023 22:21
Copy link
Owner

@ardalis ardalis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not loving having to add 2 lines to every test for the dbContext but I get it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor and improve integration test fixtures.

2 participants