using System;
using System.Collections.Generic;
using UnityEngine;
///
/// Test the User class
///
public class TestUser
{
///
/// Test for the creation of a new user
///
public void TestNewUser()
{
User user = new User();
Debug.Assert(user != null);
Debug.Assert(user.courses.Count == 0);
Debug.Assert(user.minigames.Count == 0);
}
///
/// Test whether progress on a new course can be added
///
public void TestUserAddCourse()
{
User user = new User();
Progress p = new Progress();
user.courses.Add(p);
Debug.Assert(user.courses.Count == 1);
Debug.Assert(user.minigames.Count == 0);
}
///
/// Test whether progress on a new minigame can be added
///
public void TestUserAddMinigame()
{
User user = new User();
Progress p = new Progress();
user.minigames.Add(p);
Debug.Assert(user.courses.Count == 0);
Debug.Assert(user.minigames.Count == 1);
}
///
/// Test GetRecentCourses will return empty when no progress is stored
///
public void TestGetRecentCoursesEmpty()
{
User user = new User();
Debug.Assert(user.GetRecentCourses().Count == 0);
}
///
/// Temporary test for GetRecentCourses will return all progress that is stored
///
public void TestGetRecentCoursesAll()
{
User user = new User();
Progress p = new Progress();
p.AddOrUpdate("courseIndex", CourseIndex.FINGERSPELLING);
p.AddOrUpdate("courseProgress", 0.5f);
user.courses.Add(p);
List> list = user.GetRecentCourses();
Debug.Assert(list.Count == 1);
Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING);
Debug.Assert(list[0].Item2 == 0.5f);
}
///
/// Test GetRecommendedCourses will return Tuple when no progress is stored
///
public void TestGetRecommendedCoursesEmpty()
{
User user = new User();
List> list = user.GetRecommendedCourses();
Debug.Assert(list.Count == 1);
Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING);
Debug.Assert(list[0].Item2 == 0.0f);
}
///
/// Temporary test for GetRecommenedCourses will return all progress that is stored
///
public void TestGetRecommendedCoursesAll()
{
User user = new User();
Progress p = new Progress();
p.AddOrUpdate("courseIndex", CourseIndex.FINGERSPELLING);
p.AddOrUpdate("courseProgress", 0.5f);
user.courses.Add(p);
List> list = user.GetRecommendedCourses();
Debug.Assert(list.Count == 1);
Debug.Assert(list[0].Item1 == CourseIndex.FINGERSPELLING);
Debug.Assert(list[0].Item2 == 0.5f);
}
///
/// Test GetCourseProgress returns null when course cannot be found
///
public void TestGetCourseProgressNull()
{
User user = new User();
Debug.Assert(user.GetCourseProgress(CourseIndex.FINGERSPELLING) == null);
Debug.Assert(user.GetCourseProgress((CourseIndex)100) == null);
}
///
/// Test GetCourseProgress returns correct progress object
///
public void TestGetCourseProgressValid()
{
User user = new User();
Progress p = new Progress();
p.AddOrUpdate("courseIndex", CourseIndex.FINGERSPELLING);
p.AddOrUpdate("courseProgress", 3.14159265f);
user.courses.Add(p);
Progress q = user.GetCourseProgress(CourseIndex.FINGERSPELLING);
Debug.Assert(q.Get("courseIndex") == CourseIndex.FINGERSPELLING);
Debug.Assert(q.Get("courseProgress") == 3.14159265f);
}
///
/// Test GetMinigameProgress returns null when minigame cannot be found
///
public void TestGetMinigameProgressNull()
{
User user = new User();
Debug.Assert(user.GetMinigameProgress(MinigameIndex.SPELLING_BEE) == null);
Debug.Assert(user.GetMinigameProgress((MinigameIndex)100) == null);
Progress p = new Progress();
p.AddOrUpdate("minigameIndex", MinigameIndex.SPELLING_BEE);
user.minigames.Add(p);
Debug.Assert(user.GetMinigameProgress(MinigameIndex.HANGMAN) == null);
}
///
/// Test GetMinigameProgress returns correct progress object
///
public void TestGetMinigameProgressValid()
{
User user = new User();
Progress p = new Progress();
p.AddOrUpdate("minigameIndex", MinigameIndex.SPELLING_BEE);
user.minigames.Add(p);
Progress q = user.GetMinigameProgress(MinigameIndex.SPELLING_BEE);
Debug.Assert(q.Get("minigameIndex") == CourseIndex.FINGERSPELLING);
}
}