Created
June 11, 2014 13:21
-
-
Save renestein/f9061d41a0d0d8d91164 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[TestMethod] | |
public async Task WithTaskFactory_When_One_Task_Is_Queued_Then_Task_is_Executed() | |
{ | |
bool wasTaskExecuted = false; | |
await TestTaskFactory.StartNew(() => wasTaskExecuted = true); | |
Assert.IsTrue(wasTaskExecuted); | |
} | |
[TestMethod] | |
public async Task WithTaskFactory_When_Tasks_Are_Queued_Then_All_Tasks_Are_Executed() | |
{ | |
const int NUMBER_OF_TASKS = 8096; | |
int numberOfTasksExecuted = 0; | |
var tasks = Enumerable.Range(0, NUMBER_OF_TASKS) | |
.Select(_ => TestTaskFactory.StartNew(() => Interlocked.Increment(ref numberOfTasksExecuted))).ToArray(); | |
await Task.WhenAll(tasks); | |
Assert.AreEqual(NUMBER_OF_TASKS, numberOfTasksExecuted); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment