Repository: dotnet/efcore
File: test/EFCore.Relational.Specification.Tests/Update/ComplexCollectionJsonUpdateTestBase.cs (C#)

Code before:
    [ConditionalFact]
    public virtual Task Remove_element_from_complex_collection_mapped_to_json()
        => TestHelpers.ExecuteWithStrategyInTransactionAsync(
            CreateContext,
            UseTransaction,
            async context =>
            {
                var company = await context.Companies.OrderBy(c => c.Id).FirstAsync();

                company.Contacts!.RemoveAt(0);

                ClearLog();
                await context.SaveChangesAsync();
            },
            async context =>
            {
                using (SuspendRecordingEvents())
                {
                    var company = await context.Companies.OrderBy(c => c.Id).FirstAsync();
                    Assert.Single(company.Contacts!);
                    Assert.Equal("Second Contact", company.Contacts![0].Name);
                }
            });

    [ConditionalFact]
    public virtual Task Remove_element_from_complex_collection_using_Where_with_nested_array()
        => TestHelpers.ExecuteWithStrategyInTransactionAsync(
            CreateContext,
            UseTransaction,
            async context =>
            {
                var company = new CompanyWithNestedComplexCollections
                {
                    Id = 100,
                    Name = "Test Company",
                    Items =
                    [
                        new ItemWithNestedCollection
                        {
                            Id = 1,
                            Name = "Item1",
                            SubItems = []
                        }
                    ]
                };

                context.Add(company);
                await context.SaveChangesAsync();
            },
            async context =>
            {

Review comment (suggestion):
@copilot Add a series of tests to ComplexTypesTrackingTestBase targeting this scenario, following the pattern of tests against different classes by using a common test implementation method.

Code after:
    [ConditionalFact]
    public virtual Task Remove_element_from_complex_collection_mapped_to_json()
        => TestHelpers.ExecuteWithStrategyInTransactionAsync(
            CreateContext,
            UseTransaction,
            async context =>
            {
                var company = await context.Companies.OrderBy(c => c.Id).FirstAsync();

                company.Contacts!.RemoveAt(0);

                ClearLog();
                await context.SaveChangesAsync();
            },
            async context =>
            {
                using (SuspendRecordingEvents())
                {
                    var company = await context.Companies.OrderBy(c => c.Id).FirstAsync();
                    Assert.Single(company.Contacts!);
                    Assert.Equal("Second Contact", company.Contacts![0].Name);
                }
            });

    [ConditionalFact]
    public virtual Task Delete_complex_collection_owner_entity_mapped_to_json()
        => TestHelpers.ExecuteWithStrategyInTransactionAsync(
            CreateContext,
            UseTransaction,
            async context =>
            {
                var company = await context.Companies.SingleAsync(c => c.Id == 1);

                context.Remove(company);

                ClearLog();

                await context.SaveChangesAsync();
            },
            async context =>
            {
                using (SuspendRecordingEvents())
                {
                    var exists = await context.Companies.AnyAsync(c => c.Id == 1);
                    Assert.False(exists);
                }
            });

    [ConditionalFact]
    public virtual Task Modify_element_in_complex_collection_mapped_to_json()
        => TestHelpers.ExecuteWithStrategyInTransactionAsync(