If I have an subject under test with a timer that causes some action to be taken at a timed interval, what's a good way to test that?
One method is to wrap the timer in an interface and inject it as a dependency.
However, I'd like to avoid creating yet another abstraction. It seems I can avoid that by injecting the update interval rather than the timer. Then in my test (assuming the AAA style of testing), I put a Thread.Sleep
after Act and before Assert, using a very small time value so the test doesn't take long to run.
Is that a bad idea? I know it probably doesn't fully follow the principles of TDD, but it seems like there has to be a line where you stop surrounding everything with a contract and injecting it.