diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-17 20:33:01 +0800 |
---|---|---|
committer | 杨宇千 <crupest@outlook.com> | 2019-08-17 20:33:01 +0800 |
commit | 8225c5ff0092f2d666a8c012dffbbc0b428c7d9b (patch) | |
tree | 3127ceaf927c8ae3fb38a5bc25904d2d36973bee /Timeline.Tests/UsernameValidatorUnitTest.cs | |
parent | 6edc70c00bca22e13ade23472d48d7b940f92eef (diff) | |
download | timeline-8225c5ff0092f2d666a8c012dffbbc0b428c7d9b.tar.gz timeline-8225c5ff0092f2d666a8c012dffbbc0b428c7d9b.tar.bz2 timeline-8225c5ff0092f2d666a8c012dffbbc0b428c7d9b.zip |
Finally solve the database conflict problem in unit tests.
Diffstat (limited to 'Timeline.Tests/UsernameValidatorUnitTest.cs')
-rw-r--r-- | Timeline.Tests/UsernameValidatorUnitTest.cs | 23 |
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]
|