Resolve WES-113 "Commons tests"
This commit is contained in:
8
Assets/Common/PlayModeTests.meta
Normal file
8
Assets/Common/PlayModeTests.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f89227a2dd3cfd6de917157d10b7340f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Common/PlayModeTests/BackButtonTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/BackButtonTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ad16a6ce457c004ea62362a0cf79bfc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/Common/PlayModeTests/CommonPlayModeTests.asmdef
Normal file
26
Assets/Common/PlayModeTests/CommonPlayModeTests.asmdef
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "CommonPlayModeTests",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"UnityEngine.TestRunner",
|
||||
"UnityEditor.TestRunner",
|
||||
"CourseScripts",
|
||||
"CommonScripts",
|
||||
"InterfacesScripts",
|
||||
"Unity.TextMeshPro",
|
||||
"AccountsScripts"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [
|
||||
"nunit.framework.dll"
|
||||
],
|
||||
"autoReferenced": false,
|
||||
"defineConstraints": [
|
||||
"UNITY_INCLUDE_TESTS"
|
||||
],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d08ee7c88a96eed139d13a61cc27631c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/Common/PlayModeTests/CourseActivityTests.cs
Normal file
40
Assets/Common/PlayModeTests/CourseActivityTests.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class CourseActivityTests
|
||||
{
|
||||
|
||||
[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/CourseActivityScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator StartCoursesTests()
|
||||
{
|
||||
var courseActivityScreen = (CourseActivityScreen) GameObject.FindObjectOfType(typeof(CourseActivityScreen));
|
||||
courseActivityScreen.StartCourse();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var templateCourse = (TemplateCourse) GameObject.FindObjectOfType(typeof(TemplateCourse));
|
||||
Assert.IsNotNull(templateCourse);
|
||||
}
|
||||
}
|
||||
11
Assets/Common/PlayModeTests/CourseActivityTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/CourseActivityTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 949e9bdeb8c6a13fa9191084efa1bbeb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/Common/PlayModeTests/CourseMenuScreenTests.cs
Normal file
41
Assets/Common/PlayModeTests/CourseMenuScreenTests.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class CourseMenuScreenTest
|
||||
{
|
||||
|
||||
[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/CoursesMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoListOfCoursesTest()
|
||||
{
|
||||
var courseMenuScreen = (CourseMenuScreen) GameObject.FindObjectOfType(typeof(CourseMenuScreen));
|
||||
courseMenuScreen.GotoListOfCourses();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
||||
Assert.IsNotNull(listCoursesScreen);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Common/PlayModeTests/CourseMenuScreenTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/CourseMenuScreenTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5619dced821bf9645b502b748b0383bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/Common/PlayModeTests/ListCoursesScreenTests.cs
Normal file
41
Assets/Common/PlayModeTests/ListCoursesScreenTests.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class ListCoursesScreenTest
|
||||
{
|
||||
|
||||
[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/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);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Common/PlayModeTests/ListCoursesScreenTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/ListCoursesScreenTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56f4974974083304c814d0598c09fbcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
69
Assets/Common/PlayModeTests/MainMenuScreenTests.cs
Normal file
69
Assets/Common/PlayModeTests/MainMenuScreenTests.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class MainMenuScreenTests
|
||||
{
|
||||
|
||||
[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);
|
||||
}
|
||||
|
||||
SceneManager.LoadScene("Common/Scenes/MainMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoCoursesTest()
|
||||
{
|
||||
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
mainMenuScreen.GotoCourses();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var courseMenuScreen = (CourseMenuScreen)GameObject.FindObjectOfType(typeof(CourseMenuScreen));
|
||||
|
||||
Assert.IsNotNull(courseMenuScreen);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoMiniGamesTest()
|
||||
{
|
||||
var mainMenuScreen = (MainMenuScreen) GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
mainMenuScreen.GotoMinigames();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var listMinigamesScreen = (ListMinigamesScreen) GameObject.FindObjectOfType(typeof(ListMinigamesScreen));
|
||||
Assert.IsNotNull(listMinigamesScreen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* [UnityTest]
|
||||
public IEnumerator GotoSettingsTest()
|
||||
{
|
||||
Arrange
|
||||
SceneManager.LoadScene("Common/Scenes/MainMenuScreen");
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
var mainMenuScreen = (MainMenuScreen)GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
mainMenuScreen.GotoSettings();
|
||||
yield return new WaitForSeconds(1f);
|
||||
|
||||
var minigameActivityScreen = (MinigameActivityScreen)GameObject.FindObjectOfType(typeof(MinigameActivityScreen));
|
||||
Assert.IsNotNull(minigameActivityScreen);
|
||||
}*/
|
||||
}
|
||||
11
Assets/Common/PlayModeTests/MainMenuScreenTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/MainMenuScreenTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 531b780eb4e25f58b8a03f66aa0c070a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/Common/PlayModeTests/MinigameActivityScreenTests.cs
Normal file
41
Assets/Common/PlayModeTests/MinigameActivityScreenTests.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class MiniGameActivityScreenTests
|
||||
{
|
||||
|
||||
[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/CoursesMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator GotoListOfCoursesTest()
|
||||
{
|
||||
var courseMenuScreen = (CourseMenuScreen)GameObject.FindObjectOfType(typeof(CourseMenuScreen));
|
||||
courseMenuScreen.GotoListOfCourses();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
||||
Assert.IsNotNull(listCoursesScreen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d578cc288b904dd49bec039987a248a7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Assets/Common/PlayModeTests/StartGameTests.cs
Normal file
106
Assets/Common/PlayModeTests/StartGameTests.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class StartGamesTests
|
||||
{
|
||||
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator BootWithUsersTest()
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
SceneManager.LoadScene("Common/Scenes/Boot");
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
var userCreationScreen = (UserCreationScreen) GameObject.FindObjectOfType(typeof(UserCreationScreen));
|
||||
var bootScreen = (BootScreen) GameObject.FindObjectOfType(typeof(BootScreen));
|
||||
var mainMenuScreen = (MainMenuScreen) GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
|
||||
// yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
||||
// if (Application.HasUserAuthorization(UserAuthorization.WebCam))
|
||||
// {
|
||||
// Debug.Log("no access");
|
||||
// Assert.IsNull(userCreationScreen);
|
||||
// Assert.IsNull(mainMenuScreen);
|
||||
// Assert.IsNotNull(bootScreen);
|
||||
// Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat deze applicatie toegang heeft tot je webcam!");
|
||||
// }
|
||||
// else
|
||||
if(0 >= WebCamTexture.devices.Length){
|
||||
Debug.Log("no webcam");
|
||||
Assert.IsNull(userCreationScreen);
|
||||
Assert.IsNull(mainMenuScreen);
|
||||
Assert.IsNotNull(bootScreen);
|
||||
Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat je webcam correct is aangesloten!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("everything is there");
|
||||
Assert.IsNull(bootScreen);
|
||||
Assert.IsNull(userCreationScreen);
|
||||
Assert.IsNotNull(mainMenuScreen);
|
||||
}
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator BootWithoutUsersTest()
|
||||
{
|
||||
// Arrange
|
||||
string path = Path.Combine("Assets", "users.json");
|
||||
var oneUser = "{}";
|
||||
|
||||
using (StreamWriter writer = new StreamWriter(path))
|
||||
{
|
||||
writer.Write(oneUser);
|
||||
}
|
||||
|
||||
SceneManager.LoadScene("Common/Scenes/Boot");
|
||||
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
var userCreationScreen = (UserCreationScreen) GameObject.FindObjectOfType(typeof(UserCreationScreen));
|
||||
var bootScreen = (BootScreen) GameObject.FindObjectOfType(typeof(BootScreen));
|
||||
var mainMenuScreen = (MainMenuScreen) GameObject.FindObjectOfType(typeof(MainMenuScreen));
|
||||
|
||||
// yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
|
||||
// if (Application.HasUserAuthorization(UserAuthorization.WebCam))
|
||||
// {
|
||||
// Debug.Log("no access");
|
||||
// Assert.IsNull(userCreationScreen);
|
||||
// Assert.IsNull(mainMenuScreen);
|
||||
// Assert.IsNotNull(bootScreen);
|
||||
// Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat deze applicatie toegang heeft tot je webcam!");
|
||||
// }
|
||||
// else
|
||||
if(0 >= WebCamTexture.devices.Length){
|
||||
Debug.Log("no webcam");
|
||||
Assert.IsNull(userCreationScreen);
|
||||
Assert.IsNull(mainMenuScreen);
|
||||
Assert.IsNotNull(bootScreen);
|
||||
Assert.AreEqual(bootScreen.errorText.text, "Zorg ervoor dat je webcam correct is aangesloten!");
|
||||
} else
|
||||
{
|
||||
Debug.Log("no users");
|
||||
Assert.IsNull(bootScreen);
|
||||
Assert.IsNull(mainMenuScreen);
|
||||
Assert.IsNotNull(userCreationScreen);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Common/PlayModeTests/StartGameTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/StartGameTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b23b9d56e564350dbed07a7c3439763
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Assets/Common/PlayModeTests/UserButtonTests.cs
Normal file
52
Assets/Common/PlayModeTests/UserButtonTests.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
|
||||
using NUnit.Framework;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
|
||||
public class UserButtonTests
|
||||
{
|
||||
|
||||
[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/CoursesMenuScreen");
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
}
|
||||
|
||||
/* [UnityTest]
|
||||
public IEnumerator OpenProgressCallbackTest()
|
||||
{
|
||||
var userButton = (UserButton)GameObject.FindObjectOfType(typeof(UserButton));
|
||||
userButton.OpenProgressCallback();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var listCoursesScreen = (ListCoursesScreen)GameObject.FindObjectOfType(typeof(ListCoursesScreen));
|
||||
Assert.IsNotNull(listCoursesScreen);
|
||||
}*/
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator ChangeUserCallbackTest()
|
||||
{
|
||||
var userButton = (UserButton)GameObject.FindObjectOfType(typeof(UserButton));
|
||||
userButton.ChangeUserCallback();
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
|
||||
var changeUserScreen = (ChangeUserScreen)GameObject.FindObjectOfType(typeof(ChangeUserScreen));
|
||||
Assert.IsNotNull(changeUserScreen);
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Common/PlayModeTests/UserButtonTests.cs.meta
Normal file
11
Assets/Common/PlayModeTests/UserButtonTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa48a935164b1d4488c66de005349cdd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
82
Assets/Common/Scripts/CourseMenuScreen.cs
Normal file
82
Assets/Common/Scripts/CourseMenuScreen.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// CourseMenuScreen scene manager
|
||||
/// </summary>
|
||||
public class CourseMenuScreen : MonoBehaviour
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to text that displays when there are no recent courses
|
||||
/// </summary>
|
||||
public GameObject noRecentCourses;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to recent-courses-list container object
|
||||
/// </summary>
|
||||
public Transform recentCoursesContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to recommended-courses-list container object
|
||||
/// </summary>
|
||||
public Transform recommendedCoursesContainer;
|
||||
|
||||
/// <summary>
|
||||
/// Prefab of the course item object
|
||||
/// </summary>
|
||||
public GameObject courseItem;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the users so we can get the current user;
|
||||
/// </summary>
|
||||
public UserList userList;
|
||||
|
||||
/// <summary>
|
||||
/// Reference to the courses
|
||||
/// </summary>
|
||||
public CourseList courseList;
|
||||
|
||||
/// <summary>
|
||||
/// Start is called before the first frame update
|
||||
/// </summary>
|
||||
void Start()
|
||||
{
|
||||
User user = userList.GetCurrentUser();
|
||||
|
||||
// Recent courses
|
||||
List<Tuple<CourseIndex, float>> recentCourses = user.GetRecentCourses();
|
||||
noRecentCourses.SetActive(recentCourses.Count <= 0);
|
||||
foreach (Tuple<CourseIndex, float> course in recentCourses)
|
||||
{
|
||||
// Create instance of prefab
|
||||
GameObject instance = GameObject.Instantiate(courseItem, recentCoursesContainer);
|
||||
|
||||
// Dynamically load appearance
|
||||
CourseItem item = instance.GetComponent<CourseItem>();
|
||||
item.course = courseList.GetCourseByIndex(course.Item1);
|
||||
item.progress = course.Item2;
|
||||
}
|
||||
|
||||
// Recommended courses
|
||||
List<Tuple<CourseIndex, float>> recommenedCourses = user.GetRecommendedCourses();
|
||||
foreach (Tuple<CourseIndex, float> course in recommenedCourses)
|
||||
{
|
||||
// Create instance of prefab
|
||||
GameObject instance = GameObject.Instantiate(courseItem, recommendedCoursesContainer);
|
||||
|
||||
// Dynamically load appearance
|
||||
CourseItem item = instance.GetComponent<CourseItem>();
|
||||
item.course = courseList.GetCourseByIndex(course.Item1);
|
||||
item.progress = course.Item2;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method used as callback for 'all courses' button onClick events
|
||||
/// </summary>
|
||||
public void GotoListOfCourses()
|
||||
{
|
||||
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListCoursesScreen");
|
||||
}
|
||||
}
|
||||
11
Assets/Common/Scripts/CourseMenuScreen.cs.meta
Normal file
11
Assets/Common/Scripts/CourseMenuScreen.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00e2726fda637a1488461b7a43e46343
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Courses/PlayModeTests.meta
Normal file
8
Assets/Courses/PlayModeTests.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d322616d16e32135eb3735e3bb704d05
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/Courses/PlayModeTests/BasicTests.cs
Normal file
27
Assets/Courses/PlayModeTests/BasicTests.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class BasicTests
|
||||
{
|
||||
// A UnityTest behaves like a coroutine in Play Mode. In Edit Mode you can use
|
||||
// `yield return null;` to skip a frame.
|
||||
[UnityTest]
|
||||
public IEnumerator BasicTestsWithEnumeratorPasses()
|
||||
{
|
||||
SceneManager.LoadScene("TemplateCourse");
|
||||
// Use the Assert class to test conditions.
|
||||
// Use yield to skip a frame.
|
||||
yield return null;
|
||||
|
||||
|
||||
|
||||
// var courseObject = GameObject.findGameObjectWithTag("Course");
|
||||
// Assert.IsNotNull(courseObject);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
11
Assets/Courses/PlayModeTests/BasicTests.cs.meta
Normal file
11
Assets/Courses/PlayModeTests/BasicTests.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98c67df90515b0fec8184240768037cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
6
Assets/Courses/PlayModeTests/PlayModeTests.asmdef
Normal file
6
Assets/Courses/PlayModeTests/PlayModeTests.asmdef
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "PlayModeTests",
|
||||
"optionalUnityReferences": [
|
||||
"TestAssemblies"
|
||||
]
|
||||
}
|
||||
7
Assets/Courses/PlayModeTests/PlayModeTests.asmdef.meta
Normal file
7
Assets/Courses/PlayModeTests/PlayModeTests.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1606ac91cab3333be8c7e7281c392595
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user