Skip to content

Conversation

fiseni
Copy link
Collaborator

@fiseni fiseni commented Jun 15, 2025

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.

@fiseni fiseni requested a review from Copilot June 15, 2025 12:19
Copy link

@Copilot Copilot AI left a 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 Respawn versions 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 DbContext for 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 Respawn reference for EF6 tests.
Directory.Packages.props Centralized Respawn versions 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 is Tests.FixtureNew. Update this to using 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: NETFFX probably should be NETFX to 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 that IAsyncLifetime is recognized. Add using Xunit; at the top.
using System.Collections;

tests/Ardalis.Specification.EntityFramework6.Tests/FixtureNew/Data/Store.cs:14

  • Using =[] for a List<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; } = [];

@fiseni fiseni merged commit 79d332d into main Jun 15, 2025
1 check passed
@fiseni fiseni deleted the fiseni/ef6-testfixture branch June 15, 2025 12:23
This was referenced Aug 20, 2025
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.

1 participant