Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

SubscribeFinderTest.cs 1.3 KiB

pirms 7 gadiem
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. }