- 
                Notifications
    You must be signed in to change notification settings 
- Fork 254
Add new test fixtures for EF6 provider. #519
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds comprehensive EF6 test fixtures and updates EF Core test configurations.
- Renames EF Core test database identifiers to a consistent naming scheme.
- Introduces a new EF6 fixture layer (TestFactory,TestDbContext, shared collection, repository helper, integration base, and data models).
- Configures central package management for different Respawnversions based on target framework.
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description | 
|---|---|
| tests/Ardalis.Specification.EntityFrameworkCore.Tests/Fixture/TestFactory.cs | Updated localdb catalog and container name for tests. | 
| tests/Ardalis.Specification.EntityFramework6.Tests/RepositoryOfT_ListAsync.cs | Added fixture namespace import. | 
| tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/TestFactory.cs | New EF6 test factory with multi‐TFM respawn logic. | 
| tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/TestDbContext.cs | EF6 DbContextfor test models. | 
| tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/SharedCollection.cs | Defines xUnit collection for shared fixtures. | 
| tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/Repository.cs | Generic repository helper (primary‐constructor syntax). | 
| tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/IntegrationTest.cs | Base for integration tests with seed/reset helpers. | 
| tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/Data/*.cs | EF6 data model record types. | 
| tests/Ardalis.Specification.EntityFramework6.Tests/Ardalis.Specification.EntityFramework6.Tests.csproj | Added Respawnreference for EF6 tests. | 
| Directory.Packages.props | Centralized Respawnversions by target framework. | 
Comments suppressed due to low confidence (6)
tests/Ardalis.Specification.EntityFramework6.Tests/RepositoryOfT_ListAsync.cs:1
- The EF6 tests import Tests.Fixture, but the new fixture namespace isTests.FixtureNew. Update this tousing Tests.FixtureNew;(and do the same in the other EF6 test files).
using Tests.Fixture;
tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/TestFactory.cs:42
- Typo in the catalog name: NETFFXprobably should beNETFXto match the intended naming.
_connectionString = "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=SpecificationTestsDB_EF6_NETFFX;Integrated Security=SSPI;TrustServerCertificate=True;";
tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/Repository.cs:3
- Primary‐constructor syntax for classes isn’t generally available; convert to a traditional constructor:
public class Repository<T> : RepositoryBase<T> where T : class
{
  public Repository(TestDbContext context) : base(context) {}
}public class Repository<T>(TestDbContext context) : RepositoryBase<T>(context) where T : class
tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/IntegrationTest.cs:1
- Missing using Xunit;import so thatIAsyncLifetimeis recognized. Addusing Xunit;at the top.
using System.Collections;
tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/Data/Store.cs:14
- Using =[]for aList<T>initializer may not compile; prefer= new List<Product>();for clarity and compatibility.
public List<Product> Products { get; set; } = [];
tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/Data/Company.cs:13
- Use = new List<Store>();instead of=[]to ensure the list is properly instantiated.
public List<Store> Stores { get; set; } = [];
We didn't pay attention to EF6 for a long time. We'll update and optimize implementations for this provider in the upcoming PRs.
But, before that, we have to add comprehensive tests and improve the test coverage for EF6. We have some minimal tests currently. This PR creates a new fixture that utilizes Respawn to reset the DB. We have to rely on an old Respawn API for net472, so we have to use preprocessor directives to enable/disable different usage for net9 and net472.