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.
 
 
 

113 regels
3.8 KiB

  1. //using System;
  2. //using System.Threading.Tasks;
  3. //using DotNetCore.CAP.Infrastructure;
  4. //using DotNetCore.CAP.Models;
  5. //using Microsoft.AspNetCore.Http;
  6. //using Microsoft.Extensions.DependencyInjection;
  7. //using Microsoft.Extensions.Logging;
  8. //using Xunit;
  9. //namespace DotNetCore.CAP.Test
  10. //{
  11. // public abstract class MessageManagerTestBase
  12. // {
  13. // private const string NullValue = "(null)";
  14. // protected virtual bool ShouldSkipDbTests()
  15. // {
  16. // return false;
  17. // }
  18. // protected virtual void SetupMessageServices(IServiceCollection services, object context = null)
  19. // {
  20. // services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
  21. // services.AddCap();
  22. // AddMessageStore(services, context);
  23. // services.AddSingleton<ILogger<ICapMessageStore>>(new TestLogger<ICapMessageStore>());
  24. // }
  25. // protected virtual ICapMessageStore CreateManager(object context = null, IServiceCollection services = null,
  26. // Action<IServiceCollection> configureServices = null)
  27. // {
  28. // if (services == null)
  29. // {
  30. // services = new ServiceCollection();
  31. // }
  32. // if (context == null)
  33. // {
  34. // context = CreateTestContext();
  35. // }
  36. // SetupMessageServices(services, context);
  37. // configureServices?.Invoke(services);
  38. // return services.BuildServiceProvider().GetService<ICapMessageStore>();
  39. // }
  40. // protected abstract object CreateTestContext();
  41. // protected abstract CapSentMessage CreateTestSentMessage(string content = "");
  42. // protected abstract CapReceivedMessage CreateTestReceivedMessage(string content = "");
  43. // protected abstract void AddMessageStore(IServiceCollection services, object context = null);
  44. // [Fact]
  45. // public async Task CanDeleteSentMessage()
  46. // {
  47. // if (ShouldSkipDbTests())
  48. // {
  49. // return;
  50. // }
  51. // var manager = CreateManager();
  52. // var message = CreateTestSentMessage();
  53. // var operateResult = await manager.StoreSentMessageAsync(message);
  54. // Assert.NotNull(operateResult);
  55. // Assert.True(operateResult.Succeeded);
  56. // // operateResult = await manager.RemoveSentMessageAsync(message);
  57. // // Assert.NotNull(operateResult);
  58. // // Assert.True(operateResult.Succeeded);
  59. // }
  60. // //[Fact]
  61. // //public async Task CanUpdateReceivedMessage()
  62. // //{
  63. // // if (ShouldSkipDbTests())
  64. // // {
  65. // // return;
  66. // // }
  67. // // var manager = CreateManager();
  68. // // var message = CreateTestReceivedMessage();
  69. // // // var operateResult = await manager.StoreReceivedMessageAsync(message);
  70. // // // Assert.NotNull(operateResult);
  71. // // // Assert.True(operateResult.Succeeded);
  72. // // // message.StatusName = StatusName.Processing;
  73. // // // operateResult = await manager.UpdateReceivedMessageAsync(message);
  74. // // // Assert.NotNull(operateResult);
  75. // // // Assert.True(operateResult.Succeeded);
  76. // //}
  77. // [Fact]
  78. // public async Task CanGetNextSendMessage()
  79. // {
  80. // if (ShouldSkipDbTests())
  81. // {
  82. // return;
  83. // }
  84. // var manager = CreateManager();
  85. // var message = CreateTestSentMessage();
  86. // var operateResult = await manager.StoreSentMessageAsync(message);
  87. // Assert.NotNull(operateResult);
  88. // Assert.True(operateResult.Succeeded);
  89. // // var storeMessage = await manager.GetNextSentMessageToBeEnqueuedAsync();
  90. // // Assert.Equal(message, storeMessage);
  91. // }
  92. // }
  93. //}