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.
abp/framework/test/Volo.Abp.BackgroundJobs.Tests/Volo/Abp/BackgroundJobs/BackgroundJobExecuter_Tests.cs

62 lines
1.5 KiB

using System.Threading.Tasks;
using Shouldly;
using Xunit;
namespace Volo.Abp.BackgroundJobs
{
public class BackgroundJobExecuter_Tests : BackgroundJobsTestBase
{
private readonly IBackgroundJobExecuter _backgroundJobExecuter;
public BackgroundJobExecuter_Tests()
{
_backgroundJobExecuter = GetRequiredService<IBackgroundJobExecuter>();
}
[Fact]
public async Task Should_Execute_Tasks()
{
//Arrange
var jobObject = GetRequiredService<MyJob>();
jobObject.ExecutedValues.ShouldBeEmpty();
//Act
await _backgroundJobExecuter.ExecuteAsync(
new JobExecutionContext(
ServiceProvider,
typeof(MyJob),
new MyJobArgs("42")
)
);
//Assert
jobObject.ExecutedValues.ShouldContain("42");
}
[Fact]
public async Task Should_Execute_Async_Tasks()
{
//Arrange
var jobObject = GetRequiredService<MyAsyncJob>();
jobObject.ExecutedValues.ShouldBeEmpty();
//Act
await _backgroundJobExecuter.ExecuteAsync(
new JobExecutionContext(
ServiceProvider,
typeof(MyAsyncJob),
new MyAsyncJobArgs("42")
)
);
//Assert
jobObject.ExecutedValues.ShouldContain("42");
}
}
}