diff options
author | crupest <crupest@outlook.com> | 2020-02-29 17:29:57 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-02-29 17:29:57 +0800 |
commit | b43b480d3c50b3f12cf01750c0951ece1fe70119 (patch) | |
tree | 9cbe0f8f6e6be22f66893b666ca537c0aebf268b | |
parent | e84573dde542b18bf3f78d250e6f0898f05c8d10 (diff) | |
download | timeline-b43b480d3c50b3f12cf01750c0951ece1fe70119.tar.gz timeline-b43b480d3c50b3f12cf01750c0951ece1fe70119.tar.bz2 timeline-b43b480d3c50b3f12cf01750c0951ece1fe70119.zip |
Guess what, Chinese character is also a "letter". So no need to change code. Just add some tests.
-rw-r--r-- | Timeline.Tests/UsernameValidatorUnitTest.cs | 2 | ||||
-rw-r--r-- | Timeline/Models/Validation/NameValidator.cs | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/Timeline.Tests/UsernameValidatorUnitTest.cs b/Timeline.Tests/UsernameValidatorUnitTest.cs index 0f844452..8824362b 100644 --- a/Timeline.Tests/UsernameValidatorUnitTest.cs +++ b/Timeline.Tests/UsernameValidatorUnitTest.cs @@ -39,6 +39,7 @@ namespace Timeline.Tests [InlineData("!")]
[InlineData("!abc")]
[InlineData("ab c")]
+ [InlineData("ab c!")] // This is a chinese ! .
public void BadCharactor(string value)
{
FailAndMessage(value).Should().ContainEquivalentOf("invalid")
@@ -61,6 +62,7 @@ namespace Timeline.Tests [InlineData("a-bc")]
[InlineData("a-b-c")]
[InlineData("a-b_c")]
+ [InlineData("a-你好_c")]
public void Success(string value)
{
var (result, _) = _validator.Validate(value);
diff --git a/Timeline/Models/Validation/NameValidator.cs b/Timeline/Models/Validation/NameValidator.cs index 8db10ebd..dec2b872 100644 --- a/Timeline/Models/Validation/NameValidator.cs +++ b/Timeline/Models/Validation/NameValidator.cs @@ -14,7 +14,7 @@ namespace Timeline.Models.Validation return (false, MessageEmptyString);
}
- if (value.Length > 26)
+ if (value.Length > MaxLength)
{
return (false, MessageTooLong);
}
|