Resolve WES-187 "Unit tests common and course"
This commit is contained in:
committed by
Jerome Coudron
parent
672ff367e2
commit
48b915acba
@@ -7,12 +7,14 @@ using UnityEngine.TestTools;
|
||||
|
||||
public class ListCoursesScreenTests
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Setup function to prepare the test environment before each test.
|
||||
/// </summary>
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = $"{Application.persistentDataPath}/wesign_unit_test.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}}";
|
||||
string oneUser = $"{{\"version\":1027,\"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;
|
||||
@@ -22,15 +24,26 @@ public class ListCoursesScreenTests
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cleanup after testing
|
||||
/// </summary>
|
||||
[TearDown]
|
||||
public void TearDown_ListCoursesScreenTests()
|
||||
{
|
||||
PersistentDataController.PATH = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test to verify the navigation to the course info screen.
|
||||
/// </summary>
|
||||
[UnityTest]
|
||||
public IEnumerator GotoCourseInfoTest()
|
||||
{
|
||||
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
||||
var listCoursesScreen = GameObject.FindObjectOfType<ListCoursesScreen>();
|
||||
listCoursesScreen.GotoCourseInfo();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var courseInfo = (CourseActivityScreen)GameObject.FindObjectOfType(typeof(CourseActivityScreen));
|
||||
var courseInfo = GameObject.FindObjectOfType<CourseActivityScreen>();
|
||||
Assert.IsNotNull(courseInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user