using NUnit.Framework; using System.Collections; using System.IO; using UnityEditor; using UnityEngine; using UnityEngine.TestTools; public class GameEndedPanelTests { [UnitySetUp] public IEnumerator SetupFunction() { string path = $"{Application.persistentDataPath}/unit_test_users.json"; string oneUser = $"{{\"version\":{PersistentDataController.VERSION},\"users\":[{{\"entries\":[],\"username\":\"TEST\",\"avatarIndex\":0,\"playtime\":0.0,\"minigames\":[],\"courses\":[]}}],\"currentUser\":0,\"currentMinigame\":0,\"currentCourse\":0,\"currentTheme\":0}}"; File.WriteAllText(path, oneUser); PersistentDataController.GetInstance().Load(); AssetDatabase.LoadAssetAtPath("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake(); SystemController.GetInstance().LoadNextScene("SpellingBee/Scenes/SpellingBeeGame"); yield return new WaitForSeconds(0.2f); } [UnityTest] public IEnumerator ScoreTest() { SpellingBeeController spellingBeeController = (SpellingBeeController)GameObject.FindObjectOfType(typeof(SpellingBeeController)); spellingBeeController.NextWord(); spellingBeeController.NextLetter(false); spellingBeeController.NextLetter(true); spellingBeeController.NextLetter(false); yield return new WaitForSeconds(1f); spellingBeeController.ActivateWin(); GameEndedPanel gameEndedPanel = (GameEndedPanel)GameObject.FindObjectOfType(typeof(GameEndedPanel)); Assert.NotNull(gameEndedPanel); Assert.AreEqual("Score: 0", gameEndedPanel.scoreText.text); Assert.AreEqual("1", gameEndedPanel.lettersRightText.text); Assert.AreEqual("2", gameEndedPanel.lettersWrongText.text); Assert.AreEqual("3", gameEndedPanel.lettersTotalText.text); Assert.AreEqual("00:01", gameEndedPanel.timeText.text); } }