using NUnit.Framework;
using System.Collections;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
///
/// Test the BackButton class
///
public class BackButtonTests
{
///
/// Setup the environment before each test
///
[UnitySetUp]
public IEnumerator SetupFunction()
{
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
string oneUser = $"{{\"version\":1537,\"users\":[{{\"entries\":[],\"username\":\"TEST\",\"avatarIndex\":0,\"playtime\":0.0,\"minigames\":[],\"courses\":[]}}],\"currentUser\":0,\"currentMinigame\":0,\"currentCourse\":0,\"currentTheme\":0,\"useGPU\":false}}";
File.WriteAllText(path, oneUser);
PersistentDataController.PATH = path;
PersistentDataController.GetInstance().Load();
AssetDatabase.LoadAssetAtPath("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
SystemController.GetInstance().LoadNextScene("Common/Scenes/MainMenuScreen");
yield return new WaitForSeconds(0.2f);
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListMinigamesScreen");
yield return new WaitForSeconds(0.2f);
}
///
/// Cleanup after testing
///
[TearDown]
public void TearDown_BackButtonTests()
{
PersistentDataController.PATH = null;
}
///
/// Tests returning to the previous screen with the backbutton
///
[UnityTest]
public IEnumerator BackTest()
{
var backButton = GameObject.FindObjectOfType();
backButton.Back();
yield return new WaitForSeconds(0.2f);
var mainMenuScreen = GameObject.FindObjectOfType();
Assert.IsNotNull(mainMenuScreen);
}
}