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.
 
 
 

46 lines
1.4 KiB

  1. using System;
  2. using DotNetCore.CAP.Internal;
  3. using Microsoft.Extensions.DependencyInjection;
  4. using Xunit;
  5. using Moq;
  6. namespace DotNetCore.CAP.Test
  7. {
  8. public class QueueExecutorFactoryTest
  9. {
  10. private IServiceProvider _provider;
  11. public QueueExecutorFactoryTest()
  12. {
  13. var services = new ServiceCollection();
  14. services.AddLogging();
  15. services.AddOptions();
  16. services.AddCap(x => { });
  17. _provider = services.BuildServiceProvider();
  18. }
  19. [Fact]
  20. public void CanCreateInstance()
  21. {
  22. var queueExecutorFactory = _provider.GetService<IQueueExecutorFactory>();
  23. Assert.NotNull(queueExecutorFactory);
  24. var publishExecutor = queueExecutorFactory.GetInstance(Models.MessageType.Publish);
  25. Assert.Null(publishExecutor);
  26. var disPatchExector = queueExecutorFactory.GetInstance(Models.MessageType.Subscribe);
  27. Assert.NotNull(disPatchExector);
  28. }
  29. [Fact]
  30. public void CanGetSubscribeExector()
  31. {
  32. var queueExecutorFactory = _provider.GetService<IQueueExecutorFactory>();
  33. Assert.NotNull(queueExecutorFactory);
  34. var publishExecutor = queueExecutorFactory.GetInstance(Models.MessageType.Publish);
  35. Assert.Null(publishExecutor);
  36. }
  37. }
  38. }