From 8225c5ff0092f2d666a8c012dffbbc0b428c7d9b Mon Sep 17 00:00:00 2001 From: 杨宇千 Date: Sat, 17 Aug 2019 20:33:01 +0800 Subject: Finally solve the database conflict problem in unit tests. --- Timeline.Tests/UsernameValidatorUnitTest.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'Timeline.Tests/UsernameValidatorUnitTest.cs') 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(); - } - - 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] -- cgit v1.2.3