-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from dennisdoomen/EnableMoreAsync
Enable async code blocks on all Given methods
- Loading branch information
Showing
11 changed files
with
125 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
@echo off | ||
powershell -NoProfile -ExecutionPolicy unrestricted -Command ".\Build\psake.ps1 .\Build\default.ps1 | ||
powershell -NoProfile -ExecutionPolicy unrestricted -Command ".\build.ps1" |
7 changes: 5 additions & 2 deletions
7
Source/Core/Chill.Net40.Tests/Chill.Net40.Tests.v2.ncrunchproject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace Chill | ||
{ | ||
internal static class TaskExtensions | ||
{ | ||
public static void WaitAndFlattenExceptions(this Task t) | ||
{ | ||
try | ||
{ | ||
#if NET45 | ||
Task.Run(() => t.Wait()).Wait(); | ||
#else | ||
Task.Factory.StartNew(t.Wait).Wait(); | ||
#endif | ||
} | ||
catch (AggregateException aggregateException) | ||
{ | ||
throw aggregateException.Flatten(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Collections.Concurrent; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Chill.Tests.Shared | ||
{ | ||
namespace AsyncSpecs | ||
{ | ||
public class When_an_async_act_is_used : GivenWhenThen | ||
{ | ||
private BlockingCollection<int> results = new BlockingCollection<int>(); | ||
|
||
public When_an_async_act_is_used() | ||
{ | ||
When(async () => | ||
{ | ||
foreach (int key in Enumerable.Range(0, 1000)) | ||
{ | ||
#if NET45 | ||
await Task.Delay(10); | ||
#else | ||
await TaskEx.Delay(10); | ||
#endif | ||
results.Add(key); | ||
} | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void Then_it_should_evaluate_the_sync_code_synchronously() | ||
{ | ||
results.Should().HaveCount(1000); | ||
} | ||
} | ||
public class When_an_async_arrange_is_used : GivenWhenThen | ||
{ | ||
private BlockingCollection<int> results = new BlockingCollection<int>(); | ||
|
||
public When_an_async_arrange_is_used() | ||
{ | ||
Given(async () => | ||
{ | ||
foreach (int key in Enumerable.Range(0, 1000)) | ||
{ | ||
#if NET45 | ||
await Task.Delay(10); | ||
#else | ||
await TaskEx.Delay(10); | ||
#endif | ||
results.Add(key); | ||
} | ||
}); | ||
} | ||
|
||
[Fact] | ||
public void Then_it_should_evaluate_the_sync_code_synchronously() | ||
{ | ||
results.Should().HaveCount(1000); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters