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.
 
 
 

54 line
1.2 KiB

  1. using System;
  2. using DotNetCore.CAP.Abstractions;
  3. using Microsoft.Extensions.DependencyInjection;
  4. using Xunit;
  5. namespace DotNetCore.CAP.Test
  6. {
  7. public class SubscribeFinderTest
  8. {
  9. private IServiceProvider _provider;
  10. public SubscribeFinderTest()
  11. {
  12. var services = new ServiceCollection();
  13. services.AddScoped<ITestService, TestService>();
  14. services.AddCap(x => { });
  15. _provider = services.BuildServiceProvider();
  16. }
  17. [Fact]
  18. public void CanFindControllers()
  19. {
  20. }
  21. [Fact]
  22. public void CanFindSubscribeService()
  23. {
  24. var testService = _provider.GetService<ICapSubscribe>();
  25. Assert.NotNull(testService);
  26. Assert.IsType<TestService>(testService);
  27. }
  28. }
  29. public class HomeController
  30. {
  31. }
  32. public interface ITestService { }
  33. public class TestService : ITestService, ICapSubscribe
  34. {
  35. [CapSubscribe("test")]
  36. public void Index()
  37. {
  38. }
  39. }
  40. public class CapSubscribeAttribute : TopicAttribute
  41. {
  42. public CapSubscribeAttribute(string name) : base(name)
  43. {
  44. }
  45. }
  46. }