Skip to content

Instantly share code, notes, and snippets.

@aallbrig
Last active February 19, 2022 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aallbrig/b21d800f3cc63d96055db8044978280c to your computer and use it in GitHub Desktop.
Save aallbrig/b21d800f3cc63d96055db8044978280c to your computer and use it in GitHub Desktop.
public class PrefabIntegrationTests
{
public string PrefabLocation => "Prefabs/Player";
[UnityTest]
public IEnumerator PlayerPrefab_RespondsToDownwardSwipe()
{
var testLocation = TestLocation.Next();
Object.Instantiate(Resources.Load<GameObject>(TestPlatform), testLocation);
var sut = Object.Instantiate(Resources.Load<GameObject>(PrefabLocation), testLocation);
InputSystem.AddDevice<Touchscreen>();
var pointer = InputSystem.AddDevice<Pointer>();
yield return null;
var positionA = sut.transform.position;
BeginTouch(pointer.deviceId, Vector2.up * 2);
EndTouch(pointer.deviceId, Vector2.zero);
yield return null;
yield return new WaitForSeconds(0.25f);
var positionB = sut.transform.position;
Assert.IsTrue(Vector3.Distance(positionA, positionB) > 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment