40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
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 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
|
|
Debug.Assert(UserCreationScreen.IsValidUsername(c.ToString()));
|
|
|
|
Debug.Assert(UserCreationScreen.IsValidUsername("123456789AbC"));
|
|
}
|
|
|
|
/// <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\t+-*/%_.,;:!?(){}[]\\'\"§|&~^$")
|
|
Debug.Assert(!UserCreationScreen.IsValidUsername(c.ToString()));
|
|
|
|
Debug.Assert(!UserCreationScreen.IsValidUsername("123456789_10_11_12_13"));
|
|
}
|
|
}
|