-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
TransactionSqliteTest.cs
43 lines (34 loc) · 1.68 KB
/
TransactionSqliteTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Microsoft.EntityFrameworkCore;
#nullable disable
public class TransactionSqliteTest(TransactionSqliteTest.TransactionSqliteFixture fixture)
: TransactionTestBase<TransactionSqliteTest.TransactionSqliteFixture>(fixture)
{
protected override bool SnapshotSupported
=> false;
protected override DbContext CreateContextWithConnectionString()
{
var options = Fixture.AddOptions(
new DbContextOptionsBuilder().UseSqlite(TestStore.ConnectionString)
.ConfigureWarnings(w => w.Log(RelationalEventId.AmbientTransactionWarning)))
.UseInternalServiceProvider(Fixture.ServiceProvider);
return new DbContext(options.Options);
}
public class TransactionSqliteFixture : TransactionFixtureBase
{
protected override ITestStoreFactory TestStoreFactory
=> SharedCacheSqliteTestStoreFactory.Instance;
public override async Task ReseedAsync()
{
using var context = CreateContext();
context.Set<TransactionCustomer>().RemoveRange(await context.Set<TransactionCustomer>().ToListAsync());
context.Set<TransactionOrder>().RemoveRange(await context.Set<TransactionOrder>().ToListAsync());
await context.SaveChangesAsync();
await SeedAsync(context);
}
public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder)
=> base.AddOptions(builder)
.ConfigureWarnings(w => w.Log(RelationalEventId.AmbientTransactionWarning));
}
}