Test accounts
This commit is contained in:
committed by
Jelle De Geest
parent
fee989006c
commit
7b6eb4db69
@@ -1,150 +1,166 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Test the User class
|
||||
/// </summary>
|
||||
public class TestUser
|
||||
[TestFixture]
|
||||
public class UserTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference to the user to be tested
|
||||
/// </summary>
|
||||
private User user;
|
||||
|
||||
/// <summary>
|
||||
/// Setup the tests
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void Setup_User()
|
||||
{
|
||||
user = new User();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Test for the creation of a new user
|
||||
/// </summary>
|
||||
public void TestNewUser()
|
||||
[Test]
|
||||
public void Test_New_User()
|
||||
{
|
||||
User user = new User();
|
||||
Debug.Assert(user != null);
|
||||
Debug.Assert(user.courses.Count == 0);
|
||||
Debug.Assert(user.minigames.Count == 0);
|
||||
Assert.NotNull(user);
|
||||
Assert.Zero(user.courses.Count);
|
||||
Assert.Zero(user.minigames.Count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test whether progress on a new course can be added
|
||||
/// </summary>
|
||||
public void TestUserAddCourse()
|
||||
[Test]
|
||||
public void Test_User_AddCourse()
|
||||
{
|
||||
User user = new User();
|
||||
Progress p = new Progress();
|
||||
user.courses.Add(p);
|
||||
Debug.Assert(user.courses.Count == 1);
|
||||
Debug.Assert(user.minigames.Count == 0);
|
||||
Assert.AreEqual(user.courses.Count, 1);
|
||||
Assert.Zero(user.minigames.Count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test whether progress on a new minigame can be added
|
||||
/// </summary>
|
||||
public void TestUserAddMinigame()
|
||||
[Test]
|
||||
public void Test_User_AddMinigame()
|
||||
{
|
||||
User user = new User();
|
||||
Progress p = new Progress();
|
||||
user.minigames.Add(p);
|
||||
Debug.Assert(user.courses.Count == 0);
|
||||
Debug.Assert(user.minigames.Count == 1);
|
||||
Assert.Zero(user.courses.Count);
|
||||
Assert.AreEqual(user.minigames.Count, 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetRecentCourses will return empty when no progress is stored
|
||||
/// </summary>
|
||||
public void TestGetRecentCoursesEmpty()
|
||||
[Test]
|
||||
public void Test_User_GetRecentCourses_Empty()
|
||||
{
|
||||
User user = new User();
|
||||
Debug.Assert(user.GetRecentCourses().Count == 0);
|
||||
Assert.Zero(user.GetRecentCourses().Count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Temporary test for GetRecentCourses will return all progress that is stored
|
||||
/// TEMPORARY test for GetRecentCourses will return all progress that is stored
|
||||
/// </summary>
|
||||
public void TestGetRecentCoursesAll()
|
||||
[Test]
|
||||
public void Test_User_GetRecentCourses_All()
|
||||
{
|
||||
User user = new User();
|
||||
Progress p = new Progress();
|
||||
p.AddOrUpdate<CourseIndex>("courseIndex", CourseIndex.FINGERSPELLING);
|
||||
p.AddOrUpdate<float>("courseProgress", 0.5f);
|
||||
user.courses.Add(p);
|
||||
List<Tuple<CourseIndex, float>> list = user.GetRecentCourses();
|
||||
Debug.Assert(list.Count == 1);
|
||||
Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING);
|
||||
Debug.Assert(list[0].Item2 == 0.5f);
|
||||
Assert.AreEqual(list.Count, 1);
|
||||
Assert.AreEqual(list[0].Item1, CourseIndex.FINGERSPELLING);
|
||||
Assert.AreEqual(list[0].Item2, 0.5f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetRecommendedCourses will return <c>Tuple<CourseIndex.FINGERSPELLING, 0.0></c> when no progress is stored
|
||||
/// </summary>
|
||||
public void TestGetRecommendedCoursesEmpty()
|
||||
[Test]
|
||||
public void Test_User_GetRecommendedCourses_Empty()
|
||||
{
|
||||
User user = new User();
|
||||
List<Tuple<CourseIndex, float>> list = user.GetRecommendedCourses();
|
||||
Debug.Assert(list.Count == 1);
|
||||
Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING);
|
||||
Debug.Assert(list[0].Item2 == 0.0f);
|
||||
Assert.AreEqual(list.Count, 1);
|
||||
Assert.AreEqual(list[0].Item1, CourseIndex.FINGERSPELLING);
|
||||
Assert.AreEqual(list[0].Item2, 0.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Temporary test for GetRecommenedCourses will return all progress that is stored
|
||||
/// TEMPORARY test for GetRecommenedCourses will return all progress that is stored
|
||||
/// </summary>
|
||||
public void TestGetRecommendedCoursesAll()
|
||||
[Test]
|
||||
public void Test_User_GetRecommendedCourses_All()
|
||||
{
|
||||
User user = new User();
|
||||
Progress p = new Progress();
|
||||
p.AddOrUpdate<CourseIndex>("courseIndex", CourseIndex.FINGERSPELLING);
|
||||
p.AddOrUpdate<float>("courseProgress", 0.5f);
|
||||
user.courses.Add(p);
|
||||
List<Tuple<CourseIndex, float>> list = user.GetRecommendedCourses();
|
||||
Debug.Assert(list.Count == 1);
|
||||
Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING);
|
||||
Debug.Assert(list[0].Item2 == 0.5f);
|
||||
Assert.AreEqual(list.Count, 1);
|
||||
Assert.AreEqual(list[0].Item1, CourseIndex.FINGERSPELLING);
|
||||
Assert.AreEqual(list[0].Item2, 0.5f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetCourseProgress returns null when course cannot be found
|
||||
/// </summary>
|
||||
public void TestGetCourseProgressNull()
|
||||
[Test]
|
||||
public void Test_User_GetCourseProgress_Null()
|
||||
{
|
||||
User user = new User();
|
||||
Debug.Assert(user.GetCourseProgress(CourseIndex.FINGERSPELLING) == null);
|
||||
Debug.Assert(user.GetCourseProgress((CourseIndex)100) == null);
|
||||
Assert.Null(user.GetCourseProgress(CourseIndex.FINGERSPELLING));
|
||||
Assert.Null(user.GetCourseProgress((CourseIndex)100));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetCourseProgress returns correct progress object
|
||||
/// </summary>
|
||||
public void TestGetCourseProgressValid()
|
||||
[Test]
|
||||
public void Test_User_GetCourseProgress_Valid()
|
||||
{
|
||||
User user = new User();
|
||||
Progress p = new Progress();
|
||||
p.AddOrUpdate<CourseIndex>("courseIndex", CourseIndex.FINGERSPELLING);
|
||||
p.AddOrUpdate<float>("courseProgress", 3.14159265f);
|
||||
user.courses.Add(p);
|
||||
Progress q = user.GetCourseProgress(CourseIndex.FINGERSPELLING);
|
||||
Debug.Assert(q.Get<CourseIndex>("courseIndex") == CourseIndex.FINGERSPELLING);
|
||||
Debug.Assert(q.Get<float>("courseProgress") == 3.14159265f);
|
||||
Assert.AreEqual(q.Get<CourseIndex>("courseIndex"), CourseIndex.FINGERSPELLING);
|
||||
Assert.AreEqual(q.Get<float>("courseProgress"), 3.14159265f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetMinigameProgress returns null when minigame cannot be found
|
||||
/// </summary>
|
||||
public void TestGetMinigameProgressNull()
|
||||
[Test]
|
||||
public void Test_User_GetMinigameProgress_Null()
|
||||
{
|
||||
User user = new User();
|
||||
Debug.Assert(user.GetMinigameProgress(MinigameIndex.SPELLING_BEE) == null);
|
||||
Debug.Assert(user.GetMinigameProgress((MinigameIndex)100) == null);
|
||||
Assert.Null(user.GetMinigameProgress(MinigameIndex.SPELLING_BEE));
|
||||
Assert.Null(user.GetMinigameProgress((MinigameIndex)100));
|
||||
|
||||
Progress p = new Progress();
|
||||
p.AddOrUpdate<MinigameIndex>("minigameIndex", MinigameIndex.SPELLING_BEE);
|
||||
user.minigames.Add(p);
|
||||
Debug.Assert(user.GetMinigameProgress(MinigameIndex.HANGMAN) == null);
|
||||
Assert.Null(user.GetMinigameProgress(MinigameIndex.HANGMAN));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetMinigameProgress returns correct progress object
|
||||
/// </summary>
|
||||
public void TestGetMinigameProgressValid()
|
||||
[Test]
|
||||
public void Test_User_GetMinigameProgress_Valid()
|
||||
{
|
||||
User user = new User();
|
||||
Progress p = new Progress();
|
||||
p.AddOrUpdate<MinigameIndex>("minigameIndex", MinigameIndex.SPELLING_BEE);
|
||||
user.minigames.Add(p);
|
||||
Progress q = user.GetMinigameProgress(MinigameIndex.SPELLING_BEE);
|
||||
Debug.Assert(q.Get<CourseIndex>("minigameIndex") == CourseIndex.FINGERSPELLING);
|
||||
Assert.AreEqual(q.Get<CourseIndex>("minigameIndex"), CourseIndex.FINGERSPELLING);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user