Resolve WES-187 "Unit tests common and course"

This commit is contained in:
Jelle De Geest
2023-05-12 11:53:17 +00:00
committed by Jerome Coudron
parent 672ff367e2
commit 48b915acba
25 changed files with 1248 additions and 101 deletions

View File

@@ -7,12 +7,15 @@ using UnityEngine.TestTools;
public class BackButtonTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[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;
@@ -24,15 +27,28 @@ public class BackButtonTests
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Cleanup after testing
/// </summary>
[TearDown]
public void TearDown_BackButtonTests()
{
PersistentDataController.PATH = null;
}
/// <summary>
/// Tests returning to the previous screen with the backbutton
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator BackTest()
{
var backButton = (BackButton)GameObject.FindObjectOfType(typeof(BackButton));
var backButton = GameObject.FindObjectOfType<BackButton> ();
backButton.Back();
yield return new WaitForSeconds(0.2f);
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
var mainMenuScreen = GameObject.FindObjectOfType<MainMenuScreen>();
Assert.IsNotNull(mainMenuScreen);
}
}