dotnet / dotnet/efcore

Evolve per-type testing

Open
#33,521 2 comments 0 reactions 0 assignees View on GitHub
area-json area-query area-save-changes area-test
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

#30981 shows that we're currently lacking test coverage for querying types within JSON. Our testing for specific database types is spread out across various places:

* BuiltInDataTypesTestBase: basic type testing support. Uses a single model, so quite difficult (even if possible) to extend for extra types beyond the initial closed list.
* JsonTypesTestBase: serialization/deserialization within JSON only - both scalars and collections - but not end-to-end (uses JsonValueReaderWriter), and no querying.
* JsonQueryTestBase: JSON querying tests, including query testing for a closed list of types (so not easily extensible by providers)
* JsonUpdateTestBase: JSON update tests, for the same closed list of types.

Ideally, we'd have one ad-hoc test suite, with infra to perform **all** testing for a given database type via a single test; the test would dynamically build an ad-hoc model with a regular column of the type, a JSON document with a scalar of the type, and a collection of the type; and it would exercise serialization, deserialization and querying of all of the above. The test class would contain testing for a basic type list, but providers would be able to easily call the same test infra method for their own arbitrary types. Opt outs would allow not testing specific aspects - like JSON serialization - where that happens to not be supported etc.

For inspiration, see the AssertType() infra in Npgsql ([code](https://github.com/npgsql/npgsql/blob/main/test/Npgsql.Tests/Types/DateTimeTests.cs)), where a single call tests all functionality related to the support of a single type.

Cases to tests;

* [ ] Partial update of scalar property within JSON via SaveChanges.
* [x] Partial update of scalar property within JSON via ExecuteUpdate (done in [#36659](https://github.com/dotnet/efcore/pull/36659)).
* [ ] Mapping via primitive collection, saving, querying...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.