StartupFlowTests.cs 1.1 KB

123456789101112131415161718192021222324252627
  1. using System.Collections;
  2. using System.Linq;
  3. using NUnit.Framework;
  4. using UnityEngine;
  5. using UnityEngine.TestTools;
  6. using UnityEngine.UI;
  7. namespace HexaCrazy.Tests
  8. {
  9. public class StartupFlowTests
  10. {
  11. HexGameApp app;
  12. [UnityTearDown] public IEnumerator Cleanup()
  13. { if (app != null) Object.Destroy(app.gameObject); yield return null; }
  14. [UnityTest] public IEnumerator GameStartsWithoutRuntimeSdkAndIgnoresDuplicateClick()
  15. {
  16. app = new GameObject("StartupTest").AddComponent<HexGameApp>();
  17. yield return null;
  18. Assert.AreEqual("Start", app.ScreenName);
  19. var button = app.Root.GetComponentsInChildren<Button>().Single(b => b.name == "GameStart");
  20. Assert.IsTrue(button.interactable);
  21. Assert.IsFalse(app.GetComponent<HexAudio>().Music);
  22. button.onClick.Invoke(); button.onClick.Invoke();
  23. Assert.AreEqual("Lobby", app.ScreenName);
  24. Assert.IsFalse(typeof(HexGameApp).Assembly.GetReferencedAssemblies().Any(a => a.Name == "AppRuntimes"));
  25. }
  26. }
  27. }