9
9
using UnitTests ;
10
10
using ConfigurationProvider = SqlServer . Connector . Tests . Config . ConfigurationProvider ;
11
11
12
- namespace SqlServer . Connector . Tests . Cdc
12
+ namespace SqlServer . Connector . Tests . Cdc ;
13
+
14
+ [ TestClass ]
15
+ [ TestCategory ( "Integration" ) ]
16
+ public class CdcClientTests : TestBase < CdcClient >
13
17
{
14
- [ TestClass ]
15
- [ TestCategory ( "Integration" ) ]
16
- public class CdcClientTests : TestBase < CdcClient >
18
+ [ ClassInitialize ]
19
+ public static async Task ClassInitialize ( TestContext context )
17
20
{
18
- [ ClassInitialize ]
19
- public static async Task ClassInitialize ( TestContext context )
20
- {
21
- var dbContext = new ApplicationDbContext ( ) ;
21
+ var dbContext = new ApplicationDbContext ( ) ;
22
22
23
- await dbContext . Database . EnsureDeletedAsync ( ) ;
23
+ await dbContext . Database . EnsureDeletedAsync ( ) ;
24
24
25
- await dbContext . Database . MigrateAsync ( ) ;
26
- }
25
+ await dbContext . Database . MigrateAsync ( ) ;
26
+ }
27
27
28
- private static readonly IConfiguration Configuration = ConfigurationProvider . CreateConfiguration ( ) ;
28
+ private static readonly IConfiguration Configuration = ConfigurationProvider . CreateConfiguration ( ) ;
29
29
30
- [ ClassCleanup ]
31
- public static async Task ClassCleanup ( )
32
- {
33
- var dbContext = new ApplicationDbContext ( ) ;
30
+ [ ClassCleanup ]
31
+ public static async Task ClassCleanup ( )
32
+ {
33
+ var dbContext = new ApplicationDbContext ( ) ;
34
34
35
- await dbContext . Database . EnsureDeletedAsync ( ) ;
36
- }
35
+ await dbContext . Database . EnsureDeletedAsync ( ) ;
36
+ }
37
37
38
- static string ConnectionString => Configuration . GetConnectionString ( "DefaultConnection" ) ;
38
+ static string ConnectionString => Configuration . GetConnectionString ( "DefaultConnection" ) ;
39
39
40
- readonly SqlConnectionStringBuilder connectionStringBuilder = new ( ConnectionString ) ;
40
+ readonly SqlConnectionStringBuilder connectionStringBuilder = new ( ConnectionString ) ;
41
41
42
- [ TestInitialize ]
43
- public override void TestInitialize ( )
44
- {
45
- base . TestInitialize ( ) ;
42
+ [ TestInitialize ]
43
+ public override void TestInitialize ( )
44
+ {
45
+ base . TestInitialize ( ) ;
46
46
47
- ClassUnderTest = new CdcClient ( ConnectionString ) ;
48
- }
47
+ ClassUnderTest = new CdcClient ( ConnectionString ) ;
48
+ }
49
49
50
- [ TestMethod ]
51
- public async Task CdcEnableDbAsync ( )
52
- {
53
- //Arrange
54
- string databaseName = connectionStringBuilder . InitialCatalog ;
50
+ [ TestMethod ]
51
+ public async Task CdcEnableDbAsync ( )
52
+ {
53
+ //Arrange
54
+ string databaseName = connectionStringBuilder . InitialCatalog ;
55
55
56
- //Act
57
- await ClassUnderTest . CdcEnableDbAsync ( ) ;
56
+ //Act
57
+ await ClassUnderTest . CdcEnableDbAsync ( ) ;
58
58
59
- var isEnabled = await ClassUnderTest . IsCdcDbEnabledAsync ( databaseName ) ;
59
+ var isEnabled = await ClassUnderTest . IsCdcDbEnabledAsync ( databaseName ) ;
60
60
61
- //Assert
62
- isEnabled . Should ( ) . Be ( true ) ;
63
- }
61
+ //Assert
62
+ isEnabled . Should ( ) . Be ( true ) ;
63
+ }
64
64
65
- [ TestMethod ]
66
- public async Task CdcEnableTableAsync ( )
67
- {
68
- //Arrange
65
+ [ TestMethod ]
66
+ public async Task CdcEnableTableAsync ( )
67
+ {
68
+ //Arrange
69
69
70
- //Act
71
- await ClassUnderTest . CdcEnableTableAsync ( tableName ) ;
70
+ //Act
71
+ await ClassUnderTest . CdcEnableTableAsync ( tableName ) ;
72
72
73
- var isEnabled = await ClassUnderTest . IsCdcTableEnabledAsync ( tableName ) ;
73
+ var isEnabled = await ClassUnderTest . IsCdcTableEnabledAsync ( tableName ) ;
74
74
75
- //Assert
76
- isEnabled . Should ( ) . Be ( true ) ;
77
- }
75
+ //Assert
76
+ isEnabled . Should ( ) . Be ( true ) ;
77
+ }
78
78
79
- string tableName = "Sensors" ;
79
+ string tableName = "Sensors" ;
80
80
81
- [ TestMethod ]
82
- public async Task CdcEnableTableAsync_CdcEnableTableInput ( )
83
- {
84
- //Arrange
85
- string captureInstance = $ "dbo_{ tableName } _v2";
81
+ [ TestMethod ]
82
+ public async Task CdcEnableTableAsync_CdcEnableTableInput ( )
83
+ {
84
+ //Arrange
85
+ string captureInstance = $ "dbo_{ tableName } _v2";
86
86
87
- var cdcEnableTable = new CdcEnableTable ( tableName )
88
- {
89
- CaptureInstance = captureInstance
90
- } ;
87
+ var cdcEnableTable = new CdcEnableTable ( tableName )
88
+ {
89
+ CaptureInstance = captureInstance
90
+ } ;
91
91
92
- //Act
93
- await ClassUnderTest . CdcEnableTableAsync ( cdcEnableTable ) ;
92
+ //Act
93
+ await ClassUnderTest . CdcEnableTableAsync ( cdcEnableTable ) ;
94
94
95
- var isEnabled = await ClassUnderTest . IsCdcTableEnabledAsync ( tableName , captureInstance : captureInstance ) ;
95
+ var isEnabled = await ClassUnderTest . IsCdcTableEnabledAsync ( tableName , captureInstance : captureInstance ) ;
96
96
97
- //Assert
98
- isEnabled . Should ( ) . Be ( true ) ;
99
- }
97
+ //Assert
98
+ isEnabled . Should ( ) . Be ( true ) ;
99
+ }
100
100
101
- [ TestMethod ]
102
- public async Task CdcDisableTableAsync_CaptureInstance ( )
103
- {
104
- //Arrange
105
- string captureInstance = $ "dbo_{ tableName } _v2";
101
+ [ TestMethod ]
102
+ public async Task CdcDisableTableAsync_CaptureInstance ( )
103
+ {
104
+ //Arrange
105
+ string captureInstance = $ "dbo_{ tableName } _v2";
106
106
107
- //Act
108
- await ClassUnderTest . CdcDisableTableAsync ( tableName , captureInstance : captureInstance ) ;
107
+ //Act
108
+ await ClassUnderTest . CdcDisableTableAsync ( tableName , captureInstance : captureInstance ) ;
109
109
110
- var isEnabled = await ClassUnderTest . IsCdcTableEnabledAsync ( tableName , captureInstance : captureInstance ) ;
110
+ var isEnabled = await ClassUnderTest . IsCdcTableEnabledAsync ( tableName , captureInstance : captureInstance ) ;
111
111
112
- //Assert
113
- isEnabled . Should ( ) . Be ( false ) ;
114
- }
112
+ //Assert
113
+ isEnabled . Should ( ) . Be ( false ) ;
114
+ }
115
115
116
- [ TestMethod ]
117
- public async Task CdcDisableTableAsync ( )
118
- {
119
- //Arrange
116
+ [ TestMethod ]
117
+ public async Task CdcDisableTableAsync ( )
118
+ {
119
+ //Arrange
120
120
121
- //Act
122
- await ClassUnderTest . CdcDisableTableAsync ( tableName ) ;
121
+ //Act
122
+ await ClassUnderTest . CdcDisableTableAsync ( tableName ) ;
123
123
124
- var isEnabled = await ClassUnderTest . IsCdcTableEnabledAsync ( tableName ) ;
124
+ var isEnabled = await ClassUnderTest . IsCdcTableEnabledAsync ( tableName ) ;
125
125
126
- //Assert
127
- isEnabled . Should ( ) . Be ( false ) ;
128
- }
126
+ //Assert
127
+ isEnabled . Should ( ) . Be ( false ) ;
128
+ }
129
129
130
- [ TestMethod ]
131
- public async Task CdcDisableDbAsync ( )
132
- {
133
- //Arrange
134
- string databaseName = connectionStringBuilder . InitialCatalog ;
130
+ [ TestMethod ]
131
+ public async Task CdcDisableDbAsync ( )
132
+ {
133
+ //Arrange
134
+ string databaseName = connectionStringBuilder . InitialCatalog ;
135
135
136
- //Act
137
- await ClassUnderTest . CdcDisableDbAsync ( ) ;
136
+ //Act
137
+ await ClassUnderTest . CdcDisableDbAsync ( ) ;
138
138
139
- //Assert
139
+ //Assert
140
140
141
- var isEnabled = await ClassUnderTest . IsCdcDbEnabledAsync ( databaseName ) ;
141
+ var isEnabled = await ClassUnderTest . IsCdcDbEnabledAsync ( databaseName ) ;
142
142
143
- //Assert
144
- isEnabled . Should ( ) . Be ( false ) ;
145
- }
143
+ //Assert
144
+ isEnabled . Should ( ) . Be ( false ) ;
146
145
}
147
146
}
0 commit comments