You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

80 lines
1.8 KiB

  1. using System;
  2. using System.Reflection;
  3. using DotNetCore.CAP.Internal;
  4. using Xunit;
  5. namespace DotNetCore.CAP.Test
  6. {
  7. public class HelperTest
  8. {
  9. [Fact]
  10. public void ToTimestampTest()
  11. {
  12. //Arrange
  13. var time = DateTime.Parse("2018-01-01 00:00:00");
  14. //Act
  15. var result = Helper.ToTimestamp(time);
  16. //Assert
  17. Assert.Equal(1514764800, result);
  18. }
  19. [Fact]
  20. public void IsControllerTest()
  21. {
  22. //Arrange
  23. var typeInfo = typeof(HomeController).GetTypeInfo();
  24. //Act
  25. var result = Helper.IsController(typeInfo);
  26. //Assert
  27. Assert.True(result);
  28. }
  29. [Theory]
  30. [InlineData(typeof(string))]
  31. [InlineData(typeof(decimal))]
  32. [InlineData(typeof(DateTime))]
  33. [InlineData(typeof(DateTimeOffset))]
  34. [InlineData(typeof(Guid))]
  35. [InlineData(typeof(TimeSpan))]
  36. [InlineData(typeof(Uri))]
  37. public void IsSimpleTypeTest(Type type)
  38. {
  39. //Act
  40. var result = Helper.IsComplexType(type);
  41. //Assert
  42. Assert.False(result);
  43. }
  44. [Theory]
  45. [InlineData(typeof(HomeController))]
  46. [InlineData(typeof(Exception))]
  47. public void IsComplexTypeTest(Type type)
  48. {
  49. //Act
  50. var result = Helper.IsComplexType(type);
  51. //Assert
  52. Assert.True(result);
  53. }
  54. [Theory]
  55. [InlineData("10.0.0.1")]
  56. [InlineData("172.16.0.1")]
  57. [InlineData("192.168.1.1")]
  58. public void IsInnerIPTest(string ipAddress)
  59. {
  60. Assert.True(Helper.IsInnerIP(ipAddress));
  61. }
  62. }
  63. public class HomeController
  64. {
  65. }
  66. }