Created
December 23, 2013 02:09
-
-
Save yakreved/8090880 to your computer and use it in GitHub Desktop.
unit test unity3d move object test
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
//тестируемый скрипт | |
using UnityEngine; | |
using System.Collections; | |
public class move : MonoBehaviour { | |
// Use this for initialization | |
void Start () { | |
} | |
public void MoveBoxZ () | |
{ | |
transform.position = new Vector3 (transform.position.x, transform.position.y, transform.position.z + 1); | |
} | |
// Update is called once per frame | |
void Update () { | |
if(Input.GetKey(KeyCode.UpArrow)) | |
{ | |
MoveBoxZ (); | |
} | |
} | |
} | |
//сам тест | |
using System; | |
using System.Threading; | |
using NUnit.Framework; | |
using UnityEngine; | |
namespace UnityTest | |
{ | |
internal class MyTest | |
{ | |
[Test] | |
public void ExceptionTest () | |
{ | |
throw new Exception ("Exception throwing test"); | |
} | |
[Test] | |
public void moveTest () | |
{ | |
var box = GameObject.CreatePrimitive (PrimitiveType.Cube); | |
box.AddComponent<move> (); | |
var move = box.GetComponent<move>(); | |
if(move == null) | |
throw new Exception ("test component is null("); | |
Vector3 old = move.transform.position; | |
move.MoveBoxZ (); | |
Assert.AreEqual (old, new Vector3 (move.transform.position.x, move.transform.position.y, move.transform.position.z - 1)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment