aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/UsernameValidatorUnitTest.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-08-17 20:43:24 +0800
committerGitHub <noreply@github.com>2019-08-17 20:43:24 +0800
commit2d672de8ea109c923d5a8697e44d5cbbf976ead2 (patch)
treececc5b93150f7b1e3be792de5c058433b5e40982 /Timeline.Tests/UsernameValidatorUnitTest.cs
parent7bbd66270597c7f6f07f1ab5ec6c45b3dcfa388e (diff)
parent67f42c40c3d4108620119e163a67f2686dd4a6f2 (diff)
downloadtimeline-2d672de8ea109c923d5a8697e44d5cbbf976ead2.tar.gz
timeline-2d672de8ea109c923d5a8697e44d5cbbf976ead2.tar.bz2
timeline-2d672de8ea109c923d5a8697e44d5cbbf976ead2.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.cs25
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]