| | 1 | | using System.Collections; |
| | 2 | | using System.Linq; |
| | 3 | | using DCL; |
| | 4 | | using NUnit.Framework; |
| | 5 | | using UnityEngine; |
| | 6 | | using UnityEngine.TestTools; |
| | 7 | |
|
| | 8 | | namespace Tests |
| | 9 | | { |
| | 10 | | public class IdleCheckerShould |
| | 11 | | { |
| | 12 | | private IIdleChecker idleChecker; |
| | 13 | |
|
| | 14 | | [UnityTest] |
| | 15 | | public IEnumerator BeIdleInOneSecond() |
| | 16 | | { |
| 1 | 17 | | idleChecker = new IdleChecker(); |
| 1 | 18 | | idleChecker.Initialize(); |
| 1 | 19 | | idleChecker.SetMaxTime(1); // MaxTime in one second for the test |
| 1 | 20 | | idleChecker.Update(); |
| | 21 | |
|
| | 22 | | // It should start as not idle |
| 1 | 23 | | Assert.IsFalse(idleChecker.isIdle()); |
| | 24 | |
|
| 1 | 25 | | yield return new DCL.WaitUntil(() => |
| | 26 | | { |
| 213 | 27 | | idleChecker.Update(); // We need to update it to update the check the status... |
| 213 | 28 | | return idleChecker.isIdle(); |
| | 29 | | }, 3.0f); |
| | 30 | |
|
| | 31 | | // It should be on idle, maybe it can fail for timeout... |
| 1 | 32 | | Assert.IsTrue(idleChecker.isIdle()); |
| 1 | 33 | | } |
| | 34 | | } |
| | 35 | | } |