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