Skip to content

Cosmos: OwnedQueryCosmosTest seed null collection instead of an empty list #34011

@roji

Description

@roji

OwnedQueryTestBase has some test data that includes empty collections of owned entity types:

var order2 = new Order
{
    Id = -11,
    Client = ownedPerson1,
    ["OrderDate"] = Convert.ToDateTime("2015-03-03 04:37:59"),
    Details = []
};

Interestingly, the Cosmos implementation (OwnedQueryCosmosTest) doesn't use the test data, but rather uses HasData() to seed the test data:

ob.OwnsMany(
    e => e.Details, odb =>
    {
        odb.HasData(
            new
            {
                Id = -100,
                OrderId = -10,
                OrderClientId = 1,
                Detail = "Discounted Order"
            },

This means that the test data is duplicated and can diverge, which isn't great. But regardless, for orders which have no Details, the JSON document in the database ends up with a null collection, rather than an empty one. As a result, tests such as Where_owned_collection_navigation_ToList_Count fail, since they check for a list length of zero.

Note that this is probably not just a test problem - it may be impossible to use HasData() to seed empty collections of entity types at the moment.

/cc @AndriySvyryd (not critical)

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions