@@ -97,28 +97,19 @@ public async Task CreateAsync_WithCriteria()
97
97
98
98
99
99
[ TestMethod ]
100
- public void CreateAsync_WithException ( )
100
+ public async Task CreateAsync_WithException ( )
101
101
{
102
- var lck = new AutoResetEvent ( false ) ;
103
- new Action ( async ( ) =>
104
- {
105
- IDataPortal < Single2 > dataPortal = _testDIContext . CreateDataPortal < Single2 > ( ) ;
102
+ IDataPortal < Single2 > dataPortal = _testDIContext . CreateDataPortal < Single2 > ( ) ;
106
103
107
- try
108
- {
109
- var result = await dataPortal . CreateAsync ( 9999 ) ;
110
- Assert . Fail ( "Expected exception not thrown" ) ;
111
- }
112
- catch ( Exception ex )
113
- {
114
- Assert . IsInstanceOfType ( ex , typeof ( DataPortalException ) ) ;
115
- }
116
- finally
117
- {
118
- lck . Set ( ) ;
119
- }
120
- } ) . Invoke ( ) ;
121
- lck . WaitOne ( ) ;
104
+ try
105
+ {
106
+ var result = await dataPortal . CreateAsync ( 9999 ) ;
107
+ Assert . Fail ( "Expected exception not thrown" ) ;
108
+ }
109
+ catch ( Exception ex )
110
+ {
111
+ Assert . IsInstanceOfType ( ex , typeof ( DataPortalException ) ) ;
112
+ }
122
113
}
123
114
124
115
[ TestMethod ]
@@ -164,28 +155,19 @@ public async Task FetchAsync_WithCriteria()
164
155
165
156
166
157
[ TestMethod ]
167
- public void FetchAsync_WithException ( )
158
+ public async Task FetchAsync_WithException ( )
168
159
{
169
- var lck = new AutoResetEvent ( false ) ;
170
- new Action ( async ( ) =>
171
- {
172
- IDataPortal < Single2 > dataPortal = _testDIContext . CreateDataPortal < Single2 > ( ) ;
160
+ IDataPortal < Single2 > dataPortal = _testDIContext . CreateDataPortal < Single2 > ( ) ;
173
161
174
- try
175
- {
176
- var result = await dataPortal . FetchAsync ( 9999 ) ;
177
- Assert . Fail ( "Expected exception not thrown" ) ;
178
- }
179
- catch ( Exception ex )
180
- {
181
- Assert . IsInstanceOfType ( ex , typeof ( DataPortalException ) ) ;
182
- }
183
- finally
184
- {
185
- lck . Set ( ) ;
186
- }
187
- } ) . Invoke ( ) ;
188
- lck . WaitOne ( ) ;
162
+ try
163
+ {
164
+ var result = await dataPortal . FetchAsync ( 9999 ) ;
165
+ Assert . Fail ( "Expected exception not thrown" ) ;
166
+ }
167
+ catch ( Exception ex )
168
+ {
169
+ Assert . IsInstanceOfType ( ex , typeof ( DataPortalException ) ) ;
170
+ }
189
171
}
190
172
191
173
[ TestMethod ]
@@ -236,24 +218,17 @@ await context.Assert.Try(async () =>
236
218
Assert . AreEqual ( 555 , result . Id ) ;
237
219
Assert . IsTrue ( result . IsNew ) ;
238
220
Assert . IsTrue ( result . IsDirty ) ;
239
- var lck = new AutoResetEvent ( false ) ;
240
- new Action ( async ( ) =>
221
+
222
+ try
223
+ {
224
+ result = await result . SaveAsync ( ) ;
225
+ Assert . Fail ( "Expected exception not thrown" ) ;
226
+ }
227
+ catch ( Exception ex )
241
228
{
242
- try
243
- {
244
- result = await result . SaveAsync ( ) ;
245
- Assert . Fail ( "Expected exception not thrown" ) ;
246
- }
247
- catch ( Exception ex )
248
- {
249
- context . Assert . IsTrue ( ex . GetType ( ) == typeof ( DataPortalException ) ) ;
250
- }
251
- finally
252
- {
253
- lck . Set ( ) ;
254
- }
255
- } ) . Invoke ( ) ;
256
- lck . WaitOne ( ) ;
229
+ context . Assert . IsTrue ( ex . GetType ( ) == typeof ( DataPortalException ) ) ;
230
+ }
231
+
257
232
context . Assert . Success ( ) ;
258
233
} ) ;
259
234
context . Complete ( ) ;
@@ -285,29 +260,20 @@ public async Task ExecuteAsync()
285
260
}
286
261
287
262
[ TestMethod ]
288
- public void ExecuteAsyncWithException ( )
263
+ public async Task ExecuteAsyncWithException ( )
289
264
{
290
- var lck = new AutoResetEvent ( false ) ;
291
- new Action ( async ( ) =>
292
- {
293
- IDataPortal < SingleCommand > dataPortal = _testDIContext . CreateDataPortal < SingleCommand > ( ) ;
265
+ IDataPortal < SingleCommand > dataPortal = _testDIContext . CreateDataPortal < SingleCommand > ( ) ;
294
266
295
- try
296
- {
297
- var cmd = dataPortal . Create ( 555 ) ;
298
- var result = await dataPortal . ExecuteAsync ( cmd ) ;
299
- Assert . Fail ( "Expected exception not thrown" ) ;
300
- }
301
- catch ( Exception ex )
302
- {
303
- Assert . IsInstanceOfType ( ex , typeof ( DataPortalException ) ) ;
304
- }
305
- finally
306
- {
307
- lck . Set ( ) ;
308
- }
309
- } ) . Invoke ( ) ;
310
- lck . WaitOne ( ) ;
267
+ try
268
+ {
269
+ var cmd = dataPortal . Create ( 555 ) ;
270
+ var result = await dataPortal . ExecuteAsync ( cmd ) ;
271
+ Assert . Fail ( "Expected exception not thrown" ) ;
272
+ }
273
+ catch ( Exception ex )
274
+ {
275
+ Assert . IsInstanceOfType ( ex , typeof ( DataPortalException ) ) ;
276
+ }
311
277
}
312
278
#endregion
313
279
0 commit comments