aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/UsernameValidatorUnitTest.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-08-17 20:33:01 +0800
committer杨宇千 <crupest@outlook.com>2019-08-17 20:33:01 +0800
commit4791d81ffe50d20c5e7e2f6f2ef91b519cb639ea (patch)
tree3127ceaf927c8ae3fb38a5bc25904d2d36973bee /Timeline.Tests/UsernameValidatorUnitTest.cs
parent3bd772a17276a7f6f50cead2b7fbd31975f660b9 (diff)
downloadtimeline-4791d81ffe50d20c5e7e2f6f2ef91b519cb639ea.tar.gz
timeline-4791d81ffe50d20c5e7e2f6f2ef91b519cb639ea.tar.bz2
timeline-4791d81ffe50d20c5e7e2f6f2ef91b519cb639ea.zip
Finally solve the database conflict problem in unit tests.
Diffstat (limited to 'Timeline.Tests/UsernameValidatorUnitTest.cs')
-rw-r--r--Timeline.Tests/UsernameValidatorUnitTest.cs23
1 files changed, 15 insertions, 8 deletions
diff --git a/Timeline.Tests/UsernameValidatorUnitTest.cs b/Timeline.Tests/UsernameValidatorUnitTest.cs
index 450564b7..20558d0e 100644
--- a/Timeline.Tests/UsernameValidatorUnitTest.cs
+++ b/Timeline.Tests/UsernameValidatorUnitTest.cs
@@ -14,13 +14,6 @@ namespace Timeline.Tests
_validator = validator;
}
- [Fact]
- public void NullShouldThrow()
- {
- _validator.Invoking(v => v.Validate(null, out string message)).Should().Throw<ArgumentNullException>();
- }
-
-
private string FailAndMessage(string username)
{
var result = _validator.Validate(username, out var message);
@@ -31,7 +24,21 @@ namespace Timeline.Tests
private void Succeed(string username)
{
_validator.Validate(username, out var message).Should().BeTrue();
- message.Should().BeNull();
+ message.Should().Be(ValidationConstants.SuccessMessage);
+ }
+
+ [Fact]
+ public void Null()
+ {
+ FailAndMessage(null).Should().ContainEquivalentOf("null");
+ }
+
+ [Fact]
+ public void NotString()
+ {
+ var result = _validator.Validate(123, out var message);
+ result.Should().BeFalse();
+ message.Should().ContainEquivalentOf("type");
}
[Fact]