mirror of
https://github.com/Ellpeck/Coroutine.git
synced 2024-11-21 13:23:29 +01:00
Added event based test.
This commit is contained in:
parent
bda1e21ea3
commit
1c97d17ef7
2 changed files with 38 additions and 4 deletions
34
CoroutineTests/EventBasedCoroutineTests.cs
Normal file
34
CoroutineTests/EventBasedCoroutineTests.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
using Coroutine;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CoroutineTests
|
||||
{
|
||||
[TestClass]
|
||||
public class EventBasedCoroutineTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TestEventBasedCoroutine()
|
||||
{
|
||||
int counter = 0;
|
||||
var myEvent = new Event();
|
||||
IEnumerator<Wait> OnEventTriggered()
|
||||
{
|
||||
counter++;
|
||||
yield return new Wait(myEvent);
|
||||
counter++;
|
||||
}
|
||||
|
||||
var cr = CoroutineHandler.Start(OnEventTriggered());
|
||||
Assert.AreEqual(1, counter, "instruction before yield is not executed.");
|
||||
CoroutineHandler.RaiseEvent(myEvent);
|
||||
Assert.AreEqual(2, counter, "instruction after yield is not executed.");
|
||||
CoroutineHandler.RaiseEvent(myEvent);
|
||||
Assert.AreEqual(2, counter, "instruction after yield is not executed.");
|
||||
|
||||
Assert.AreEqual(true, cr.IsFinished, "Incorrect IsFinished value.");
|
||||
Assert.AreEqual(false, cr.WasCanceled, "Incorrect IsCanceled value.");
|
||||
Assert.AreEqual(cr.MoveNextCount, 2, "Incorrect MoveNextCount value.");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Coroutine;
|
||||
|
||||
|
||||
namespace CoroutineTests
|
||||
{
|
||||
using Coroutine;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
[TestClass]
|
||||
public class TimeBasedCoroutineTests
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue