(PATCH): Add integration tests for EF Core (SQL Server, PostgreSQL) and MongoDB - #69
Merged
Merged
Conversation
…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
✅ PR Title Formatted CorrectlyThe title of this PR has been updated to match the correct format. Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
PTrampert.QueryObjects.Integration.Test, an NUnit project that proves query objects translate and executeagainst real databases rather than only against LINQ-to-Objects.
One suite, three databases
ProductQueryTestsholds every expectation and is parameterized over anIProductStore. Three fixtures supply thestore, so the same 20 cases run against each:
SqlServerProductQueryTestsSqlServermcr.microsoft.com/mssql/server:2022-latestPostgreSqlProductQueryTestsPostgreSqlpostgres:17-alpineMongoDbProductQueryTestsMongoDbmongo:8.2Containers come from Testcontainers, one per fixture, started in
[OneTimeSetUp]. Fixtures run in parallel so thestartups overlap.
Coverage
A single
ProductQueryexercises every shipped attribute —EqualsQuery,NotEqualsQuery, the four comparisonattributes,
StringContainsQuery,StringStartsWithQuery,AnyOfQuery,NoneOfQueryandContainsQuery— overstring,Guid,bool,int,decimal,DateTimeandList<string>properties. There are also cases for anempty query object, a query with no matches, multiple criteria combined, and an
IQueryObject<T>expression combinedwith 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 thatAnyOfQuery/NoneOfQuerybuild for a collection target.Parameterization
EfCoreProductQueryTestsadds three relational-only cases that verify the behaviour introduced in #68 end to end. ADbCommandInterceptorcaptures the command as sent, and the tests assert that query values arrive as SQL parametersrather than literals, that the same query shape produces byte-identical SQL for different values, and that
InlineValue = trueembeds the literal and sends no parameters.Notes
dotnet test <sln>picks it up. That means PR builds nowneed 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.2rather than8.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 teston the solution: 34 unit tests and 66 integration tests pass.🤖 Generated with Claude Code
https://claude.ai/code/session_018pK9kvAcxFsZ3KkYQcEZGP