37 lines
1.4 KiB
C#
37 lines
1.4 KiB
C#
using NUnit.Framework;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
using UnityEngine.TestTools;
|
|
|
|
public class ListCoursesScreenTest
|
|
{
|
|
|
|
[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.PATH = path;
|
|
PersistentDataController.GetInstance().Load();
|
|
AssetDatabase.LoadAssetAtPath<UserAvatarList>("Assets/Accounts/ScriptableObjects/UserAvatarList.asset").Awake();
|
|
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListCoursesScreen");
|
|
yield return new WaitForSeconds(0.2f);
|
|
}
|
|
|
|
[UnityTest]
|
|
public IEnumerator GotoCourseInfoTest()
|
|
{
|
|
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
|
listCoursesScreen.GotoCourseInfo();
|
|
yield return new WaitForSeconds(0.2f);
|
|
|
|
var courseInfo = (CourseActivityScreen)GameObject.FindObjectOfType(typeof(CourseActivityScreen));
|
|
Assert.IsNotNull(courseInfo);
|
|
}
|
|
}
|
|
|