KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have to test a method which does a certain amount of work after an interval. while (running) { ... // Work ... Thread.Sleep(Interval); } Interval is passed in as a parameter to the class so I can just pass in 0 or 1 but I was interested as to how to mock the system clock if this wasn't the case. In my test I'd like to be able to simply set the time forward by TimeSpan Interval and have the thread wake up. I've never written tests for code which acts upon the executing thread before and I'm sure there are some pitfalls to avoid - please feel free to elaborate on what approach you use. Thanks!
Tags (comma-separated)
Save Edits
Cancel