Skip to content

Instantly share code, notes, and snippets.

@jagwire
Created February 8, 2016 15:53
Show Gist options
  • Save jagwire/cdd4769ef4e389868813 to your computer and use it in GitHub Desktop.
Save jagwire/cdd4769ef4e389868813 to your computer and use it in GitHub Desktop.
Example Automatic Test
using UnityEngine;
namespace MHS.Tests {
public class MyLogic {
public int speed = 5;
public int position = 0;
public void tick(float timeStep) {
position = position + speed*time;
}
}
[TestFixture]
MyLogicTest {
private MyLogic logic;
public MyLogicTest() {
logic = new MyLogic();
}
[Test]
public onTickPositionShouldAdvanceBySpeedTimesTime() {
//arrange
float time = 0.02f;
logic.speed = 5;
//act
logic.tick(time);
//assert
Assert.AreEqual(logic.position, 0.1f); // 5 * 0.2f
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment