Resolve WES-181 "Missing code doc"
This commit is contained in:
committed by
Louis Adriaens
parent
7505ae7262
commit
3d99184717
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user