public void PausedTimerShouldBeSaveAndLoadable() { int waitTimeMs = 100; bool elapsed = false; PausableTimer timer = new PausableTimer(waitTimeMs); timer.Elapsed += (a, b) => { elapsed = true; }; int margin = Mathf.RoundToInt(waitTimeMs * 0.1f); timer.Start(); // Wait half the time, then save System.Threading.Thread.Sleep((waitTimeMs + margin) / 2); timer.Pause(); IGenericSaveData save = timer.GetSave(); Assert.IsFalse(elapsed); timer = new PausableTimer(save); timer.Elapsed += (a, b) => { elapsed = true; }; System.Threading.Thread.Sleep((waitTimeMs + margin) / 2); Assert.IsFalse(elapsed); timer.Resume(); System.Threading.Thread.Sleep((waitTimeMs + margin) / 2); Assert.IsTrue(elapsed); }