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.
 
 
 

83 lines
2.7 KiB

  1. //using System;
  2. //using System.Threading;
  3. //using System.Threading.Tasks;
  4. //using DotNetCore.CAP.Models;
  5. //using DotNetCore.CAP.Processor;
  6. //using Microsoft.Extensions.DependencyInjection;
  7. //using Microsoft.Extensions.Options;
  8. //using Moq;
  9. //using Xunit;
  10. //namespace DotNetCore.CAP.Test
  11. //{
  12. // public class DefaultDispatcherTest
  13. // {
  14. // private CancellationTokenSource _cancellationTokenSource;
  15. // private ProcessingContext _context;
  16. // private IServiceProvider _provider;
  17. // private Mock<IStorageConnection> _mockStorageConnection;
  18. // public DefaultDispatcherTest()
  19. // {
  20. // _mockStorageConnection = new Mock<IStorageConnection>();
  21. // _cancellationTokenSource = new CancellationTokenSource();
  22. // var services = new ServiceCollection();
  23. // services.AddLogging();
  24. // services.Configure<IOptions<CapOptions>>(x => { });
  25. // services.AddOptions();
  26. // services.AddSingleton(_mockStorageConnection.Object);
  27. // _provider = services.BuildServiceProvider();
  28. // _context = new ProcessingContext(_provider, _cancellationTokenSource.Token);
  29. // }
  30. // [Fact]
  31. // public void MockTest()
  32. // {
  33. // Assert.NotNull(_provider.GetServices<IStorageConnection>());
  34. // }
  35. // [Fact]
  36. // public async void ProcessAsync_CancellationTokenCancelled_ThrowsImmediately()
  37. // {
  38. // // Arrange
  39. // _cancellationTokenSource.Cancel();
  40. // var fixture = Create();
  41. // // Act
  42. // await Assert.ThrowsAsync<OperationCanceledException>(() => fixture.ProcessAsync(_context));
  43. // }
  44. // [Fact]
  45. // public async Task ProcessAsync()
  46. // {
  47. // // Arrange
  48. // var job = new CapPublishedMessage
  49. // {
  50. // };
  51. // var mockFetchedJob = Mock.Get(Mock.Of<IFetchedMessage>(fj => fj.MessageId == 42 && fj.MessageType == MessageType.Publish));
  52. // _mockStorageConnection
  53. // .Setup(m => m.FetchNextMessageAsync())
  54. // .ReturnsAsync(mockFetchedJob.Object).Verifiable();
  55. // _mockQueueExecutor
  56. // .Setup(x => x.ExecuteAsync(_mockStorageConnection.Object, mockFetchedJob.Object))
  57. // .Returns(Task.FromResult(OperateResult.Success));
  58. // var fixture = Create();
  59. // // Act
  60. // await fixture.ProcessAsync(_context);
  61. // // Assert
  62. // _mockStorageConnection.VerifyAll();
  63. // }
  64. // private DefaultDispatcher Create()
  65. // => _provider.GetService<DefaultDispatcher>();
  66. // }
  67. //}