aboutsummaryrefslogtreecommitdiff
path: root/Timeline.Tests/UserDetailValidatorTest.cs
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2019-10-24 20:15:58 +0800
committerGitHub <noreply@github.com>2019-10-24 20:15:58 +0800
commit7305358a88ffc87f51f7b78deb4f07ef99120beb (patch)
tree7ca5010a06829cc5fadea1ea17ae72d082fc344c /Timeline.Tests/UserDetailValidatorTest.cs
parent297d0c9029360f1d5334ed843b9b299356740ec1 (diff)
parenta0f3cd7599a48c14fb5492fb1c6e2dbd0a82fb45 (diff)
downloadtimeline-7305358a88ffc87f51f7b78deb4f07ef99120beb.tar.gz
timeline-7305358a88ffc87f51f7b78deb4f07ef99120beb.tar.bz2
timeline-7305358a88ffc87f51f7b78deb4f07ef99120beb.zip
Merge pull request #50 from crupest/refactor
Refactor : A Huge Step
Diffstat (limited to 'Timeline.Tests/UserDetailValidatorTest.cs')
-rw-r--r--Timeline.Tests/UserDetailValidatorTest.cs97
1 files changed, 0 insertions, 97 deletions
diff --git a/Timeline.Tests/UserDetailValidatorTest.cs b/Timeline.Tests/UserDetailValidatorTest.cs
deleted file mode 100644
index 9b112946..00000000
--- a/Timeline.Tests/UserDetailValidatorTest.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using FluentAssertions;
-using System.Collections.Generic;
-using Timeline.Models.Validation;
-using Xunit;
-
-namespace Timeline.Tests
-{
- public static class UserDetailValidatorsTest
- {
- private static void SucceedWith<TValidator>(object value) where TValidator : class, IValidator, new()
- {
- var result = new TValidator().Validate(value, out var message);
- result.Should().BeTrue();
- message.Should().Equals(ValidationConstants.SuccessMessage);
- }
-
- private static void FailWith<TValidator>(object value, params string[] messageContains) where TValidator : class, IValidator, new()
- {
- var result = new TValidator().Validate(value, out var message);
- result.Should().BeFalse();
-
- foreach (var m in messageContains)
- {
- message.Should().ContainEquivalentOf(m);
- }
- }
-
- public class QQ
- {
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- [InlineData("12345678")]
- public void Success(object qq)
- {
- SucceedWith<UserDetailValidators.QQValidator>(qq);
- }
-
- [Theory]
- [InlineData(123, "type")]
- [InlineData("123", "short")]
- [InlineData("111111111111111111111111111111111111", "long")]
- [InlineData("aaaaaaaa", "digit")]
- public void Fail(object qq, string messageContains)
- {
- FailWith<UserDetailValidators.QQValidator>(qq, messageContains);
- }
- }
-
- public class EMail
- {
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- [InlineData("aaa@aaa.net")]
- public void Success(object email)
- {
- SucceedWith<UserDetailValidators.EMailValidator>(email);
- }
-
- public static IEnumerable<object[]> FailTestData()
- {
- yield return new object[] { 123, "type" };
- yield return new object[] { new string('a', 100), "long" };
- yield return new object[] { "aaaaaaaa", "format" };
- }
-
- [Theory]
- [MemberData(nameof(FailTestData))]
- public void Fail(object email, string messageContains)
- {
- FailWith<UserDetailValidators.EMailValidator>(email, messageContains);
- }
- }
-
- public class PhoneNumber
- {
- [Theory]
- [InlineData(null)]
- [InlineData("")]
- [InlineData("12345678910")]
- public void Success(object phoneNumber)
- {
- SucceedWith<UserDetailValidators.PhoneNumberValidator>(phoneNumber);
- }
-
- [Theory]
- [InlineData(123, "type")]
- [InlineData("111111111111111111111111111111111111", "long")]
- [InlineData("aaaaaaaa", "digit")]
- public void Fail(object phoneNumber, string messageContains)
- {
- FailWith<UserDetailValidators.PhoneNumberValidator>(phoneNumber, messageContains);
- }
- }
- }
-}