From 3e9a6df1213f82af3462af2a5f20e3b5a5459705 Mon Sep 17 00:00:00 2001 From: Zaafar Date: Thu, 8 Apr 2021 12:38:08 -0400 Subject: [PATCH] made unit test simple. --- Tests/EventBasedCoroutineTests.cs | 53 ++++++++++++++++--------------- Tests/TimeBasedCoroutineTests.cs | 1 - 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Tests/EventBasedCoroutineTests.cs b/Tests/EventBasedCoroutineTests.cs index 150c62c..b9fe804 100644 --- a/Tests/EventBasedCoroutineTests.cs +++ b/Tests/EventBasedCoroutineTests.cs @@ -302,39 +302,40 @@ namespace Tests { } [Test] - public void TestNestedCoroutineWithMoveToTime() + public void MovingCoroutineTest() { - var frequentEvent = new Event(); - var onceInAWhileEvent = new Event(); - - IEnumerator FrequentCoroutine() { - int i = 0; + var evt = new Event(); + IEnumerator MovingCoroutine() { while (true) { - yield return new Wait(frequentEvent); - if (i % 2 == 0) { - CoroutineHandler.RaiseEvent(onceInAWhileEvent); - } - - i++; + yield return new Wait(evt); + yield return new Wait(0d); } } - IEnumerator OnceInAWhileCoroutine() { - while (true) { - yield return new Wait(onceInAWhileEvent); - for (int i = 0; i < 5; i++) { - yield return new Wait(0d); - } - } - } + CoroutineHandler.Start(MovingCoroutine(), "MovingCoroutine"); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.RaiseEvent(evt); + CoroutineHandler.RaiseEvent(evt); - CoroutineHandler.Start(FrequentCoroutine()); - CoroutineHandler.Start(OnceInAWhileCoroutine()); + CoroutineHandler.Tick(1d); + CoroutineHandler.Tick(1d); + CoroutineHandler.Tick(1d); + CoroutineHandler.Tick(1d); - CoroutineHandler.RaiseEvent(frequentEvent); - CoroutineHandler.RaiseEvent(frequentEvent); - CoroutineHandler.RaiseEvent(frequentEvent); - CoroutineHandler.RaiseEvent(frequentEvent); + 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 diff --git a/Tests/TimeBasedCoroutineTests.cs b/Tests/TimeBasedCoroutineTests.cs index 2e0fa46..7cdc943 100644 --- a/Tests/TimeBasedCoroutineTests.cs +++ b/Tests/TimeBasedCoroutineTests.cs @@ -442,6 +442,5 @@ namespace Tests { Assert.AreEqual(1, counterChild, "Child counter is invalid at event 4."); always.Cancel(); } - } } \ No newline at end of file