5
5
using CommunityToolkit . Datasync . Server . EntityFrameworkCore ;
6
6
using CommunityToolkit . Datasync . Server . Test . Helpers ;
7
7
using CommunityToolkit . Datasync . TestCommon . Databases ;
8
+ using CommunityToolkit . Datasync . TestCommon . Fixtures ;
8
9
using Microsoft . EntityFrameworkCore ;
9
10
using Xunit . Abstractions ;
10
11
11
12
namespace CommunityToolkit . Datasync . Server . Test . Live ;
12
13
13
14
[ ExcludeFromCodeCoverage ]
14
15
[ Collection ( "LiveTestsCollection" ) ]
15
- public class PgSQL_Controller_Tests ( DatabaseFixture fixture , ITestOutputHelper output ) : LiveControllerTests < PgEntityMovie > , IAsyncLifetime
16
+ public class PgSQL_Controller_Tests ( PostgreSqlDatabaseFixture fixture , ITestOutputHelper output ) : LiveControllerTests < PgEntityMovie > , IClassFixture < PostgreSqlDatabaseFixture > , IAsyncLifetime
16
17
{
17
18
#region Setup
18
19
private readonly Random random = new ( ) ;
19
20
private List < PgEntityMovie > movies = [ ] ;
20
21
21
22
public async Task InitializeAsync ( )
22
23
{
23
- if ( ! string . IsNullOrEmpty ( ConnectionStrings . PgSql ) )
24
- {
25
- // Note: we don't clear entities on every run to speed up the test runs. This can only be done because
26
- // the tests are read-only (associated with the query and get capabilities). If the test being run writes
27
- // to the database then change clearEntities to true.
28
- output . WriteLine ( $ "PgIsInitialized = { fixture . PgIsInitialized } ") ;
29
- Context = await PgDbContext . CreateContextAsync ( ConnectionStrings . PgSql , output , clearEntities : ! fixture . PgIsInitialized ) ;
30
- this . movies = Context . Movies . AsNoTracking ( ) . ToList ( ) ;
31
- fixture . PgIsInitialized = true ;
32
- }
24
+ Context = await PgDbContext . CreateContextAsync ( fixture . ConnectionString , output ) ;
25
+ this . movies = await Context . Movies . AsNoTracking ( ) . ToListAsync ( ) ;
33
26
}
34
27
35
28
public async Task DisposeAsync ( )
@@ -44,7 +37,7 @@ public async Task DisposeAsync()
44
37
45
38
protected override string DriverName { get ; } = "PgSQL" ;
46
39
47
- protected override bool CanRunLiveTests ( ) => ! string . IsNullOrEmpty ( ConnectionStrings . PgSql ) ;
40
+ protected override bool CanRunLiveTests ( ) => true ;
48
41
49
42
protected override async Task < PgEntityMovie > GetEntityAsync ( string id )
50
43
=> await Context . Movies . AsNoTracking ( ) . SingleOrDefaultAsync ( m => m . Id == id ) ;
0 commit comments