Resolve WES-113 "Commons tests"
This commit is contained in:
44
Assets/Common/PlayModeTests/BackButtonTests.cs
Normal file
44
Assets/Common/PlayModeTests/BackButtonTests.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class BackButtonTests
|
||||
{
|
||||
|
||||
[UnitySetUp]
|
||||
public IEnumerator SetupFunction()
|
||||
{
|
||||
string path = Path.Combine("Assets", "users.json");
|
||||
var oneUser = "{\"currentUserIndex\": 0,\"storedUsers\": [{\"username\": \"TEST\",\"avatar\": {\"instanceID\": 40848},\"playtime\": 0.0,\"courses\": [],\"minigames\": []}]}";
|
||||
|
||||
using (StreamWriter writer = new StreamWriter(path))
|
||||
{
|
||||
writer.Write(oneUser);
|
||||
}
|
||||
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/MainMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListMinigamesScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator BackTest()
|
||||
{
|
||||
|
||||
var backButton = (BackButton) GameObject.FindObjectOfType(typeof(BackButton));
|
||||
backButton.Back();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var mainMenuScreen = (MainMenuScreen) GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
Assert.IsNotNull(mainMenuScreen);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user