@@ -20,28 +20,22 @@ sealed class DatabaseUtils
20
20
[ BeforeTestRun ( Order = - 1 ) ]
21
21
public static async Task CreateNLogDatabaseIfNotExists ( )
22
22
{
23
- await using ( var conn = new SqlConnection ( DatabaseConnectionString ) )
24
- {
25
- await conn . OpenAsync ( ) ;
26
- await using ( var cmd = new SqlCommand ( $ "IF (db_id(N'Logs') IS NULL) BEGIN CREATE DATABASE [Logs] END;", conn ) )
27
- {
28
- await cmd . ExecuteNonQueryAsync ( ) ;
29
- }
30
- }
23
+ await using var conn = new SqlConnection ( DatabaseConnectionString ) ;
24
+ await conn . OpenAsync ( ) ;
25
+ await using var cmd = new SqlCommand ( $ "IF (db_id(N'Logs') IS NULL) BEGIN CREATE DATABASE [Logs] END;", conn ) ;
26
+ await cmd . ExecuteNonQueryAsync ( ) ;
31
27
}
32
28
33
29
[ BeforeTestRun ( Order = - 1 ) ]
34
30
public static void DeployDB ( )
35
31
{
36
32
var instance = new DacServices ( DatabaseConnectionString ) ;
37
- using ( var dacpac = DacPackage . Load ( "Ark.Reference.Core.Database.dacpac" ) )
33
+ using var dacpac = DacPackage . Load ( "Ark.Reference.Core.Database.dacpac" ) ;
34
+ instance . Deploy ( dacpac , "Ark.Reference.Core.Database" , true , new DacDeployOptions ( )
38
35
{
39
- instance . Deploy ( dacpac , "Ark.Reference.Core.Database" , true , new DacDeployOptions ( )
40
- {
41
- CreateNewDatabase = true ,
42
- AllowIncompatiblePlatform = true // needed since Database project is AzureV12 and under tests 2022 is used
43
- } ) ;
44
- }
36
+ CreateNewDatabase = true ,
37
+ AllowIncompatiblePlatform = true // needed since Database project is AzureV12 and under tests 2022 is used
38
+ } ) ;
45
39
}
46
40
47
41
[ BeforeScenario ]
@@ -59,26 +53,22 @@ public async Task CleanUpEntireDbBeforeScenario(FeatureContext fctx, ScenarioCon
59
53
60
54
private async Task _cleanUpEntireDb ( bool resetProfileCalendar = false )
61
55
{
62
- await using ( var ctx = new SqlConnection ( TestHost . DBConfig . ConnectionString ) )
63
- {
64
- await ctx . OpenAsync ( ) ;
65
- await using ( var tx = await ctx . BeginTransactionAsync ( ) )
66
- {
56
+ await using var ctx = new SqlConnection ( TestHost . DBConfig . ConnectionString ) ;
57
+ await ctx . OpenAsync ( ) ;
58
+ await using var tx = await ctx . BeginTransactionAsync ( ) ;
67
59
68
- await ctx . ExecuteAsync (
69
- @"[ops].[ResetFull_onlyForTesting]" ,
70
- new
71
- {
72
- areYouReallySure = true ,
73
- resetConfig = true ,
74
- } ,
75
- commandType : CommandType . StoredProcedure ,
76
- commandTimeout : 60 ,
77
- transaction : tx ) ;
60
+ await ctx . ExecuteAsync (
61
+ @"[ops].[ResetFull_onlyForTesting]" ,
62
+ new
63
+ {
64
+ areYouReallySure = true ,
65
+ resetConfig = true ,
66
+ } ,
67
+ commandType : CommandType . StoredProcedure ,
68
+ commandTimeout : 60 ,
69
+ transaction : tx ) ;
78
70
79
- await tx . CommitAsync ( ) ;
80
- }
81
- }
71
+ await tx . CommitAsync ( ) ;
82
72
}
83
73
}
84
74
}
0 commit comments