Created
June 2, 2014 14:04
-
-
Save renestein/e0ceece27366aae6891a to your computer and use it in GitHub Desktop.
Run_When_One_Task_Added_And_Cancel_Work_Then_Returns_One().cs
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 void Run_When_One_Task_Added_And_Cancel_Work_Then_Returns_One() | |
{ | |
m_scheduler.Dispatch(() => | |
{ | |
}); | |
cancelWorkAfterTimeout(); | |
var result = m_scheduler.Run(); | |
Assert.AreEqual(1, result); | |
} | |
private void cancelWorkAfterTimeout(int? sleepMs = null) | |
{ | |
const int DEFAULT_SLEEP = 1000; | |
var sleepTime = sleepMs ?? DEFAULT_SLEEP; | |
var work = new Work(m_scheduler); | |
ThreadPool.QueueUserWorkItem(_ => | |
{ | |
Thread.Sleep(sleepTime); | |
work.Dispose(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment