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.
 
 
 

60 lines
1.3 KiB

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