public async Task TestDelay() { var task = ThreadingService.RunDelay(UpdateDelay, 1); await Task.Delay(500); //Asset Not early executed Assert.IsTrue(updateCounter == 0); await Task.Delay(1500); //Asset Executed in time Assert.IsTrue(updateCounter == 1); task.Dispose(); updateCounter = 0; task = ThreadingService.RunDelay(UpdateDelay, 1); await Task.Delay(500); task.Dispose(); await Task.Delay(1500); //asset early dispose Assert.IsTrue(updateCounter == 0); }
public IEnumerator TestDelay() { var task = ThreadingService.RunDelay(UpdateDelay, 1); yield return(new WaitForSeconds(.5f)); //Asset Not early executed Assert.IsTrue(updateCounter == 0); yield return(new WaitForSeconds(2f)); //Asset Executed in time Assert.IsTrue(updateCounter >= 1); task.Dispose(); updateCounter = 0; task = ThreadingService.RunDelay(UpdateDelay, 1); yield return(new WaitForSeconds(.5f)); task.Dispose(); yield return(new WaitForSeconds(1.5f)); //asset early dispose Assert.IsTrue(updateCounter == 0); }