Skip to content

Commit

Permalink
Test fixup (#25102)
Browse files Browse the repository at this point in the history
Follow-up to #25086
  • Loading branch information
roji authored Jun 15, 2021
1 parent c6243d8 commit d342614
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions test/EFCore.SqlServer.FunctionalTests/DbContextPoolingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -731,27 +731,24 @@ public async Task Uninitialized_context_configuration_is_reset_properly(bool asy
{
var serviceProvider = BuildServiceProvider<SecondContext>();

DbContext ctx;
using (var scope = serviceProvider.CreateScope())
using (var ctx1 = scope.ServiceProvider.GetRequiredService<SecondContext>())
{
await ctx1.DisposeAsync();
ctx = ctx1;
}
var serviceScope = serviceProvider.CreateScope();
var ctx = serviceScope.ServiceProvider.GetRequiredService<SecondContext>();
await Dispose(ctx, async);
await Dispose(serviceScope, async);

using (var scope = serviceProvider.CreateScope())
using (var ctx2 = scope.ServiceProvider.GetRequiredService<SecondContext>())
{
Assert.Same(ctx, ctx2);
ctx2.Blogs.Add(new SecondContext.Blog());
}
serviceScope = serviceProvider.CreateScope();
var ctx2 = serviceScope.ServiceProvider.GetRequiredService<SecondContext>();
Assert.Same(ctx, ctx2);
ctx2.Blogs.Add(new SecondContext.Blog());
await Dispose(ctx2, async);
await Dispose(serviceScope, async);

using (var scope = serviceProvider.CreateScope())
using (var ctx3 = scope.ServiceProvider.GetRequiredService<SecondContext>())
{
Assert.Same(ctx, ctx3);
Assert.Empty(ctx3.ChangeTracker.Entries());
}
serviceScope = serviceProvider.CreateScope();
var ctx3 = serviceScope.ServiceProvider.GetRequiredService<SecondContext>();
Assert.Same(ctx, ctx3);
Assert.Empty(ctx3.ChangeTracker.Entries());
await Dispose(ctx2, async);
await Dispose(serviceScope, async);
}

[ConditionalTheory]
Expand Down

0 comments on commit d342614

Please sign in to comment.