diff options
author | 杨宇千 <crupest@outlook.com> | 2019-08-17 20:43:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-17 20:43:24 +0800 |
commit | 0630fd020ec11e343b787a18d70f1f13fdb350b3 (patch) | |
tree | cecc5b93150f7b1e3be792de5c058433b5e40982 /Timeline.Tests/UsernameValidatorUnitTest.cs | |
parent | 2d33ed8dc93a99fd5f24a9d4b2c609ddf078d367 (diff) | |
parent | 1fcd4c0daace2532757f797be2e33768b9d2cccd (diff) | |
download | timeline-0630fd020ec11e343b787a18d70f1f13fdb350b3.tar.gz timeline-0630fd020ec11e343b787a18d70f1f13fdb350b3.tar.bz2 timeline-0630fd020ec11e343b787a18d70f1f13fdb350b3.zip |
Merge pull request #42 from crupest/change-username
Add change username api.
Diffstat (limited to 'Timeline.Tests/UsernameValidatorUnitTest.cs')
-rw-r--r-- | Timeline.Tests/UsernameValidatorUnitTest.cs | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Timeline.Tests/UsernameValidatorUnitTest.cs b/Timeline.Tests/UsernameValidatorUnitTest.cs index 97d56195..20558d0e 100644 --- a/Timeline.Tests/UsernameValidatorUnitTest.cs +++ b/Timeline.Tests/UsernameValidatorUnitTest.cs @@ -1,6 +1,6 @@ using FluentAssertions;
using System;
-using Timeline.Services;
+using Timeline.Models.Validation;
using Xunit;
namespace Timeline.Tests
@@ -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]
|