Add test of nested IEnumerator

pull/23/head
Kazunori Tamura 2019-06-28 11:57:06 +09:00
parent fed4ba76b5
commit 5a934d382f
1 changed files with 21 additions and 0 deletions

View File

@ -376,6 +376,27 @@ namespace UniRx.AsyncTests
throw new Exception("MyException"); throw new Exception("MyException");
} }
[UnityTest]
public IEnumerator NestedEnumerator() => UniTask.ToCoroutine(async () =>
{
var time = Time.realtimeSinceStartup;
await ParentCoroutineEnumerator();
var elapsed = Time.realtimeSinceStartup - time;
((int)Math.Round(TimeSpan.FromSeconds(elapsed).TotalSeconds, MidpointRounding.ToEven)).Should().Be(3);
});
IEnumerator ParentCoroutineEnumerator()
{
yield return ChildCoroutineEnumerator();
}
IEnumerator ChildCoroutineEnumerator()
{
yield return new WaitForSeconds(3);
}
#endif #endif
#endif #endif
} }