Skip to content

Commit bc4bb00

Browse files
Address MSTEST0040 warnings
Fixes Csla.Windows.Tests project which can't be executed due to a missing test.runsettings-file.
1 parent 634459e commit bc4bb00

File tree

2 files changed

+52
-78
lines changed

2 files changed

+52
-78
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RunSettings>
3+
<MSTest>
4+
<Parallelize>
5+
<Scope>ClassLevel</Scope>
6+
</Parallelize>
7+
</MSTest>
8+
</RunSettings>

Source/Csla.test/DataPortal/AsynchDataPortalTest.cs

+44-78
Original file line numberDiff line numberDiff line change
@@ -97,28 +97,19 @@ public async Task CreateAsync_WithCriteria()
9797

9898

9999
[TestMethod]
100-
public void CreateAsync_WithException()
100+
public async Task CreateAsync_WithException()
101101
{
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>();
106103

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+
}
122113
}
123114

124115
[TestMethod]
@@ -164,28 +155,19 @@ public async Task FetchAsync_WithCriteria()
164155

165156

166157
[TestMethod]
167-
public void FetchAsync_WithException()
158+
public async Task FetchAsync_WithException()
168159
{
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>();
173161

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+
}
189171
}
190172

191173
[TestMethod]
@@ -236,24 +218,17 @@ await context.Assert.Try(async () =>
236218
Assert.AreEqual(555, result.Id);
237219
Assert.IsTrue(result.IsNew);
238220
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)
241228
{
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+
257232
context.Assert.Success();
258233
});
259234
context.Complete();
@@ -285,29 +260,20 @@ public async Task ExecuteAsync()
285260
}
286261

287262
[TestMethod]
288-
public void ExecuteAsyncWithException()
263+
public async Task ExecuteAsyncWithException()
289264
{
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>();
294266

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+
}
311277
}
312278
#endregion
313279

0 commit comments

Comments
 (0)