-
Notifications
You must be signed in to change notification settings - Fork 259
Expand file tree
/
Copy pathConnectionInterceptionNpgsqlTest.cs
More file actions
100 lines (78 loc) · 3.87 KB
/
ConnectionInterceptionNpgsqlTest.cs
File metadata and controls
100 lines (78 loc) · 3.87 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System.Data;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
namespace Microsoft.EntityFrameworkCore;
public abstract class ConnectionInterceptionNpgsqlTestBase(ConnectionInterceptionNpgsqlTestBase.InterceptionNpgsqlFixtureBase fixture)
: ConnectionInterceptionTestBase(fixture)
{
[ActiveIssue("#2368")]
public override Task Intercept_connection_creation_passively(bool async)
=> base.Intercept_connection_creation_passively(async);
[ActiveIssue("#2368")]
public override Task Intercept_connection_creation_with_multiple_interceptors(bool async)
=> base.Intercept_connection_creation_with_multiple_interceptors(async);
[ActiveIssue("#2368")]
public override Task Intercept_connection_to_override_connection_after_creation(bool async)
=> base.Intercept_connection_to_override_connection_after_creation(async);
[ActiveIssue("#2368")]
public override Task Intercept_connection_to_override_creation(bool async)
=> base.Intercept_connection_to_override_creation(async);
public abstract class InterceptionNpgsqlFixtureBase : InterceptionFixtureBase
{
protected override string StoreName
=> "ConnectionInterception";
protected override ITestStoreFactory TestStoreFactory
=> NpgsqlTestStoreFactory.Instance;
protected override IServiceCollection InjectInterceptors(
IServiceCollection serviceCollection,
IEnumerable<IInterceptor> injectedInterceptors)
=> base.InjectInterceptors(serviceCollection.AddEntityFrameworkNpgsql(), injectedInterceptors);
}
protected override DbContextOptionsBuilder ConfigureProvider(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql();
protected override BadUniverseContext CreateBadUniverse(DbContextOptionsBuilder optionsBuilder)
=> new(optionsBuilder.UseNpgsql(new FakeDbConnection()).Options);
public class FakeDbConnection : DbConnection
{
[AllowNull]
public override string ConnectionString { get; set; }
public override string Database
=> "Database";
public override string DataSource
=> "DataSource";
public override string ServerVersion
=> throw new NotImplementedException();
public override ConnectionState State
=> ConnectionState.Closed;
public override void ChangeDatabase(string databaseName)
=> throw new NotImplementedException();
public override void Close()
=> throw new NotImplementedException();
public override void Open()
=> throw new NotImplementedException();
protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
=> throw new NotImplementedException();
protected override DbCommand CreateDbCommand()
=> throw new NotImplementedException();
}
public class ConnectionInterceptionNpgsqlTest(ConnectionInterceptionNpgsqlTest.InterceptionNpgsqlFixture fixture)
: ConnectionInterceptionNpgsqlTestBase(fixture), IClassFixture<ConnectionInterceptionNpgsqlTest.InterceptionNpgsqlFixture>
{
public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase
{
protected override bool ShouldSubscribeToDiagnosticListener
=> false;
}
}
public class ConnectionInterceptionWithDiagnosticsNpgsqlTest(
ConnectionInterceptionWithDiagnosticsNpgsqlTest.InterceptionNpgsqlFixture fixture)
: ConnectionInterceptionNpgsqlTestBase(fixture),
IClassFixture<ConnectionInterceptionWithDiagnosticsNpgsqlTest.InterceptionNpgsqlFixture>
{
public class InterceptionNpgsqlFixture : InterceptionNpgsqlFixtureBase
{
protected override bool ShouldSubscribeToDiagnosticListener
=> true;
}
}
}