Skip to content

(PATCH): Add integration tests for EF Core (SQL Server, PostgreSQL) and MongoDB - #69

Merged
PaulTrampert merged 1 commit into
mainfrom
integration-tests
Sep 6, 2026
Merged

PaulTrampert merged 1 commit into
mainfrom
integration-tests

Conversation

@PaulTrampert

Copy link
Copy Markdown
Owner

Adds PTrampert.QueryObjects.Integration.Test, an NUnit project that proves query objects translate and execute
against real databases rather than only against LINQ-to-Objects.

One suite, three databases

ProductQueryTests holds every expectation and is parameterized over an IProductStore. Three fixtures supply the
store, so the same 20 cases run against each:

Fixture Category Backing store
SqlServerProductQueryTests SqlServer EF Core + mcr.microsoft.com/mssql/server:2022-latest
PostgreSqlProductQueryTests PostgreSql EF Core + postgres:17-alpine
MongoDbProductQueryTests MongoDb MongoDB C# driver + mongo:8.2

Containers come from Testcontainers, one per fixture, started in [OneTimeSetUp]. Fixtures run in parallel so the
startups overlap.

Coverage

A single ProductQuery exercises every shipped attribute — EqualsQuery, NotEqualsQuery, the four comparison
attributes, StringContainsQuery, StringStartsWithQuery, AnyOfQuery, NoneOfQuery and ContainsQuery — over
string, Guid, bool, int, decimal, DateTime and List<string> properties. There are also cases for an
empty query object, a query with no matches, multiple criteria combined, and an IQueryObject<T> expression combined
with attribute filters.

Every provider under test throws rather than silently falling back to client-side evaluation, so a passing test is
also evidence the predicate reached the database. Notably, all three translate the Intersect(...).Any() form that
AnyOfQuery/NoneOfQuery build for a collection target.

Parameterization

EfCoreProductQueryTests adds three relational-only cases that verify the behaviour introduced in #68 end to end. A
DbCommandInterceptor captures the command as sent, and the tests assert that query values arrive as SQL parameters
rather than literals, that the same query shape produces byte-identical SQL for different values, and that
InlineValue = true embeds the literal and sends no parameters.

Notes

  • The project is in the solution, so the existing pipeline's dotnet test <sln> picks it up. That means PR builds now
    need Docker and pull the SQL Server image; happy to split it into its own workflow instead if you'd rather keep the
    publish gate lighter.
  • mongo:8.2 rather than 8.0: MongoDB 8.0 refuses to start on Linux kernels 6.19 and newer
    (SERVER-121912). Image tags are pinned in
    Stores/ContainerImages.cs.

Testing

dotnet test on the solution: 34 unit tests and 66 integration tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_018pK9kvAcxFsZ3KkYQcEZGP

…nd MongoDB

Adds PTrampert.QueryObjects.Integration.Test, an NUnit project that runs one
shared suite against real databases started with Testcontainers.

ProductQueryTests holds every expectation and is parameterized over an
IProductStore; SqlServerProductQueryTests, PostgreSqlProductQueryTests and
MongoDbProductQueryTests supply the store. The suite covers every query
attribute the library ships with, over string, Guid, bool, int, decimal,
DateTime and collection properties, plus IQueryObject<T> expressions combined
with attribute filters.

The relational fixtures additionally assert, through a command interceptor,
that query values reach the database as SQL parameters and that the same query
shape yields identical SQL for different values, with InlineValue opting out.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018pK9kvAcxFsZ3KkYQcEZGP
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown

✅ PR Title Formatted Correctly

The title of this PR has been updated to match the correct format. Thank you!

@PaulTrampert
PaulTrampert merged commit 2de68bb into main Sep 6, 2026
8 checks passed
@PaulTrampert
PaulTrampert deleted the integration-tests branch September 6, 2026 03:48
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