mirror of
https://github.com/Ellpeck/Coroutine.git
synced 2024-05-19 23:51:23 +02:00
made unit test simple.
This commit is contained in:
parent
581a01f048
commit
3e9a6df121
|
@ -302,39 +302,40 @@ namespace Tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestNestedCoroutineWithMoveToTime()
|
public void MovingCoroutineTest()
|
||||||
{
|
{
|
||||||
var frequentEvent = new Event();
|
var evt = new Event();
|
||||||
var onceInAWhileEvent = new Event();
|
IEnumerator<Wait> MovingCoroutine() {
|
||||||
|
|
||||||
IEnumerator<Wait> FrequentCoroutine() {
|
|
||||||
int i = 0;
|
|
||||||
while (true) {
|
while (true) {
|
||||||
yield return new Wait(frequentEvent);
|
yield return new Wait(evt);
|
||||||
if (i % 2 == 0) {
|
yield return new Wait(0d);
|
||||||
CoroutineHandler.RaiseEvent(onceInAWhileEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator<Wait> OnceInAWhileCoroutine() {
|
CoroutineHandler.Start(MovingCoroutine(), "MovingCoroutine");
|
||||||
while (true) {
|
CoroutineHandler.RaiseEvent(evt);
|
||||||
yield return new Wait(onceInAWhileEvent);
|
CoroutineHandler.RaiseEvent(evt);
|
||||||
for (int i = 0; i < 5; i++) {
|
CoroutineHandler.RaiseEvent(evt);
|
||||||
yield return new Wait(0d);
|
CoroutineHandler.RaiseEvent(evt);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CoroutineHandler.Start(FrequentCoroutine());
|
CoroutineHandler.Tick(1d);
|
||||||
CoroutineHandler.Start(OnceInAWhileCoroutine());
|
CoroutineHandler.Tick(1d);
|
||||||
|
CoroutineHandler.Tick(1d);
|
||||||
|
CoroutineHandler.Tick(1d);
|
||||||
|
|
||||||
CoroutineHandler.RaiseEvent(frequentEvent);
|
CoroutineHandler.RaiseEvent(evt);
|
||||||
CoroutineHandler.RaiseEvent(frequentEvent);
|
CoroutineHandler.Tick(1d);
|
||||||
CoroutineHandler.RaiseEvent(frequentEvent);
|
CoroutineHandler.RaiseEvent(evt);
|
||||||
CoroutineHandler.RaiseEvent(frequentEvent);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -442,6 +442,5 @@ namespace Tests {
|
||||||
Assert.AreEqual(1, counterChild, "Child counter is invalid at event 4.");
|
Assert.AreEqual(1, counterChild, "Child counter is invalid at event 4.");
|
||||||
always.Cancel();
|
always.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue