Skip to content

Commit

Permalink
Merge branch 'release/9.0-rc1' => 'release/9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriySvyryd authored Aug 18, 2024
2 parents e88fa4a + e914e92 commit b463be2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 4 additions & 5 deletions test/EFCore.Cosmos.FunctionalTests/F1CosmosFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ protected override ITestStoreFactory TestStoreFactory
public override TestHelpers TestHelpers
=> CosmosTestHelpers.Instance;

public override async Task ReseedAsync()
protected override async Task<bool> ShouldSeedAsync(F1Context context)
{
await base.ReseedAsync();

using var context = CreateContext();
try
{
await context.Teams.SingleAsync(t => t.Id == Team.Ferrari);
await base.ShouldSeedAsync(context);
}
catch
{
// Recreating the containers without using CosmosClient causes cached metadata in CosmosClient to be out of sync
// and causes the first query to fail. This is a workaround for that.
}

return await base.ShouldSeedAsync(context);
}

public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
Expand Down
10 changes: 8 additions & 2 deletions test/EFCore.Specification.Tests/F1FixtureBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
.UseModel(CreateModelExternal())
.UseSeeding((c, _) =>
{
if (c.Set<EngineSupplier>().Count() != 0)
if (!ShouldSeed((F1Context)c))
{
return;
}
Expand All @@ -29,7 +29,7 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
})
.UseAsyncSeeding(async (c, _, t) =>
{
if (await c.Set<EngineSupplier>().CountAsync(t) != 0)
if (!await ShouldSeedAsync((F1Context)c))
{
return;
}
Expand All @@ -40,6 +40,12 @@ public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder build
.ConfigureWarnings(
w => w.Ignore(CoreEventId.SaveChangesStarting, CoreEventId.SaveChangesCompleted));

protected virtual bool ShouldSeed(F1Context context)
=> context.EngineSuppliers.Count() == 0;

protected virtual async Task<bool> ShouldSeedAsync(F1Context context)
=> await context.EngineSuppliers.CountAsync() == 0;

protected override IServiceCollection AddServices(IServiceCollection serviceCollection)
=> base.AddServices(serviceCollection.AddSingleton<ISingletonInterceptor, F1MaterializationInterceptor>());

Expand Down

0 comments on commit b463be2

Please sign in to comment.