From 0d51954b637b55d841f0aa2fc3f2685c54f77132 Mon Sep 17 00:00:00 2001 From: Zaafar Ahmed Date: Thu, 8 Apr 2021 13:25:56 -0400 Subject: [PATCH] Added a unit test to expose an exception (#14) * added a unit test to expose the bug. * made unit test simple. * adding extra lines. --- Tests/EventBasedCoroutineTests.cs | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Tests/EventBasedCoroutineTests.cs b/Tests/EventBasedCoroutineTests.cs index 456f9c9..f1fbb91 100644 --- a/Tests/EventBasedCoroutineTests.cs +++ b/Tests/EventBasedCoroutineTests.cs @@ -301,5 +301,42 @@ namespace Tests { Assert.AreEqual(cr.Name, "Bird", "Incorrect name of the coroutine."); } + [Test] + public void MovingCoroutineTest() + { + var evt = new Event(); + IEnumerator MovingCoroutine() { + while (true) { + yield return new Wait(evt); + yield return new Wait(0d); + } + } + + CoroutineHandler.Start(MovingCoroutine(), "MovingCoroutine"); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.RaiseEvent(evt); + + CoroutineHandler.Tick(1d); + CoroutineHandler.Tick(1d); + CoroutineHandler.Tick(1d); + CoroutineHandler.Tick(1d); + + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.Tick(1d); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.Tick(1d); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.Tick(1d); + + CoroutineHandler.Tick(1d); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.Tick(1d); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.Tick(1d); + CoroutineHandler.RaiseEvent(evt); + } + } } \ No newline at end of file