using UnityEngine;

/// <summary>
/// Test the UserCreationScreen class
/// </summary>
public class TestUserCreationScreen : MonoBehaviour
{
    /// <summary>
    /// Start is called before the first frame update
    /// </summary>
    void Start()
    {
        TestIsValidUsernameTrue();
        TestIsValidUsernameFalse();
    }

    /// <summary>
    /// Tets IsValidUsername will return <c>true</c> for an valid username
    /// </summary>
    public void TestIsValidUsernameTrue()
    {
        foreach (char c in "abcdefghijklmnopqrstuvwxyz")
            Debug.Assert(UserCreationScreen.IsValidUsername(c.ToString()));

        Debug.Assert(UserCreationScreen.IsValidUsername("abcdefghijkl"));
    }

    /// <summary>
    /// Tets IsValidUsername will return <c>false</c> for an invalid username
    /// </summary>
    public void TestIsValidUsernameFalse()
    {
        Debug.Assert(!UserCreationScreen.IsValidUsername(string.Empty));
        foreach (char c in " \n\t0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ+-*/%_(){}[]\\")
            Debug.Assert(!UserCreationScreen.IsValidUsername(c.ToString()));

        Debug.Assert(!UserCreationScreen.IsValidUsername("abcdefghijklmnopqrstuvwxyz"));
    }
}
