parent
e7cd2bcd9f
commit
63b46caeea
13 changed files with 326 additions and 94 deletions
@ -1,7 +1,10 @@ |
||||
using System; |
||||
using Microsoft.Extensions.DependencyInjection; |
||||
|
||||
namespace DotXxlJob.Core |
||||
{ |
||||
public interface IJobHandlerFactory |
||||
{ |
||||
IJobHandler GetJobHandler(string handlerName); |
||||
IJobHandler GetJobHandler(IServiceScopeFactory scopeFactory, string handlerName, out IServiceScope serviceScope); |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@ |
||||
using System; |
||||
using System.Threading.Tasks; |
||||
using DotXxlJob.Core.DefaultHandlers; |
||||
using DotXxlJob.Core.Model; |
||||
using Xunit; |
||||
|
||||
namespace DotXxlJob.Core.Tests |
||||
{ |
||||
public class JobHandlerCacheTest |
||||
{ |
||||
[Fact] |
||||
public void Repeated_Job_Handler() |
||||
{ |
||||
var cache = new JobHandlerCache(); |
||||
|
||||
cache.AddJobHandler<SimpleHttpJobHandler>(); |
||||
|
||||
Assert.Throws<ArgumentException>(() => cache.AddJobHandler("simpleHttpJobHandler", new TestJobHandler())); |
||||
} |
||||
|
||||
private class TestJobHandler : IJobHandler |
||||
{ |
||||
public void Dispose() { } |
||||
|
||||
public Task<ReturnT> Execute(JobExecuteContext context) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -1,13 +0,0 @@ |
||||
using System; |
||||
using Xunit; |
||||
|
||||
namespace DotXxlJob.Core.Tests |
||||
{ |
||||
public class UnitTest1 |
||||
{ |
||||
[Fact] |
||||
public void Test1() |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue