Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve testing (MSTEST0040 fixed, Csla.Windows.Tests fixed) #4586

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Source/Csla.Windows.Tests/test.runsettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<MSTest>
<Parallelize>
<Scope>ClassLevel</Scope>
</Parallelize>
</MSTest>
</RunSettings>
122 changes: 44 additions & 78 deletions Source/Csla.test/DataPortal/AsynchDataPortalTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,28 +97,19 @@ public async Task CreateAsync_WithCriteria()


[TestMethod]
public void CreateAsync_WithException()
public async Task CreateAsync_WithException()
{
var lck = new AutoResetEvent(false);
new Action(async () =>
{
IDataPortal<Single2> dataPortal = _testDIContext.CreateDataPortal<Single2>();
IDataPortal<Single2> dataPortal = _testDIContext.CreateDataPortal<Single2>();

try
{
var result = await dataPortal.CreateAsync(9999);
Assert.Fail("Expected exception not thrown");
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(DataPortalException));
}
finally
{
lck.Set();
}
}).Invoke();
lck.WaitOne();
try
{
var result = await dataPortal.CreateAsync(9999);
Assert.Fail("Expected exception not thrown");
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(DataPortalException));
}
}

[TestMethod]
Expand Down Expand Up @@ -164,28 +155,19 @@ public async Task FetchAsync_WithCriteria()


[TestMethod]
public void FetchAsync_WithException()
public async Task FetchAsync_WithException()
{
var lck = new AutoResetEvent(false);
new Action(async () =>
{
IDataPortal<Single2> dataPortal = _testDIContext.CreateDataPortal<Single2>();
IDataPortal<Single2> dataPortal = _testDIContext.CreateDataPortal<Single2>();

try
{
var result = await dataPortal.FetchAsync(9999);
Assert.Fail("Expected exception not thrown");
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(DataPortalException));
}
finally
{
lck.Set();
}
}).Invoke();
lck.WaitOne();
try
{
var result = await dataPortal.FetchAsync(9999);
Assert.Fail("Expected exception not thrown");
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(DataPortalException));
}
}

[TestMethod]
Expand Down Expand Up @@ -236,24 +218,17 @@ await context.Assert.Try(async () =>
Assert.AreEqual(555, result.Id);
Assert.IsTrue(result.IsNew);
Assert.IsTrue(result.IsDirty);
var lck = new AutoResetEvent(false);
new Action(async () =>

try
{
result = await result.SaveAsync();
Assert.Fail("Expected exception not thrown");
}
catch (Exception ex)
{
try
{
result = await result.SaveAsync();
Assert.Fail("Expected exception not thrown");
}
catch (Exception ex)
{
context.Assert.IsTrue(ex.GetType() == typeof(DataPortalException));
}
finally
{
lck.Set();
}
}).Invoke();
lck.WaitOne();
context.Assert.IsTrue(ex.GetType() == typeof(DataPortalException));
}

context.Assert.Success();
});
context.Complete();
Expand Down Expand Up @@ -285,29 +260,20 @@ public async Task ExecuteAsync()
}

[TestMethod]
public void ExecuteAsyncWithException()
public async Task ExecuteAsyncWithException()
{
var lck = new AutoResetEvent(false);
new Action(async () =>
{
IDataPortal<SingleCommand> dataPortal = _testDIContext.CreateDataPortal<SingleCommand>();
IDataPortal<SingleCommand> dataPortal = _testDIContext.CreateDataPortal<SingleCommand>();

try
{
var cmd = dataPortal.Create(555);
var result = await dataPortal.ExecuteAsync(cmd);
Assert.Fail("Expected exception not thrown");
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(DataPortalException));
}
finally
{
lck.Set();
}
}).Invoke();
lck.WaitOne();
try
{
var cmd = dataPortal.Create(555);
var result = await dataPortal.ExecuteAsync(cmd);
Assert.Fail("Expected exception not thrown");
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(DataPortalException));
}
}
#endregion

Expand Down
Loading