public void ShouldWaitUntilTimeout() { ModularInput._isAttached = () => false; var start = DateTime.Now; ModularInput.WaitForAttach(5); var end = DateTime.Now; Assert.True((end - start).Seconds >= 5); }
public void ShouldWaitUntilAttach() { ModularInput._isAttached = () => false; var start = DateTime.Now; var exited = false; var thread = new Thread(() => { ModularInput.WaitForAttach(10); exited = true; }); thread.Start(); ModularInput._isAttached = () => true; Thread.Sleep(1000); var end = DateTime.Now; Assert.True((end - start).Seconds <= 2); Assert.True(exited); }