Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test fixup #25102

Merged
1 commit merged into from
Jun 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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