Created
June 2, 2014 14:24
-
-
Save renestein/6e179ac0124f009a12b3 to your computer and use it in GitHub Desktop.
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
[TestMethod] | |
public void Run_When_More_Tasks_Added_And_Cancel_Work_Then_All_Tasks_Are_Executed() | |
{ | |
bool wasTask1Called = false; | |
bool wasTask2Called = false; | |
m_scheduler.Dispatch(() => | |
{ | |
wasTask1Called = true; | |
}); | |
m_scheduler.Dispatch(() => | |
{ | |
wasTask2Called = true; | |
}); | |
cancelWorkAfterTimeout(); | |
m_scheduler.Run(); | |
Assert.IsTrue(wasTask1Called && wasTask2Called); | |
} | |
[TestMethod] | |
public void Run_When_Two_Tasks_Added_And_Cancel_Work_Then_Returns_Two() | |
{ | |
const int NUMBER_OF_SCHEDULED_TASKS = 2; | |
Enumerable.Range(0, NUMBER_OF_SCHEDULED_TASKS) | |
.Select(_ => m_scheduler.Dispatch(() => | |
{ | |
})).ToArray(); | |
cancelWorkAfterTimeout(); | |
var executedTasksCount = m_scheduler.Run(); | |
Assert.AreEqual(NUMBER_OF_SCHEDULED_TASKS, executedTasksCount); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment