Resolve WES-181 "Missing code doc"

This commit is contained in:
Dries Van Schuylenbergh 2023-05-14 20:18:29 +00:00 committed by Louis Adriaens
parent 7505ae7262
commit 3d99184717
67 changed files with 686 additions and 198 deletions

View File

@ -38,7 +38,6 @@ public class User
/// </summary>
public Sprite GetAvatar() { return UserList.AVATARS[storedUserData.avatarIndex]; }
/// <summary>
/// Get a list of all recently started minigameCards
/// </summary>

View File

@ -12,6 +12,9 @@ public class UserAvatarList : ScriptableObject
/// </summary>
public List<Sprite> avatars = new List<Sprite>();
/// <summary>
/// Awake is called when the object gets created
/// </summary>
public void Awake()
{
UserList.AVATARS = avatars;

View File

@ -54,7 +54,6 @@ public class UserCreationScreen : MonoBehaviour
/// </summary>
public static bool canGoBack = true;
/// <summary>
/// Start is called before the first frame update
/// </summary>

View File

@ -105,7 +105,6 @@ public static class UserList
PersistentDataController.GetInstance().SetCurrentUser(index, true);
}
/// <summary>
/// Change the current user
/// </summary>

View File

@ -26,8 +26,6 @@ public class UserListTests
/// </summary>
private Sprite avatar = null;
private string cachedPath;
/// <summary>
/// Setup the tests
/// </summary>
@ -98,8 +96,6 @@ public class UserListTests
Assert.IsNull(user);
}
/// <summary>
/// Test whether an existing user can be found by its username
/// </summary>

View File

@ -25,7 +25,6 @@ public class UserTests
user = new User(data);
}
/// <summary>
/// Test for the creation of a new user
/// </summary>

View File

@ -110,6 +110,9 @@ public class PanelCourseProgressTests
Assert.IsNotNull(panel.progressBar);
}
/// <summary>
/// Test whether the panel is correctly initialized
/// </summary>
[UnityTest]
public IEnumerator Test_Start()
{
@ -126,6 +129,9 @@ public class PanelCourseProgressTests
Assert.AreEqual(course.theme.learnables.Count, panel.learnablesContainer.childCount);
}
/// <summary>
/// Test whether the panel is correctly initialized when there is no course progress
/// </summary>
[UnityTest]
public IEnumerator Test_Start_Empty()
{

View File

@ -109,7 +109,6 @@ public class PanelMinigameProgressTests
PersistentDataController.PATH = null;
}
/// <summary>
/// Test whether every item that needs to be assign in the editor, is assigned
/// </summary>
@ -130,6 +129,9 @@ public class PanelMinigameProgressTests
Assert.IsNotNull(panel.emptyHighscore);
}
/// <summary>
/// Test whether the panel is correctly initialized
/// </summary>
[UnityTest]
public IEnumerator Test_Start()
{
@ -145,6 +147,9 @@ public class PanelMinigameProgressTests
Assert.AreEqual(minigame.title, panel.minigameTitle.text);
}
/// <summary>
/// Test whether the panel is correctly initialized when there is no minigame progress
/// </summary>
[UnityTest]
public IEnumerator Test_Start_Empty()
{
@ -155,6 +160,9 @@ public class PanelMinigameProgressTests
Assert.IsTrue(panel.emptyMinigames.gameObject.activeSelf);
}
/// <summary>
/// Test whether the panel is correctly initialized when there are minigames, but these don't have any score
/// </summary>
[UnityTest]
public IEnumerator Test_Start_NoScorePresent()
{

View File

@ -62,6 +62,9 @@ public class ProgressGraphTests
Assert.IsNotNull(graph.axesTickMarker);
}
/// <summary>
/// Test whether negative values are correctly plotted
/// </summary>
[UnityTest]
public IEnumerator Test_PlotGraph_Negative()
{
@ -70,6 +73,9 @@ public class ProgressGraphTests
Assert.IsTrue(true);
}
/// <summary>
/// Test whether values between 0 and 1 are correctly plotted
/// </summary>
[UnityTest]
public IEnumerator Test_PlotGraph_SmallerThen1()
{
@ -78,6 +84,9 @@ public class ProgressGraphTests
Assert.IsTrue(true);
}
/// <summary>
/// Test whether values around 0 are correctly plotted
/// </summary>
[UnityTest]
public IEnumerator Test_PlotGraph_AroundZero()
{
@ -86,6 +95,9 @@ public class ProgressGraphTests
Assert.IsTrue(true);
}
/// <summary>
/// Test whether all 0 values are correctly plotted
/// </summary>
[UnityTest]
public IEnumerator Test_PlotGraph_AllZeros()
{
@ -94,6 +106,9 @@ public class ProgressGraphTests
Assert.IsTrue(true);
}
/// <summary>
/// Test whether values between -1 and 1 are correctly plotted
/// </summary>
[UnityTest]
public IEnumerator Test_PlotGraph_BetweenPos1AndNeg1()
{
@ -102,6 +117,9 @@ public class ProgressGraphTests
Assert.IsTrue(true);
}
/// <summary>
/// Test whether a single value is correctly plotted
/// </summary>
[UnityTest]
public IEnumerator Test_PlotGraph_Single()
{
@ -110,6 +128,9 @@ public class ProgressGraphTests
Assert.IsTrue(true);
}
/// <summary>
/// Test whether multiple values are correctly plotted
/// </summary>
[UnityTest]
public IEnumerator Test_PlotGraph_Multiple()
{
@ -118,6 +139,9 @@ public class ProgressGraphTests
Assert.IsTrue(true);
}
/// <summary>
/// Test whether too many values (capped at 10) are correctly plotted
/// </summary>
[UnityTest]
public IEnumerator Test_PlotGraph_TooMany()
{

View File

@ -44,6 +44,7 @@ public class UserCreationScreenTests
{
PersistentDataController.PATH = null;
}
/// <summary>
/// Test whether every item that needs to be assign in the editor, is assigned
/// </summary>

View File

@ -102,6 +102,9 @@ public class UserProgressScreenTests
Assert.IsFalse(userProgressController.minigamesPanel.activeSelf);
}
/// <summary>
/// Test whether the course panel is displayed
/// </summary>
[UnityTest]
public IEnumerator Test_DisplayCourses()
{
@ -115,6 +118,10 @@ public class UserProgressScreenTests
Assert.IsFalse(userProgressController.minigamesPanel.activeSelf);
}
/// <summary>
/// Test whether the minigames panel is displayed
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator Test_DisplayMinigames()
{

View File

@ -48,9 +48,17 @@ public class PersistentDataController
/// </summary>
public List<byte> data = new List<byte>();
/// <summary>
/// Create a new PersistentDataEntry
/// </summary>
/// <param name="key"></param>
/// <param name="data"></param>
public PersistentDataEntry(string key, byte[] data) : this(key, data.ToList())
{ }
/// <summary>
/// Create a new PersistentDataEntry
/// </summary>
public PersistentDataEntry(string key, List<byte> data)
{
this.key = key;
@ -171,10 +179,30 @@ public class PersistentDataController
[Serializable]
public class SavedUserData : PersistentDataContainer
{
/// <summary>
/// The user's username
/// </summary>
public string username = null;
/// <summary>
/// The index of the user's avatar in the UserList.AVATARS list
/// </summary>
public int avatarIndex = -1;
/// <summary>
/// The total playtime of the user
/// </summary>
/// <remarks>Not implemented yet</remarks>
public double playtime = 0.0;
/// <summary>
/// A list of progress on minigames the user has
/// </summary>
public List<SavedMinigameProgress> minigames = new List<SavedMinigameProgress>();
/// <summary>
/// A list of progress on courses the user has
/// </summary>
public List<SavedCourseProgress> courses = new List<SavedCourseProgress>();
}
@ -210,9 +238,9 @@ public class PersistentDataController
}
/// <summary>
///
/// Check whether there are enough inUse Learnables
/// </summary>
/// <returns> bool which indicates if there are enough inUseLearnables </returns>
/// <returns></returns>
private bool EnoughLearnables()
{
// There need to be more then 5 non completed learnables
@ -297,9 +325,24 @@ public class PersistentDataController
[Serializable]
public class SavedLearnableProgress : PersistentDataContainer
{
/// <summary>
/// Index of the Learnbable in its Theme
/// </summary>
public int index;
/// <summary>
/// Bool that indicated whether the user already started learning this Learnable
/// </summary>
public bool inUse = false;
/// <summary>
/// Display name of the Learnable
/// </summary>
public string name;
/// <summary>
/// Progress of the learnabe, a number between -5.0 and +5.0
/// </summary>
public float progress = 0.0f;
}
@ -309,8 +352,19 @@ public class PersistentDataController
[Serializable]
public class SavedMinigameProgress : PersistentDataContainer
{
/// <summary>
/// Index of the minigame
/// </summary>
public MinigameIndex minigameIndex;
/// <summary>
/// The 10 last scores of a user
/// </summary>
public List<Score> latestScores = new List<Score>();
/// <summary>
/// Top 10 scores of a user
/// </summary>
public List<Score> highestScores = new List<Score>();
}
@ -320,11 +374,34 @@ public class PersistentDataController
[Serializable]
private class SavedDataStructure
{
/// <summary>
/// The version of the PersistentDataController with which this savefile is created
/// </summary>
public int version = VERSION;
/// <summary>
/// A list of all users
/// </summary>
public List<SavedUserData> users = new List<SavedUserData>();
/// <summary>
/// The index of the current user in the this.users list
/// </summary>
public int currentUser = -1;
/// <summary>
/// The index of the current minigame
/// </summary>
public MinigameIndex currentMinigame;
/// <summary>
/// The index of the current course
/// </summary>
public CourseIndex currentCourse;
/// <summary>
/// The index of the current theme
/// </summary>
public ThemeIndex currentTheme;
/// <summary>

View File

@ -6,7 +6,14 @@
[Serializable]
public class Score
{
/// <summary>
/// The actual score
/// </summary>
public int scoreValue;
/// <summary>
/// The time when the score is achieved, in string format
/// </summary>
public string time;
}

View File

@ -41,6 +41,9 @@ public class PersistentDataControllerTests
CIRCLE
}
/// <summary>
/// Setup the PersistentDataController tests
/// </summary>
[SetUp]
public void Setup_PersistentDataController()
{
@ -49,12 +52,18 @@ public class PersistentDataControllerTests
pdc = PersistentDataController.GetInstance();
}
/// <summary>
/// Cleaning up the tests
/// </summary>
[TearDown]
public void TearDown_PersistentDataController()
{
PersistentDataController.PATH = null;
}
/// <summary>
/// Test whether the singleton instance is correctly returned
/// </summary>
[Test]
public void Test_PersistentDataController_GetInstance()
{
@ -64,6 +73,9 @@ public class PersistentDataControllerTests
Assert.AreEqual($"{Application.persistentDataPath}/wesign_saved_data.json", PersistentDataController.PATH);
}
/// <summary>
/// Test whether all data is correctly cleared
/// </summary>
[Test]
public void Test_PersistentDataController_Clear()
{
@ -73,6 +85,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(-1, pdc.GetCurrentUser());
}
/// <summary>
/// Test whether an empty savefile can be saved correctly
/// </summary>
[Test]
public void Test_PersistentDataController_Save_Empty()
{
@ -87,6 +102,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(expected, content);
}
/// <summary>
/// Test whether a savefile can be created when non already exists
/// </summary>
[Test]
public void Test_PersistentDataController_Save_New()
{
@ -103,6 +121,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(expected, content);
}
/// <summary>
/// Test whether an existing savefile can be loaded
/// </summary>
[Test]
public void Test_PersistentDataController_Load_Existing()
{
@ -111,6 +132,9 @@ public class PersistentDataControllerTests
Assert.IsTrue(pdc.Load(false));
}
/// <summary>
/// Test whether an exisiting older savefile will create a new correct savefile
/// </summary>
[Test]
public void Test_PersistentDataController_Load_OlderVersion()
{
@ -119,6 +143,9 @@ public class PersistentDataControllerTests
Assert.IsFalse(pdc.Load(false));
}
/// <summary>
/// Test whether an exisiting newer savefile will create a new correct savefile
/// </summary>
[Test]
public void Test_PersistentDataController_Load_NewerVersion()
{
@ -127,6 +154,9 @@ public class PersistentDataControllerTests
Assert.IsFalse(pdc.Load(false));
}
/// <summary>
/// Test whether the PersistentDataController will fail loading a savefile when no savefile is present
/// </summary>
[Test]
public void Test_PersistentDataController_Load_New()
{
@ -136,6 +166,9 @@ public class PersistentDataControllerTests
FileAssert.DoesNotExist(PATH);
}
/// <summary>
/// Test whether a corrupted savefile will throw an error
/// </summary>
[Test]
public void Test_PersistentDataController_Load_Exception()
{
@ -144,6 +177,9 @@ public class PersistentDataControllerTests
Assert.AreEqual("https://www.youtube.com/watch?v=dQw4w9WgXcQ", File.ReadAllText(PATH));
}
/// <summary>
/// Test whether a corrupted savefile will be overriden
/// </summary>
[Test]
public void Test_PersistentDataController_Load_Override()
{
@ -154,6 +190,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(expected, content);
}
/// <summary>
/// Test whether the current version is correct
/// </summary>
[Test]
public void Test_PersistentDataController_Version()
{
@ -161,6 +200,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(VERSION, PersistentDataController.VERSION);
}
/// <summary>
/// Test whether a new user can be added
/// </summary>
[Test]
public void Test_PersistentDataController_AddUser()
{
@ -178,6 +220,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(expected, content);
}
/// <summary>
/// Test whether all users are returned
/// </summary>
[Test]
public void Test_PersistentDataController_GetUsers()
{
@ -196,6 +241,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(0, users[0].avatarIndex);
}
/// <summary>
/// Test whether the current user is returned
/// </summary>
[Test]
public void Test_PersistentDataController_GetCurrentUser()
{
@ -211,6 +259,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(0, pdc.GetCurrentUser());
}
/// <summary>
/// Test whether the current user is corrctly changed
/// </summary>
[Test]
public void Test_PersistentDataController_SetCurrentUser()
{
@ -227,6 +278,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(3, pdc.GetCurrentUser());
}
/// <summary>
/// Test whether setting an invalid current user throws an error
/// </summary>
[Test]
public void Test_PersistentDataController_SetCurrentUser_Invalid()
{
@ -241,6 +295,9 @@ public class PersistentDataControllerTests
Assert.Throws<IndexOutOfRangeException>(delegate { pdc.SetCurrentUser(3); });
}
/// <summary>
/// Test whether setting the current user for an empty userlist will throw an error
/// </summary>
[Test]
public void Test_PersistentDataController_SetCurrentUser_Empty()
{
@ -249,6 +306,9 @@ public class PersistentDataControllerTests
Assert.Throws<IndexOutOfRangeException>(delegate { pdc.SetCurrentUser(0); });
}
/// <summary>
/// Test whether a user is correctly removed and the current user is correctly updated
/// </summary>
[Test]
public void Test_PersistentDataController_DeleteUser_BeforeCurrent()
{
@ -280,6 +340,9 @@ public class PersistentDataControllerTests
}
}
/// <summary>
/// Test whether a user is correctly removed and the current user is correctly updated
/// </summary>
[Test]
public void Test_PersistentDataController_DeleteUser_Current()
{
@ -311,6 +374,9 @@ public class PersistentDataControllerTests
}
}
/// <summary>
/// Test whether a user is correctly removed and the current user is correctly updated
/// </summary>
[Test]
public void Test_PersistentDataController_DeleteUser_AfterCurrent()
{
@ -343,6 +409,9 @@ public class PersistentDataControllerTests
}
}
/// <summary>
/// Test whether deleting an invalid user will throw an error
/// </summary>
[Test]
public void Test_PersistentDataController_DeleteUser_Invalid()
{
@ -357,6 +426,9 @@ public class PersistentDataControllerTests
Assert.Throws<IndexOutOfRangeException>(delegate { pdc.SetCurrentUser(3); });
}
/// <summary>
/// Test whether deleting a user from an empty userlist will throw an error
/// </summary>
[Test]
public void Test_PersistentDataController_DeleteUser_Empty()
{
@ -365,6 +437,9 @@ public class PersistentDataControllerTests
Assert.Throws<IndexOutOfRangeException>(delegate { pdc.DeleteUser(0); });
}
/// <summary>
/// Test whether the correct current course is returned
/// </summary>
[Test]
public void Test_PersistentDataController_CurrentCourse()
{
@ -374,6 +449,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(CourseIndex.FINGERSPELLING, pdc.GetCurrentCourse());
}
/// <summary>
/// Test whether the correct current minigame is returned
/// </summary>
[Test]
public void Test_PersistentDataController_CurrentMinigame()
{
@ -383,6 +461,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(MinigameIndex.SPELLING_BEE, pdc.GetCurrentMinigame());
}
/// <summary>
/// Test whether the correct current theme is returned
/// </summary>
[Test]
public void Test_PersistentDataController_CurrentTheme()
{
@ -420,6 +501,9 @@ public class PersistentDataControllerTests
Assert.IsFalse(pdc.IsUsingGPU());
}
/// <summary>
/// Test the creation of a new PersistentDataContainer
/// </summary>
[Test]
public void Test_New_PersistentDataContainer()
{
@ -428,6 +512,9 @@ public class PersistentDataControllerTests
Assert.Zero(c.entries.Count);
}
/// <summary>
/// Test whether setting an invalid object on a key in a PersitentDataContainer will throw an error
/// </summary>
[Test]
public void Test_PersistentDataContainer_Set_Invalid()
{
@ -435,6 +522,9 @@ public class PersistentDataControllerTests
Assert.IsFalse(c.Set<object>("key", null));
}
/// <summary>
/// Test whether setting a valid object on duplicate key in a PersitentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Set_DuplicateKey()
{
@ -443,6 +533,9 @@ public class PersistentDataControllerTests
Assert.IsTrue(c.Set<int>("key", 321));
}
/// <summary>
/// Test whether setting an int in a PersitentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Set_Int()
{
@ -450,6 +543,9 @@ public class PersistentDataControllerTests
Assert.IsTrue(c.Set<int>("key", 123));
}
/// <summary>
/// Test whether setting a string in a PersitentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Set_String()
{
@ -457,6 +553,9 @@ public class PersistentDataControllerTests
Assert.IsTrue(c.Set<string>("key", "abc"));
}
/// <summary>
/// Test whether setting a struct in a PersitentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Set_Struct()
{
@ -464,6 +563,9 @@ public class PersistentDataControllerTests
Assert.IsTrue(c.Set<Struct>("key", new Struct()));
}
/// <summary>
/// Test whether setting an enum in a PersitentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Set_Enum()
{
@ -471,6 +573,9 @@ public class PersistentDataControllerTests
Assert.IsTrue(c.Set<Enum>("key", new Enum()));
}
/// <summary>
/// Test whether retrieving the wrong type from a PersistentDataContainer will throw an error
/// </summary>
[Test]
public void Test_PersistentDataContainer_Get_InvalidType()
{
@ -481,6 +586,9 @@ public class PersistentDataControllerTests
Assert.Throws<InvalidCastException>(delegate { c.Get<Struct>("key"); });
}
/// <summary>
/// Test whether retrieving the an wrong key from a PersistentDataContainer will throw an error
/// </summary>
[Test]
public void Test_PersistentDataContainer_Get_KeyNotFound()
{
@ -489,6 +597,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<int>("KEY"); });
}
/// <summary>
/// Test whether retrieving the unknown key from a PersistentDataContainer will throw an error
/// </summary>
[Test]
public void Test_PersistentDataContainer_Get_Empty()
{
@ -496,6 +607,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<int>("key"); });
}
/// <summary>
/// Test whether retrieving an int from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Get_Int()
{
@ -504,6 +618,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(123, c.Get<int>("key"));
}
/// <summary>
/// Test whether retrieving a string from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Get_String()
{
@ -512,6 +629,9 @@ public class PersistentDataControllerTests
Assert.AreEqual("value", c.Get<string>("key"));
}
/// <summary>
/// Test whether retrieving a struct from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Get_Struct()
{
@ -521,6 +641,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(s, c.Get<Struct>("key"));
}
/// <summary>
/// Test whether retrieving an enum from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Get_Enum()
{
@ -530,6 +653,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(e, c.Get<Enum>("key"));
}
/// <summary>
/// Test whether removing an invalid key from a PersistentDataContainer will throw an error
/// </summary>
[Test]
public void Test_PersistentDataContainer_Remove_Invalid()
{
@ -538,6 +664,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Remove("KEY"); });
}
/// <summary>
/// Test whether removing a non-existing key from a PersistentDataContainer will throw an error
/// </summary>
[Test]
public void Test_PersistentDataContainer_Remove_Empty()
{
@ -545,6 +674,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Remove("key"); });
}
/// <summary>
/// Test whether removing an int from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Remove_Int()
{
@ -554,6 +686,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<int>("key"); });
}
/// <summary>
/// Test whether removing a string from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Remove_String()
{
@ -563,6 +698,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<string>("key"); });
}
/// <summary>
/// Test whether removing a struct from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Remove_Struct()
{
@ -573,6 +711,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<Struct>("key"); });
}
/// <summary>
/// Test whether removing an enum from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Remove_Enum()
{
@ -582,6 +723,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<Enum>("key"); });
}
/// <summary>
/// Test whether popping an invalid key from a PersistentDataContainer will throw an error
/// </summary>
[Test]
public void Test_PersistentDataContainer_Pop_Invalid()
{
@ -590,6 +734,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Remove("KEY"); });
}
/// <summary>
/// Test whether popping a non-existing key from a PersistentDataContainer will throw an error
/// </summary>
[Test]
public void Test_PersistentDataContainer_Pop_Empty()
{
@ -597,6 +744,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Remove("KEY"); });
}
/// <summary>
/// Test whether popping an int from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Pop_Int()
{
@ -606,6 +756,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<int>("key"); });
}
/// <summary>
/// Test whether popping a string from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Pop_String()
{
@ -615,6 +768,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<string>("key"); });
}
/// <summary>
/// Test whether popping a struct from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Pop_Struct()
{
@ -625,6 +781,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<Struct>("key"); });
}
/// <summary>
/// Test whether popping an enum from a PersistentDataContainer can be done correctly
/// </summary>
[Test]
public void Test_PersistentDataContainer_Pop_Enum()
{
@ -634,6 +793,9 @@ public class PersistentDataControllerTests
Assert.Throws<KeyNotFoundException>(delegate { c.Get<Enum>("key"); });
}
/// <summary>
/// Test whether checking for a valid key will return true
/// </summary>
[Test]
public void Test_PersistentDataContainer_Has_ValidKey()
{
@ -643,6 +805,9 @@ public class PersistentDataControllerTests
Assert.IsTrue(c.Has("key"));
}
/// <summary>
/// Test whether checking for a invalid key will return false
/// </summary>
[Test]
public void Test_PersistentDataContainer_Has_InvalidKey()
{
@ -652,6 +817,9 @@ public class PersistentDataControllerTests
Assert.IsFalse(c.Has("KEY"));
}
/// <summary>
/// Test whether a Learnable can be saved correctly
/// </summary>
[Test]
public void Test_SavedCourseProgress_AddLearnable_Valid()
{
@ -665,6 +833,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(0, progress.FindLearnable("learnable").index);
}
/// <summary>
/// Test whether a duplicate name in a Learnable, will not save this Learnable
/// </summary>
[Test]
public void Test_SavedCourseProgress_AddLearnable_DuplicateName()
{
@ -677,6 +848,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(1, progress.learnables.Count);
}
/// <summary>
/// Test whether a duplicate index in a Learnable, will not save this Learnable
/// </summary>
[Test]
public void Test_SavedCourseProgress_AddLearnable_DuplicateIndex()
{
@ -689,7 +863,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(1, progress.learnables.Count);
}
/// <summary>
/// Test whether when updating a invalid named Learnable will throw an error
/// </summary>
[Test]
public void Test_SavedCourseProgress_UpdateLearnable_InvalidName()
{
@ -701,7 +877,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(0.0f, progress.FindLearnable("learnable").progress);
}
/// <summary>
/// Test whether when updating a valid named Learnable will be correctly saved
/// </summary>
[Test]
public void Test_SavedCourseProgress_UpdateLearnable_UpdatesProgress()
{
@ -713,6 +891,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(3.0f, progress.FindLearnable("learnable").progress);
}
/// <summary>
/// Test whether when updating a Learnable, the progress is capped at 5
/// </summary>
[Test]
public void Test_SavedCourseProgress_UpdateLearnable_CropsProgressAtFive()
{
@ -725,6 +906,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(1, progress.completedLearnables);
}
/// <summary>
/// Test whether when updating a Learnable, the progress is capped at -5
/// </summary>
[Test]
public void Test_SavedCourseProgress_UpdateLearnable_CropsProgressAtNegativeFive()
{
@ -737,6 +921,9 @@ public class PersistentDataControllerTests
Assert.AreEqual(0, progress.completedLearnables);
}
/// <summary>
/// Test whether a Learnable can be fountd correctly
/// </summary>
[Test]
public void Test_SavedCourseProgress_FindLearnable()
{
@ -748,6 +935,9 @@ public class PersistentDataControllerTests
Assert.IsNotNull(progress.FindLearnable("learnable 2"));
}
/// <summary>
/// Test whether no Learnable is returned when there are no learnables
/// </summary>
[Test]
public void Test_SavedCourseProgress_GetRandomLearnable_NoLearnables()
{
@ -755,6 +945,9 @@ public class PersistentDataControllerTests
Assert.IsNull(progress.GetRandomLearnable());
}
/// <summary>
/// Test whether no Learnable is returned when there are no unused learnables
/// </summary>
[Test]
public void Test_SavedCourseProgress_GetRandomLearnable_NoUnusedLearnables()
{
@ -767,6 +960,9 @@ public class PersistentDataControllerTests
Assert.IsNull(progress.GetRandomLearnable());
}
/// <summary>
/// Test whether no Learnable is returned when there are only completed learnables
/// </summary>
[Test]
public void Test_SavedCourseProgress_GetRandomLearnable_OnlyCompletedLearnables()
{
@ -784,6 +980,9 @@ public class PersistentDataControllerTests
Assert.IsNull(progress.GetRandomLearnable());
}
/// <summary>
/// Test whether a random Learnable is returned
/// </summary>
[Test]
public void Test_SavedCourseProgress_GetRandomLearnable_Valid()
{

View File

@ -8,18 +8,27 @@ using UnityEngine.SceneManagement;
[TestFixture]
public class SystemControllerTests
{
/// <summary>
/// Test whether the singleton instance is correctly returned
/// </summary>
[Test]
public void Test_SystemController_GetInstance()
{
Assert.IsNotNull(SystemController.GetInstance());
}
/// <summary>
/// Test whether a non valid scene also yields a non valid index
/// </summary>
[Test]
public void Test_GetSceneIndex_InvalidScene()
{
Assert.AreEqual(-1, SystemController.GetSceneIndex("a/non/existing/scene"));
}
/// <summary>
/// Test whether a valid scene also yields a valid index
/// </summary>
[Test]
public void Test_GetSceneIndex_ValidScene()
{

View File

@ -6,7 +6,6 @@ using UnityEngine;
[CreateAssetMenu(menuName = "Create new Scriptable/Course")]
public class Course : ScriptableObject
{
/// <summary>
/// Index of the course
/// </summary>

View File

@ -1,7 +1,6 @@
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Keep track off installed minigames
/// </summary>

View File

@ -2,6 +2,7 @@ using NatML;
using System;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// This scriptable will hold tupples of Courseindices and models
/// </summary>
@ -33,7 +34,6 @@ public class ModelList : ScriptableObject
public TextAsset embeddingsFile;
}
/// <summary>
/// A list of all the models
/// </summary>
@ -61,7 +61,6 @@ public class ModelList : ScriptableObject
return null;
}
/// <summary>
/// Function to check if the modelIndex has been set
/// </summary>
@ -80,11 +79,19 @@ public class ModelList : ScriptableObject
currentModelIndex = models.FindIndex((m) => m.index == index);
}
/// <summary>
/// Shortcut for getting the index of the current model
/// </summary>
/// <returns></returns>
public ModelIndex GetCurrentModelIndex()
{
return models[currentModelIndex].index;
}
/// <summary>
/// Shortcut for getting the embeddings TextAsset of the current model
/// </summary>
/// <returns></returns>
public TextAsset GetEmbeddings()
{
return models[currentModelIndex].embeddingsFile;

View File

@ -28,10 +28,8 @@ public class Theme : ScriptableObject
/// </summary>
public ModelIndex modelIndex;
/// <summary>
/// List of all learnable words/letters
/// </summary>
public List<Learnable> learnables = new List<Learnable>();
}

View File

@ -1,7 +1,6 @@
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Keep track off defined themes
/// </summary>

View File

@ -20,7 +20,6 @@ public class BootScreen : MonoBehaviour
/// <summary>
/// Request authorization and check whether at least 1 webcam is available
/// </summary>
/// <returns>IEnumerator object</returns>
IEnumerator Start()
{
UserList.AVATARS = sprites.avatars;
@ -57,6 +56,4 @@ public class BootScreen : MonoBehaviour
errorText.text = "Zorg ervoor dat deze applicatie toegang heeft tot je webcam!";
}
}
}

View File

@ -8,12 +8,21 @@ using UnityEngine.UI;
/// </summary>
public class CourseActivityScreen : MonoBehaviour
{
// vvv TEMPORARY STUFF vvv
/// <summary>
/// Reference to the 'continue playing' button
/// </summary>
public GameObject playButton;
public GameObject previewButton;
// ^^^ TEMPORARY STUFF ^^^
/// <summary>
/// Reference to the 'play in preview mode' button
/// </summary>
public GameObject previewButton;
/// <summary>
/// Reference to the 'restart from beginning' button
/// </summary>
public GameObject restartButton;
/// <summary>
/// Reference to the courses
/// </summary>
@ -39,7 +48,6 @@ public class CourseActivityScreen : MonoBehaviour
/// </summary>
public Image courseImage;
/// <summary>
/// Progress bar Display
/// </summary>
@ -68,15 +76,12 @@ public class CourseActivityScreen : MonoBehaviour
int index = courseList.currentCourseIndex;
Course course = courseList.courses[index];
// vvv TEMPORARY STUFF vvv
playButton.SetActive(course.theme.modelIndex != ModelIndex.NONE);
previewButton.SetActive(course.theme.modelIndex == ModelIndex.NONE);
// ^^^ TEMPORARY STUFF ^^^
title.text = course.title;
description.text = course.description;
courseImage.sprite = course.thumbnail;
//progressBar.value = progressValue;
// Set progress
PersistentDataController.GetInstance().Load();

View File

@ -77,6 +77,5 @@ public class CourseItem : MonoBehaviour
courseList.SetCurrentCourse(course.index);
SystemController.GetInstance().LoadNextScene("Common/Scenes/CourseActivityScreen");
});
}
}

View File

@ -2,6 +2,9 @@ using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.UI;
/// <summary>
/// Manager for the settings screen
/// </summary>
public class SettingsScreen : MonoBehaviour
{
/// <summary>

View File

@ -7,6 +7,9 @@ using UnityEngine;
[TestFixture]
public class CourseListTests
{
/// <summary>
/// Reference to the courses list, for quick access
/// </summary>
private CourseList courseList;
/// <summary>

View File

@ -7,6 +7,9 @@ using UnityEngine;
[TestFixture]
public class MinigameListTests
{
/// <summary>
/// Reference to the minigames list, for quick access
/// </summary>
private MinigameList minigameList;
/// <summary>

View File

@ -1,12 +1,16 @@
using NatML;
using NUnit.Framework;
using UnityEngine;
/// <summary>
/// Test the ModelList class
/// </summary>
[TestFixture]
public class ModelListTests
{
/// <summary>
/// Reference to the model list, for quick access
/// </summary>
private ModelList modelList;
/// <summary>
@ -35,6 +39,7 @@ public class ModelListTests
}
}
}
/// <summary>
/// Check if current model can be correctly gotten as current via GetCurrentModel
/// </summary>

View File

@ -7,6 +7,9 @@ using UnityEngine;
[TestFixture]
public class ThemeListTests
{
/// <summary>
/// Reference to the themelist, for quick access
/// </summary>
private ThemeList themeList;
/// <summary>

View File

@ -8,8 +8,16 @@ using UnityEngine;
[TestFixture]
public class ThemeTests
{
/// <summary>
/// Reference to the current theme, for quick access
/// </summary>
private Theme theme;
/// <summary>
/// The names of custom learnables for a custom theme
/// </summary>
private List<string> names = new List<string>() { "appel", "peer", "banaan" };
/// <summary>
/// Setup a theme with some learnables in it
/// </summary>
@ -24,6 +32,7 @@ public class ThemeTests
theme.learnables.Add(learnable);
}
}
/// <summary>
/// Test if all the learnables are stored in the theme
/// </summary>

View File

@ -5,12 +5,14 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
/// <summary>
/// Test the BackButton class
/// </summary>
public class BackButtonTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -39,12 +41,11 @@ public class BackButtonTests
/// <summary>
/// Tests returning to the previous screen with the backbutton
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator BackTest()
{
var backButton = GameObject.FindObjectOfType<BackButton> ();
var backButton = GameObject.FindObjectOfType<BackButton>();
backButton.Back();
yield return new WaitForSeconds(0.2f);

View File

@ -6,13 +6,14 @@ using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
public class StartGamesTests
/// <summary>
/// Test the BootScreen class
/// </summary>
public class BootScreenTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator BootWithUsersTest()
{
@ -44,6 +45,7 @@ public class StartGamesTests
}
Assert.IsNull(userCreationScreen);
}
/// <summary>
/// Cleanup after testing
/// </summary>
@ -56,7 +58,6 @@ public class StartGamesTests
/// <summary>
/// Test booting without user
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator BootWithoutUsersTest()
{
@ -88,5 +89,4 @@ public class StartGamesTests
}
Assert.IsNull(mainMenuScreen);
}
}

View File

@ -5,12 +5,14 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
public class CourseActivityTests
/// <summary>
/// Test the CourseActivityScreen class
/// </summary>
public class CourseActivityScreenTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -33,10 +35,10 @@ public class CourseActivityTests
{
PersistentDataController.PATH = null;
}
/// <summary>
/// Full tests of the CoursesActivityScreen
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator CoursesActivityTest()
{

View File

@ -1,14 +1,20 @@
using NUnit.Framework;
using UnityEngine.UI;
using System.Collections;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
using UnityEngine.UI;
/// <summary>
/// Test the CourseItem class
/// </summary>
public class CourseItemTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
[UnitySetUp]
public IEnumerator SetupFunction()
{

View File

@ -5,12 +5,14 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
/// <summary>
/// Test the CourseMenuScreen class
/// </summary>
public class CourseMenuScreenTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{

View File

@ -5,6 +5,9 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
/// <summary>
/// Test the ListCoursesScreen class
/// </summary>
public class ListCoursesScreenTests
{
/// <summary>

View File

@ -5,6 +5,9 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
/// <summary>
/// Test the ListMinigamesScreen class
/// </summary>
public class ListMinigamesScreenTests
{
/// <summary>

View File

@ -6,7 +6,9 @@ using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
/// <summary>
/// Test the MainMenuScreen class
/// </summary>
public class MainMenuScreenTests
{
/// <summary>
@ -112,6 +114,7 @@ public class MainMenuScreenTests
Assert.IsNotNull(backbutton);
backbutton.GetComponent<UnityEngine.UI.Button>().onClick.Invoke();
}
/// <summary>
/// Tests the QuicApplication function of the MainMenuScreen
/// </summary>
@ -121,6 +124,5 @@ public class MainMenuScreenTests
var mainMenuScreen = GameObject.FindObjectOfType<MainMenuScreen>();
mainMenuScreen.QuitApplication();
yield return new WaitForSeconds(0.2f);
}
}

View File

@ -5,13 +5,14 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
public class MiniGameActivityScreenTests
/// <summary>
/// Test the MinigameActivityScreen class
/// </summary>
public class MinigameActivityScreenTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -25,6 +26,7 @@ public class MiniGameActivityScreenTests
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListMinigamesScreen");
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Cleanup after testing
/// </summary>
@ -37,7 +39,6 @@ public class MiniGameActivityScreenTests
/// <summary>
/// Test loading the spellingbee minigame
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator GotoSpellingBeeTest()
{
@ -45,12 +46,11 @@ public class MiniGameActivityScreenTests
listMinigamesScreen.minigameList.SetCurrentMinigame(MinigameIndex.SPELLING_BEE);
listMinigamesScreen.LoadScene("Common/Scenes/MinigameActivityScreen");
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Test loading the Hangman minigame
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator GotoHangmanTest()
{
@ -58,12 +58,11 @@ public class MiniGameActivityScreenTests
listMinigamesScreen.minigameList.SetCurrentMinigame(MinigameIndex.HANGMAN);
listMinigamesScreen.LoadScene("Common/Scenes/MinigameActivityScreen");
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Test loading the JustSign minigame
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator GotoJustSignTest()
{
@ -71,20 +70,18 @@ public class MiniGameActivityScreenTests
listMinigamesScreen.minigameList.SetCurrentMinigame(MinigameIndex.JUST_SIGN);
listMinigamesScreen.LoadScene("Common/Scenes/MinigameActivityScreen");
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Check if Progress is loading correctly
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator ProgressLoadTest()
{
string path = $"{Application.persistentDataPath}/wesign_unit_test.json";
string minigame = "{\"entries\":[],\"minigameIndex\":1,\"latestScores\":[{\"scoreValue\":70,\"time\":\"19/04/2023 22:32:39\"},{\"scoreValue\":55,\"time\":\"20/04/2023 11:50:10\"},{\"scoreValue\":55,\"time\":\"20/04/2023 13:27:15\"}],\"highestScores\":[{\"scoreValue\":70,\"time\":\"19/04/2023 22:32:39\"},{\"scoreValue\":55,\"time\":\"20/04/2023 11:50:10\"},{\"scoreValue\":55,\"time\":\"20/04/2023 13:27:15\"}]}";
string oneUser = $"{{\"version\":1027,\"users\":[{{\"entries\":[],\"username\":\"Tester0\",\"avatarIndex\":0,\"playtime\":0.0,\"minigames\":[{minigame}],\"courses\":[]}}],\"currentUser\":0,\"currentMinigame\":0,\"currentCourse\":0,\"currentTheme\":0}}";
File.WriteAllText(path, oneUser);
PersistentDataController.PATH = path;
PersistentDataController.GetInstance().Load();
@ -96,8 +93,6 @@ public class MiniGameActivityScreenTests
listMinigamesScreen.minigameList.SetCurrentMinigame(MinigameIndex.HANGMAN);
listMinigamesScreen.LoadScene("Common/Scenes/MinigameActivityScreen");
yield return new WaitForSeconds(0.2f);
}
}

View File

@ -1,18 +1,20 @@
using NUnit.Framework;
using UnityEngine.UI;
using System.Collections;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
using UnityEngine.UI;
/// <summary>
/// Test the MinigameItem class
/// </summary>
public class MinigameItemTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -26,6 +28,7 @@ public class MinigameItemTests
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListMinigamesScreen");
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Cleanup after testing
/// </summary>
@ -38,7 +41,6 @@ public class MinigameItemTests
/// <summary>
/// Test the callback function of a MinigameItem
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator CallBackTest()
{

View File

@ -1,18 +1,20 @@
using NUnit.Framework;
using UnityEngine.UI;
using System.Collections;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
using UnityEngine.UI;
/// <summary>
/// Test the ThemeItem class
/// </summary>
public class ThemeItemTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -26,6 +28,7 @@ public class ThemeItemTests
SystemController.GetInstance().LoadNextScene("Common/Scenes/ListMinigamesScreen");
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Cleanup after testing
/// </summary>
@ -34,10 +37,10 @@ public class ThemeItemTests
{
PersistentDataController.PATH = null;
}
/// <summary>
/// Test the callback function of a ThemeItem
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator CallBackTest()
{
@ -58,6 +61,6 @@ public class ThemeItemTests
yield return new WaitForSeconds(0.2f);
Assert.AreEqual("SpellingBeeGame", SceneManager.GetActiveScene().name);
Assert.AreEqual("SpellingBeeGame", SceneManager.GetActiveScene().name);
}
}

View File

@ -1,16 +1,18 @@
using UnityEditor;
using NUnit.Framework;
using System.Collections;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
using NUnit.Framework;
/// <summary>
/// Test the UserButton class
/// </summary>
public class UserButtonTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -37,7 +39,6 @@ public class UserButtonTests
/// <summary>
/// Test the ChangeUserCallback on the UserButton
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator ChangeUserCallbackTest()
{
@ -52,7 +53,6 @@ public class UserButtonTests
/// <summary>
/// Test if the username and avatar are correctly loaded
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator CorrectUsernameAndAvatarTest()
{
@ -63,10 +63,10 @@ public class UserButtonTests
yield return null;
}
/// <summary>
/// Test the transition to UserProgressScreen
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator ChangeSceneToUserProgressScreenTest()
{
@ -78,10 +78,10 @@ public class UserButtonTests
var userProgressScreen = GameObject.FindObjectOfType<UserProgressScreen>();
Assert.IsNotNull(userProgressScreen, "Scene was not correctly changed to UserProgressScreen.");
}
/// <summary>
/// Test is the user dropdown menu works correctly
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator ToggleDropdownTest()
{

View File

@ -93,6 +93,9 @@ public class CoursesController : AbstractFeedback
/// </summary>
private Image feedbackProgressImage;
/// <summary>
/// Reference to the video player
/// </summary>
public VideoPlayer videoPlayer;
/// <summary>
@ -206,7 +209,7 @@ public class CoursesController : AbstractFeedback
/// </summary>
public void StartCourseController()
{
// Setting up course
course = courselist.courses[courselist.currentCourseIndex];
maxWords = course.theme.learnables.Count;
@ -333,9 +336,10 @@ public class CoursesController : AbstractFeedback
private GameObject SetupPanel()
{
if (corruptPanelId == true)
{
{
(currentWordIndex, panelId) = (1, CorruptedPanelIDValue);
} else
}
else
{
(currentWordIndex, panelId) = FetchSign().ToValueTuple();
}
@ -432,7 +436,7 @@ public class CoursesController : AbstractFeedback
if (currentWordIndex < course.theme.learnables.Count && panelId != 1 && !hasAnswered)
{
// Get current sign
Learnable sign = course.theme.learnables[currentWordIndex];
string currentSign = sign.name.ToUpper().Replace(" ", "-");
@ -552,6 +556,10 @@ public class CoursesController : AbstractFeedback
}
/// <summary>
/// Wait 0.75 seconds and proceed to the next sign
/// </summary>
/// <returns></returns>
private IEnumerator WaitNextSign()
{
// Wait for 0.75 seconds
@ -588,7 +596,7 @@ public class CoursesController : AbstractFeedback
UserList.Save();
SystemController.GetInstance().BackToPreviousScene();
}
/// <summary>
/// Returns panelId for testing
/// </summary>
@ -597,6 +605,7 @@ public class CoursesController : AbstractFeedback
{
return panelId;
}
/// <summary>
/// Returns currentSign for testing
/// </summary>
@ -606,6 +615,7 @@ public class CoursesController : AbstractFeedback
Learnable sign = course.theme.learnables[currentWordIndex];
return sign.name.ToUpper().Replace(" ", "-");
}
/// <summary>
/// Used for testing an out of bounds PanelId
/// </summary>
@ -642,6 +652,4 @@ public class CoursesController : AbstractFeedback
CorruptedPanelIDValue = 1;
yield return CRNextSign();
}
}

View File

@ -1,12 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
using System.Linq;
/// <summary>
/// Class to handle panel with multiple choice options
/// </summary>
public class PanelMultipleChoice : MonoBehaviour
{
/// <summary>
@ -108,7 +110,7 @@ public class PanelMultipleChoice : MonoBehaviour
}
List<Learnable> randomSigns = new List<Learnable>();
foreach(var sign in test.Take(3))
foreach (var sign in test.Take(3))
{
randomSigns.Add(signs[sign.index]);
}
@ -152,7 +154,6 @@ public class PanelMultipleChoice : MonoBehaviour
}
});
}
}
/// <summary>
@ -211,13 +212,11 @@ public class PanelMultipleChoice : MonoBehaviour
playButton.sprite = pauseSprite;
videoPlayer.Play();
}
else
{
// Pause video and and switch sprite of button
playButton.sprite = playSprite;
videoPlayer.Pause();
}
}
}

View File

@ -3,10 +3,24 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Class to handle panel with only image and webcam
/// </summary>
public class PanelWithImage : MonoBehaviour
{
/// <summary>
/// Reference to the feedback progress bar
/// </summary>
public GameObject feedbackProgressObject;
/// <summary>
/// Reference to the object containing the message for when the course is loaded in preview mode
/// </summary>
public GameObject previewMessage;
/// <summary>
/// True if the course is loaded in preview mode, false otherwise
/// </summary>
public bool isPreview;
/// <summary>
@ -14,8 +28,14 @@ public class PanelWithImage : MonoBehaviour
/// </summary>
public Transform signImageContainer;
/// <summary>
/// Reference to the prefab for displaying the image
/// </summary>
public GameObject signImagePrefab;
/// <summary>
/// Reference to the webcam
/// </summary>
public RawImage webcamScreen;
/// <summary>
@ -33,9 +53,19 @@ public class PanelWithImage : MonoBehaviour
/// </summary>
public Image feedbackProgressImage;
/// <summary>
/// Reference to the list of learnables
/// </summary>
public List<Learnable> signs;
/// <summary>
/// Index of the current learnable in the list with learnables
/// </summary>
public int currentSignIndex;
/// <summary>
/// Update the display of this panel
/// </summary>
public void Display()
{
Learnable currentSign = signs[currentSignIndex];

View File

@ -4,20 +4,49 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Video;
/// <summary>
/// Class to handle panel with image, video and webcam
/// </summary>
public class PanelWithVideoAndImage : MonoBehaviour
{
/// <summary>
/// Reference to the feedback progress bar
/// </summary>
public GameObject feedbackProgressObject;
/// <summary>
/// Reference to the object containing the message for when the course is loaded in preview mode
/// </summary>
public GameObject previewMessage;
/// <summary>
/// True if the course is loaded in preview mode, false otherwise
/// </summary>
public bool isPreview;
/// <summary>
/// Video 'play' sprite
/// </summary>
public Sprite playSprite;
/// <summary>
/// Video 'pause' sprite
/// </summary>
public Sprite pauseSprite;
/// <summary>
/// Reference to instructional video player
/// </summary>
public VideoPlayer videoPlayer;
/// <summary>
/// Refrence to the video play/pause button
/// </summary>
public Image playButton;
/// <summary>
/// Reference to the webcam
/// </summary>
public RawImage webcamScreen;
/// <summary>
@ -25,6 +54,9 @@ public class PanelWithVideoAndImage : MonoBehaviour
/// </summary>
public Transform signImageContainer;
/// <summary>
/// Reference to the prefab for displaying the image
/// </summary>
public GameObject signImagePrefab;
/// <summary>
@ -42,9 +74,19 @@ public class PanelWithVideoAndImage : MonoBehaviour
/// </summary>
public Image feedbackProgressImage;
/// <summary>
/// Reference to the list of learnables
/// </summary>
public List<Learnable> signs;
/// <summary>
/// Index of the current learnable in the list with learnables
/// </summary>
public int currentSignIndex;
/// <summary>
/// Update the display of this panel
/// </summary>
public void Display()
{
Learnable currentSign = signs[currentSignIndex];
@ -79,13 +121,11 @@ public class PanelWithVideoAndImage : MonoBehaviour
playButton.sprite = pauseSprite;
videoPlayer.Play();
}
else
{
// Pause video and and switch sprite of button
playButton.sprite = playSprite;
videoPlayer.Pause();
}
}
}

View File

@ -1,20 +1,20 @@
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
/// <summary>
/// Test the PanelMultipleChoice, PanelWithImage, and PanelWithVideoAndImage classes
/// </summary>
[TestFixture]
public class PaneTests
public class CoursePanelsTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -45,11 +45,12 @@ public class PaneTests
yield return null;
}
/// <summary>
/// Cleanup after testing
/// </summary>
[TearDown]
public void TearDown_PaneTests()
public void TearDown_PanelTests()
{
PersistentDataController.PATH = null;
}
@ -57,7 +58,6 @@ public class PaneTests
/// <summary>
/// Test pausing/resuming the video in all course panels
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator PlayPauseTest()
{
@ -71,10 +71,10 @@ public class PaneTests
panel.TogglePlayPause();
yield return null;
Assert.IsTrue(panel.videoPlayer.isPlaying == false);
Assert.IsFalse(panel.videoPlayer.isPlaying);
panel.TogglePlayPause();
yield return null;
Assert.IsTrue(panel.videoPlayer.isPlaying == true);
Assert.IsTrue(panel.videoPlayer.isPlaying);
yield return coursesController.SummonMultipleChoice();
@ -83,11 +83,10 @@ public class PaneTests
panel2.TogglePlayPause();
yield return null;
Assert.IsTrue(panel2.videoPlayer.isPlaying == false);
Assert.IsFalse(panel2.videoPlayer.isPlaying);
panel2.TogglePlayPause();
yield return null;
Assert.IsTrue(panel2.videoPlayer.isPlaying == true);
Assert.IsTrue(panel2.videoPlayer.isPlaying);
yield return null;
}
}

View File

@ -4,17 +4,19 @@ using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using UnityEngine.TestTools;
using UnityEngine.UI;
/// <summary>
/// Test the CoursesController class
/// </summary>
[TestFixture]
public class CoursesControllerTests
{
/// <summary>
/// Setup the environment before each test
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -31,7 +33,6 @@ public class CoursesControllerTests
var mainMenuScreen = GameObject.FindObjectOfType<MainMenuScreen>();
mainMenuScreen.GotoCourses();
yield return null;
}
/// <summary>
@ -42,13 +43,13 @@ public class CoursesControllerTests
{
PersistentDataController.PATH = null;
}
/// <summary>
/// Function used to Spoof the sign predictor. The it uses 0f as certainty so the sign is "perfect".
/// Function used to spoof the sign predictor. It uses 0.0f as certainty so the sign is "perfect".
/// </summary>
/// <param name="sign"></param>
/// <param name="signPredictor"></param>
/// <returns></returns>
public IEnumerator SignLetter(string sign, SignPredictor signPredictor)
private IEnumerator SignLetter(string sign, SignPredictor signPredictor)
{
signPredictor.learnableProbabilities = new Dictionary<string, float>();
// Loop through all capital letters of the alphabet
@ -66,11 +67,10 @@ public class CoursesControllerTests
yield return listener.ProcessIncomingCall();
}
}
/// <summary>
/// Simulates a little playtrough of a course
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator PlaytroughTest()
{
@ -115,6 +115,7 @@ public class CoursesControllerTests
coursesController.ReturnToActivityScreen();
yield return new WaitForSeconds(1.0f);
}
/// <summary>
/// Tests a preview course
/// </summary>
@ -208,10 +209,10 @@ public class CoursesControllerTests
yield return coursesController.CallSetupPanel();
yield return new WaitForSeconds(0.2f);
}
/// <summary>
/// Tests what happens when the sign is correct but not certain enough
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator UnconfidentTest()
{
@ -251,10 +252,10 @@ public class CoursesControllerTests
yield return new WaitForSeconds(1.0f);
Assert.AreEqual(coursesController.GetCurrentSign(), "A");
}
/// <summary>
/// Test what happens when an incorrect sign is signed
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator IncorrectSignTest()
{
@ -280,10 +281,10 @@ public class CoursesControllerTests
yield return new WaitForSeconds(1.0f);
Assert.AreEqual(coursesController.GetCurrentSign(), "A");
}
/// <summary>
/// Test what happens when there is no sign being signed
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator NoSignTest()
{
@ -309,10 +310,10 @@ public class CoursesControllerTests
yield return new WaitForSeconds(1.0f);
Assert.AreEqual(coursesController.GetCurrentSign(), "A");
}
/// <summary>
/// Tests what happens when a wrong sign is performed twice but with a long enough interval
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator TwoWrongFastTest()
{
@ -345,10 +346,10 @@ public class CoursesControllerTests
Assert.AreEqual(coursesController.GetCurrentSign(), "A");
}
/// <summary>
/// Tests what happens when the sign can not be processed but the Feedback is not Null
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator FeedbackNotNullTest()
{

View File

@ -6,6 +6,9 @@ using UnityEngine;
using UnityEngine.UI;
using Random = UnityEngine.Random;
/// <summary>
/// The Hangman game controller
/// </summary>
public class HangmanController : AbstractMinigameController
{
[Header("ConcreteVariables")]
@ -166,11 +169,6 @@ public class HangmanController : AbstractMinigameController
/// </summary>
public TMP_Text confirmText;
///// <summary>
///// Temporary reference to timer to turn it off
///// </summary>
//public GameObject timer;
/// <summary>
/// Maximum length of the words
/// </summary>
@ -249,9 +247,6 @@ public class HangmanController : AbstractMinigameController
scoreDisplay.text = $"Score: {CalculateScore()}";
scoreBonus.text = "";
// Temporary
//timer.SetActive(true);
}
/// <summary>
@ -286,9 +281,6 @@ public class HangmanController : AbstractMinigameController
confirmPanel.SetActive(false);
signPredictor.SwapScreen(script.webcamScreen);
//temporarily turn off timer in input-mode
//timer.SetActive(false);
}
/// <summary>
@ -335,6 +327,7 @@ public class HangmanController : AbstractMinigameController
StartGame();
}
}
/// <summary>
/// Update is called once per frame
/// </summary>
@ -371,6 +364,7 @@ public class HangmanController : AbstractMinigameController
});
}
}
/// <summary>
/// Functionality to be called when the backspace-key is pressed during input-mode
/// </summary>
@ -384,6 +378,7 @@ public class HangmanController : AbstractMinigameController
}
Input.ResetInputAxes();
}
/// <summary>
/// Handles sign logic, so that it does not have to run every frame
/// This function is called when the UpdateFeedback has accepted a letter
@ -417,6 +412,7 @@ public class HangmanController : AbstractMinigameController
break;
}
}
/// <summary>
/// Takes the currentSign and tries to enter it into the word if playing
/// When in input-mode it will just add the letter to the currentWord
@ -469,6 +465,7 @@ public class HangmanController : AbstractMinigameController
SwitchMode(1);
}
}
/// <summary>
/// The letter got rejected, start the letter-fetching process again
/// </summary>
@ -482,6 +479,7 @@ public class HangmanController : AbstractMinigameController
else if (mode == 4)
SwitchMode(1);
}
/// <summary>
/// Outside function to switch the modes this allows the gameIsactive-logic to be properly attached to the modes
/// </summary>
@ -499,6 +497,7 @@ public class HangmanController : AbstractMinigameController
gameIsActive = false;
}
}
/// <summary>
/// Change the image that is being displayed
/// </summary>
@ -515,6 +514,7 @@ public class HangmanController : AbstractMinigameController
scoreBonus.text = $"{INCORRECT_LETTER_SCORE}";
scoreBonus.color = new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f);
}
/// <summary>
/// In this function, the letters of the word selected in DisplayWord are updated after a correct guess.
/// </summary>
@ -542,6 +542,7 @@ public class HangmanController : AbstractMinigameController
scoreBonus.text = $"+{hits * CORRECT_LETTER_SCORE}";
scoreBonus.color = new Color(0x8b / 255.0f, 0xd4 / 255.0f, 0x5e / 255.0f);
}
/// <summary>
/// This function returns the score that the user currently has
/// </summary>
@ -551,6 +552,7 @@ public class HangmanController : AbstractMinigameController
int won = corrects == currentWord.Length ? 1 : 0;
return corrects * CORRECT_LETTER_SCORE + wrongs * INCORRECT_LETTER_SCORE + WIN_SCORE * won;
}
/// <summary>
/// Delete all letter objects
/// </summary>
@ -562,6 +564,7 @@ public class HangmanController : AbstractMinigameController
}
letters.Clear();
}
/// <summary>
/// Displays the word that needs to be spelled
/// </summary>
@ -581,6 +584,7 @@ public class HangmanController : AbstractMinigameController
txt.text = c == ' ' ? "" : Char.ToString('_');
}
}
/// <summary>
/// The logic to process the signs sent by the signPredictor
/// </summary>
@ -670,6 +674,7 @@ public class HangmanController : AbstractMinigameController
timerCircle.fillAmount = currentTime;
}
}
/// <summary>
/// The logic to set the scoreboard of hangman
/// </summary>
@ -694,6 +699,7 @@ public class HangmanController : AbstractMinigameController
score: CalculateScore()
);
}
/// <summary>
/// The hangman-specific logic that needs to be called at the start of the game
/// </summary>
@ -724,27 +730,50 @@ public class HangmanController : AbstractMinigameController
DeleteWord();
}
// The following functions are only used for testing
/// <summary>
/// Get this.currentWord, FOR TESTING ONLY
/// </summary>
public string getCurrentWord()
{
return currentWord;
}
/// <summary>
/// Get this.mode, FOR TESTING ONLY
/// </summary>
public int getCurrentMode()
{
return mode;
}
/// <summary>
/// Get this.corrects, FOR TESTING ONLY
/// </summary>
public int getCorrects()
{
return corrects;
}
/// <summary>
/// Get this.wrongs, FOR TESTING ONLY
/// </summary>
public int getWrongs()
{
return wrongs;
}
/// <summary>
/// Get this.userLettersText.text, FOR TESTING ONLY
/// </summary>
public string getUsedLetters()
{
return usedLettersText.text;
}
/// <summary>
/// Get this.currentTime, FOR TESTING ONLY
/// </summary>
public float getCurrentTime()
{
return currentTime;

View File

@ -1,8 +1,9 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// The hangman-variant of the ScoreBoard
/// The Hangman-variant of the ScoreBoard
/// </summary>
public class HangmanGameEndedPanel : AbstractGameEndedPanel
{
@ -23,6 +24,10 @@ public class HangmanGameEndedPanel : AbstractGameEndedPanel
/// Letters ( right | wrong )
/// </summary>
public TMP_Text lettersRightText;
/// <summary>
/// Letters ( right | wrong )
/// </summary>
public TMP_Text lettersWrongText;
/// <summary>

View File

@ -2,6 +2,9 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// The panel for holding the actual game in Hangman
/// </summary>
public class PanelHangmanGame : MonoBehaviour
{
/// <summary>

View File

@ -2,6 +2,9 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// The mulitplayer panel for Hangman
/// </summary>
public class PanelMultiplayerInput : MonoBehaviour
{
/// <summary>

View File

@ -7,16 +7,25 @@ using System.Linq;
using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
/// <summary>
/// Test the HangmanController class
/// </summary>
public class HangmanPlaymodeTests
{
/// <summary>
/// Reference to the HangmanController so we can access it quickly
/// </summary>
private HangmanController hangmanController;
/// <summary>
/// The mode of the multiple choice panel that when the confirm button needs to be clicked
/// </summary>
private int multiplayerConfirmInput = 4;
/// <summary>
/// SetupFunction to reach the hangman-game
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -93,7 +102,6 @@ public class HangmanPlaymodeTests
/// <summary>
/// Tests the singleplayer functionality, only the winning side as losing is easier when the word is chosen beforehand.
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator SinglePlayerTests()
{
@ -188,7 +196,6 @@ public class HangmanPlaymodeTests
/// <summary>
/// Tests the multiplayer-code
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator MultiPlayerTests()
{
@ -259,7 +266,6 @@ public class HangmanPlaymodeTests
/// <summary>
/// Tests some remaning functionality regarding the feedback that isn't contained in the previous tests
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator SignChangingTest()
{
@ -301,7 +307,6 @@ public class HangmanPlaymodeTests
/// <summary>
/// Test the functionality of the scoreboard to display multiple games
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator ScoreBoardTest()
{

View File

@ -59,27 +59,27 @@ public class JustSignController : AbstractMinigameController
/// <summary>
/// Score obtained when getting a perfect hit
/// </summary>
private int perfectScore = 50;
private const int perfectScore = 50;
/// <summary>
/// Score obtained when getting a good hit
/// </summary>
private int goodScore = 20;
private const int goodScore = 20;
/// <summary>
/// Score obtained when getting a meh hit
/// </summary>
private int mehScore = 10;
private const int mehScore = 10;
/// <summary>
/// Score obtained when getting a terrible hit
/// </summary>
private int terribleScore = -3;
private const int terribleScore = -3;
/// <summary>
/// Score obtained when symbol goes offscreen
/// </summary>
private int offscreenScore = -5;
private const int offscreenScore = -5;
/// <summary>
/// Symbol prefab
@ -109,17 +109,17 @@ public class JustSignController : AbstractMinigameController
/// <summary>
/// Controls movement speed of symbols (higher -> faster)
/// </summary>
private int moveSpeed = 100;
private const int moveSpeed = 100;
/// <summary>
/// Starting X-coordinate of a symbol = (-1920 - symbolsize) / 2
/// </summary>
private int trackX = 1920 / 2;
private const int trackX = 1920 / 2;
/// <summary>
/// Starting Y-coordinate of a symbol
/// </summary>
private int trackY = 0;
private const int trackY = 0;
/// <summary>
/// Time at which the last symbol was spawned
@ -246,6 +246,9 @@ public class JustSignController : AbstractMinigameController
/// </summary>
public GameObject userFeedback;
/// <summary>
/// Get the current theme
/// </summary>
protected override Theme signPredictorTheme
{
get { return currentTheme; }

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// The JustSign-variant of the ScoreBoard
/// </summary>

View File

@ -1,5 +1,4 @@
using UnityEngine;
using UnityEngine.Audio;
/// <summary>
/// Class for holding all (static) data about a certain song

View File

@ -5,12 +5,14 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
/// <summary>
/// Test the JustSignController class
/// </summary>
public class JustSignControllerTests
{
/// <summary>
/// Setup for testing Just Sign
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -40,14 +42,13 @@ public class JustSignControllerTests
/// <summary>
/// Tests a sign that is done too quickly, i.e., feedback during game and scoreboard after
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator EarlyScoreTest()
{
JustSignController justSignController = GameObject.FindObjectOfType<JustSignController>();
yield return new WaitForSeconds(5.0f);
string currentSign = justSignController.GetFirstSign();
justSignController.ProcessMostProbableSign(1.0f, currentSign);
@ -75,7 +76,6 @@ public class JustSignControllerTests
/// <summary>
/// Tests a sign that is done too late, i.e., feedback during game and scoreboard after
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator TooLateScoreTest()
{
@ -105,7 +105,6 @@ public class JustSignControllerTests
/// <summary>
/// Tests a sign that is done in the meh-zone, i.e., feedback during game and scoreboard after
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator MehScoreTest()
{
@ -140,7 +139,6 @@ public class JustSignControllerTests
/// <summary>
/// Tests a sign that is done in the good-zone, i.e., feedback during game and scoreboard after
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator GoodScoreTest()
{
@ -175,7 +173,6 @@ public class JustSignControllerTests
/// <summary>
/// Tests a sign that is done in the perfect-zone, i.e., feedback during game and scoreboard after
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator PerfectScoreTest()
{
@ -210,7 +207,6 @@ public class JustSignControllerTests
/// <summary>
/// Tests the entire game, i.e., feedback during game and scoreboard after
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator WalkthroughTest()
{
@ -227,14 +223,14 @@ public class JustSignControllerTests
currentSign = justSignController.GetFirstSign();
justSignController.ProcessMostProbableSign(1.0f, currentSign);
Assert.AreEqual(justSignController.CalculateScore(), 7);
yield return new WaitForSeconds(6.0f);
currentSign = justSignController.GetFirstSign();
justSignController.ProcessMostProbableSign(1.0f, currentSign);
Assert.AreEqual(justSignController.CalculateScore(), 27);
yield return new WaitForSeconds(6.0f);
@ -243,7 +239,7 @@ public class JustSignControllerTests
justSignController.ProcessMostProbableSign(1.0f, currentSign);
Assert.AreEqual(justSignController.CalculateScore(), 77);
yield return new WaitForSeconds(10.0f);
Assert.AreEqual(justSignController.CalculateScore(), 72);
@ -259,14 +255,13 @@ public class JustSignControllerTests
Assert.AreEqual("1", justSignGameEndedPanel.terribleSignsText.text);
Assert.AreEqual("1", justSignGameEndedPanel.notFoundSignsText.text);
Assert.AreEqual("Score: 72", justSignGameEndedPanel.scoreText.text);
string gpmText = (60f * 4/ 64).ToString("#") + " GPM";
string gpmText = (60f * 4 / 64).ToString("#") + " GPM";
Assert.AreEqual(gpmText, justSignGameEndedPanel.gpmText.text);
}
/// <summary>
/// Tests if the game ends when the song does
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator SongEndTest()
{
@ -294,7 +289,6 @@ public class JustSignControllerTests
/// <summary>
/// Tests the feedback in the game
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator FeedbackTest()
{

View File

@ -1,6 +1,5 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Listener interface with an IEnumerator as its processing-function.
/// </summary>

View File

@ -4,6 +4,7 @@ using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Abstract class for all minigame-gameEndedPanels
/// </summary>
@ -16,7 +17,7 @@ public abstract class AbstractGameEndedPanel : MonoBehaviour
{
get;
}
/// <summary>
/// Reference to the scoreboard entries container
/// </summary>

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Shared abstract class for the minigameControllers
/// </summary>
@ -134,6 +135,7 @@ public abstract class AbstractMinigameController : AbstractFeedback
PersistentDataController.GetInstance().Save();
}
/// <summary>
/// The function that activates when the game ends, handles some endgame logic and displays the EndPanel
/// </summary>

View File

@ -2,17 +2,18 @@ using DigitalRuby.Tween;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// Contains all game logic for the SpellingBee game
/// </summary>
public partial class SpellingBeeController : AbstractMinigameController
{
/// <summary>
/// All of the words that can be used in this session
/// </summary>
//private string[] words;
private List<Learnable> words = new List<Learnable>();
/// <summary>
@ -154,12 +155,12 @@ public partial class SpellingBeeController : AbstractMinigameController
/// <summary>
/// Score obtained when spelling a letter
/// </summary>
private int correctLettersScore = 10;
private const int correctLettersScore = 10;
/// <summary>
/// Score obtained when spelling the wrong letter :o
/// </summary>
private int incorrectLettersScore = -5;
private const int incorrectLettersScore = -5;
/// <summary>
/// Set the AbstractMinigameController variable to inform it of the theme for the signPredictor
@ -198,7 +199,6 @@ public partial class SpellingBeeController : AbstractMinigameController
int seconds = Mathf.FloorToInt(timerValue % 60.0f);
timerText.text = string.Format("{0:00}:{1:00}", minutes, seconds);
}
}
@ -310,7 +310,6 @@ public partial class SpellingBeeController : AbstractMinigameController
}
else
{
//ActivateWin();
ActivateEnd(true);
}
}
@ -338,9 +337,8 @@ public partial class SpellingBeeController : AbstractMinigameController
}
/// <summary>
/// wait for 2 seconds
/// Wait for 2 seconds
/// </summary>
/// <returns></returns>
private IEnumerator Wait()
{
yield return new WaitForSecondsRealtime(2);
@ -458,7 +456,6 @@ public partial class SpellingBeeController : AbstractMinigameController
predictedSign = null;
previousIncorrectSign = null;
}
// Incorrect sign, wait a bit before passing it along
else
{
@ -475,7 +472,6 @@ public partial class SpellingBeeController : AbstractMinigameController
previousIncorrectSign = null;
}
}
}
}
@ -527,7 +523,6 @@ public partial class SpellingBeeController : AbstractMinigameController
bonusTimeText.SetActive(false);
currentTheme = minigame.themeList.themes[minigame.themeList.currentThemeIndex];
//feedback.signPredictor.SetModel(currentTheme.modelIndex);
words.AddRange(currentTheme.learnables);
ShuffleWords();
NextWord();

View File

@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// The SpellingBee-variant of the ScoreBoard
/// </summary>
public class SpellingBeeGameEndedPanel : AbstractGameEndedPanel
{
/// <summary>
@ -29,6 +28,10 @@ public class SpellingBeeGameEndedPanel : AbstractGameEndedPanel
/// Letters ( right | wrong )
/// </summary>
public TMP_Text lettersRightText;
/// <summary>
/// Letters ( right | wrong )
/// </summary>
public TMP_Text lettersWrongText;
/// <summary>

View File

@ -5,12 +5,14 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
/// <summary>
/// Test the SpellingBeeGameEndedPanel class
/// </summary>
public class SpellingBeeGameEndedPanelTests
{
/// <summary>
/// Setup for testing scoreboard of Spelling Bee
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -34,11 +36,10 @@ public class SpellingBeeGameEndedPanelTests
/// <summary>
/// Tests the scoreboard for Spelling Bee
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator ScoreTest()
{
SpellingBeeController spellingBeeController = (SpellingBeeController)GameObject.FindObjectOfType(typeof(SpellingBeeController));
var spellingBeeController = GameObject.FindObjectOfType<SpellingBeeController>();
spellingBeeController.NextWord();
spellingBeeController.NextLetter(false);
spellingBeeController.NextLetter(true);
@ -49,16 +50,13 @@ public class SpellingBeeGameEndedPanelTests
spellingBeeController.ActivateEnd(true);
// Fetch the panel with the info for the fields and check if the controller has implemented them
var script = GameObject.FindObjectOfType<SpellingBeeGameEndedPanel>();
SpellingBeeGameEndedPanel SpellingBeeGameEndedPanel = (SpellingBeeGameEndedPanel)GameObject.FindObjectOfType(typeof(SpellingBeeGameEndedPanel));
var SpellingBeeGameEndedPanel = GameObject.FindObjectOfType<SpellingBeeGameEndedPanel>();
Assert.NotNull(SpellingBeeGameEndedPanel);
Assert.AreEqual("Score: 0", SpellingBeeGameEndedPanel.scoreText.text);
Assert.AreEqual("1", SpellingBeeGameEndedPanel.lettersRightText.text);
Assert.AreEqual("2", SpellingBeeGameEndedPanel.lettersWrongText.text);
Assert.AreEqual("3", SpellingBeeGameEndedPanel.lettersTotalText.text);
Assert.AreEqual("00:01", SpellingBeeGameEndedPanel.timeText.text);
}
/// <summary>

View File

@ -5,12 +5,14 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.TestTools;
/// <summary>
/// Test the SpellingBeeController class
/// </summary>
public class SpellingBeeControllerTests
{
/// <summary>
/// Setup for testing Spelling Bee
/// </summary>
/// <returns></returns>
[UnitySetUp]
public IEnumerator SetupFunction()
{
@ -40,7 +42,6 @@ public class SpellingBeeControllerTests
/// <summary>
/// Tests the calculations of the score
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator CheckScoreTest()
{
@ -56,7 +57,6 @@ public class SpellingBeeControllerTests
/// <summary>
/// Tests the ending panel
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator ActivateGameOverTest()
{
@ -67,13 +67,11 @@ public class SpellingBeeControllerTests
SpellingBeeGameEndedPanel SpellingBeeGameEndedPanel = GameObject.FindObjectOfType<SpellingBeeGameEndedPanel>();
Assert.NotNull(SpellingBeeGameEndedPanel);
Assert.AreEqual("VERLOREN", SpellingBeeGameEndedPanel.endText.text);
}
/// <summary>
/// Tests the scoreboard in case of completion
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator ActivateWinTests()
{
@ -89,7 +87,6 @@ public class SpellingBeeControllerTests
/// <summary>
/// Tests the scoreboard when timer goes off
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator CheckGameOverTest()
{
@ -105,7 +102,6 @@ public class SpellingBeeControllerTests
/// <summary>
/// Tests the completion from a word and from the entire theme + scoreboard
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator CheckGoToNextWord()
{
@ -115,7 +111,7 @@ public class SpellingBeeControllerTests
spellingBeeController.PredictSign(spellingBeeController.GetSign());
yield return new WaitForSeconds(0.2f);
Assert.IsTrue(spellingBeeController.bonusTimeText.activeSelf);
yield return new WaitForSeconds(1.0f);
@ -137,7 +133,6 @@ public class SpellingBeeControllerTests
/// <summary>
/// Tests the feedback in the game
/// </summary>
/// <returns></returns>
[UnityTest]
public IEnumerator FeedbackTest()
{
@ -165,11 +160,11 @@ public class SpellingBeeControllerTests
yield return new WaitForSeconds(2.5f);
Assert.AreEqual($"Verkeerde gebaar: '{sign}'", spellingBeeController.feedbackText.text);
Assert.AreEqual(new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f), spellingBeeController.feedbackText.color);
Assert.AreEqual(new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f), spellingBeeController.feedbackText.color);
spellingBeeController.ProcessCurrentAndPredicted(0.9f * threshold, sign, distance, expected);
Assert.AreEqual(new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f), spellingBeeController.scoreBonus.color);
Assert.AreEqual(new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f), spellingBeeController.scoreBonus.color);
}
yield return new WaitForSeconds(0.2f);
@ -201,7 +196,7 @@ public class SpellingBeeControllerTests
Assert.AreEqual($"Verkeerde gebaar: '{sign}'", spellingBeeController.feedbackText.text);
Assert.AreEqual(new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f), spellingBeeController.feedbackText.color);
spellingBeeController.ProcessCurrentAndPredicted(0.9f * threshold, sign, distance, expected);
Assert.AreEqual(new Color(0xf5 / 255.0f, 0x49 / 255.0f, 0x3d / 255.0f), spellingBeeController.scoreBonus.color);