Created
March 5, 2017 13:35
-
-
Save neuecc/dc53b44fd51b895f2a08215c0047481f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make unit test on plain C# class | |
public class SampleGroup | |
{ | |
// all public methods are automatically registered in test group | |
public void SumTest() | |
{ | |
var x = int.Parse("100"); | |
var y = int.Parse("200"); | |
// using RuntimeUnitTestToolkit; | |
// 'Is' is Assertion method, same as Assert(actual, expected) | |
(x + y).Is(300); | |
} | |
// return type 'IEnumerator' is marked as async test method | |
public IEnumerator AsyncTest() | |
{ | |
var testObject = new GameObject("Test"); | |
// wait asynchronous coroutine(UniRx coroutine runnner) | |
yield return MainThreadDispatcher.StartCoroutine(MoveToRight(testObject)); | |
// assrtion | |
testObject.transform.position.x.Is(60); | |
GameObject.Destroy(testObject); | |
} | |
IEnumerator MoveToRight(GameObject o) | |
{ | |
for (int i = 0; i < 60; i++) | |
{ | |
var p = o.transform.position; | |
p.x += 1; | |
o.transform.position = p; | |
yield return null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment