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.
 
 
 

43 lines
1.3 KiB

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