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.
 
 
 

32 lines
1.0 KiB

  1. using System;
  2. using System.Threading;
  3. using DotNetCore.CAP.Test.FakeInMemoryQueue;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Xunit.Abstractions;
  6. namespace DotNetCore.CAP.Test.Helpers
  7. {
  8. public static class TestServiceCollectionExtensions
  9. {
  10. public const string TestGroupName = "Test";
  11. public static void AddTestSetup(this IServiceCollection services, ITestOutputHelper testOutput)
  12. {
  13. services.AddLogging(x => x.AddTestLogging(testOutput));
  14. services.AddCap(x =>
  15. {
  16. x.DefaultGroupName = TestGroupName;
  17. x.UseFakeTransport();
  18. x.UseInMemoryStorage();
  19. });
  20. services.AddHostedService<TestBootstrapService>();
  21. }
  22. public static ServiceProvider BuildTestContainer(this IServiceCollection services, CancellationToken cancellationToken)
  23. {
  24. var container = services.BuildServiceProvider();
  25. container.StartHostedServices(cancellationToken);
  26. return container;
  27. }
  28. }
  29. }