ExtensionMethodsTest.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using Xunit;
  2. namespace Masuit.Tools.Test
  3. {
  4. public class ExtensionMethodsTest
  5. {
  6. [Fact]
  7. public void MatchUrl_True()
  8. {
  9. bool expect = "https://git.lug.us-tc.edu.cn/masuit/soft".MatchUrl();
  10. Assert.Equal(true, expect);
  11. }
  12. [Fact]
  13. public void MatchEmail()
  14. {
  15. var (expect, match) = "[email protected]".MatchEmail();
  16. Assert.Equal(true, expect);
  17. }
  18. [Fact]
  19. public void MatchIdentifyCard_False()
  20. {
  21. bool expect = "513901199509120610".MatchIdentifyCard();
  22. Assert.Equal(false, expect);
  23. }
  24. [Theory]
  25. [InlineData("16666666666")]
  26. [InlineData("19999999999")]
  27. public void Can_MatchPhoneNumber_(string phone)
  28. {
  29. Xunit.Assert.True(phone.MatchPhoneNumber());
  30. }
  31. [Theory]
  32. [InlineData("166666666666")]
  33. [InlineData("199999999996")]
  34. public void CanNot_MatchPhoneNumber_(string phone)
  35. {
  36. Xunit.Assert.False(phone.MatchPhoneNumber());
  37. }
  38. [Theory]
  39. [InlineData("010-12345678")]
  40. [InlineData("0731-87654321")]
  41. [InlineData("0351-7654321")]
  42. [InlineData("01012345678")]
  43. [InlineData("073187654321")]
  44. [InlineData("03517654321")]
  45. public void Can_MatchLandline_(string phone)
  46. {
  47. Xunit.Assert.True(phone.MatchLandline());
  48. }
  49. }
  50. }