CharacterLimitValidation.cs
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using NUnit.Framework;
namespace Core.InputField
{
public class CharacterLimitValidation : TestBehaviourBase<UnityEngine.UI.InputField>
{
[Test]
public void LimitCanNotBeNegative()
{
const int testValue = -1;
m_TestObject.characterLimit = testValue;
Assert.AreNotEqual(testValue, m_TestObject.characterLimit);
}
[Test]
public void TextLengthShorterThanLimit()
{
const string testValue = "Test";
m_TestObject.characterLimit = 10;
m_TestObject.text = testValue;
Assert.AreEqual(testValue, m_TestObject.text);
}
[Test]
public void TextLengthEqualToLimit()
{
const string testValue = "0123456789";
m_TestObject.characterLimit = 10;
m_TestObject.text = testValue;
Assert.AreEqual(testValue, m_TestObject.text);
}
[Test]
public void TextLengthGreaterThanLimit()
{
m_TestObject.characterLimit = 10;
m_TestObject.text = "01234567891234567890";
Assert.AreEqual(10, m_TestObject.text.Length);
Assert.AreEqual("0123456789", m_TestObject.text);
}
}
}