fc0d341d15
Validators (Pushes and Pull Requests) / validate-ui-and-storage (push) Successful in 24s
Prepare Release / Build & Create Release (push) Successful in 1m0s
Prepare Release / Release Notification (push) Successful in 1s
Validators (Pushes and Pull Requests) / validate-core (push) Successful in 2m6s
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using Xunit;
|
|
using Moq;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Hangfire;
|
|
using Hangfire.Common;
|
|
using QuantEngine.Web.Services;
|
|
|
|
namespace QuantEngine.Core.Tests;
|
|
|
|
public class SchedulerServiceTests
|
|
{
|
|
[Fact]
|
|
public void InitializeSchedules_RegistersAllFourRequiredJobs()
|
|
{
|
|
// Arrange
|
|
var loggerMock = new Mock<ILogger<SchedulerService>>();
|
|
var jobClientMock = new Mock<IBackgroundJobClient>();
|
|
var recurringJobManagerMock = new Mock<IRecurringJobManager>();
|
|
var scopeFactoryMock = new Mock<IServiceScopeFactory>();
|
|
|
|
var configMock = new Mock<IConfiguration>();
|
|
configMock.Setup(c => c["Kis:AccountMode"]).Returns("mock");
|
|
|
|
var service = new SchedulerService(
|
|
loggerMock.Object,
|
|
jobClientMock.Object,
|
|
recurringJobManagerMock.Object,
|
|
scopeFactoryMock.Object,
|
|
configMock.Object
|
|
);
|
|
|
|
// Act
|
|
service.InitializeSchedules();
|
|
|
|
// Assert
|
|
// Verify daily-collection was added or updated
|
|
recurringJobManagerMock.Verify(m => m.AddOrUpdate(
|
|
"daily-collection",
|
|
It.IsAny<Job>(),
|
|
"0 9 * * *",
|
|
It.IsAny<RecurringJobOptions>()
|
|
), Times.Once);
|
|
|
|
// Verify hourly-price-update was added or updated
|
|
recurringJobManagerMock.Verify(m => m.AddOrUpdate(
|
|
"hourly-price-update",
|
|
It.IsAny<Job>(),
|
|
"0 9,11,13,15 * * 1-5",
|
|
It.IsAny<RecurringJobOptions>()
|
|
), Times.Once);
|
|
|
|
// Verify weekly-report was added or updated
|
|
recurringJobManagerMock.Verify(m => m.AddOrUpdate(
|
|
"weekly-report",
|
|
It.IsAny<Job>(),
|
|
"0 17 * * 5",
|
|
It.IsAny<RecurringJobOptions>()
|
|
), Times.Once);
|
|
|
|
// Verify monthly-optimization was added or updated
|
|
recurringJobManagerMock.Verify(m => m.AddOrUpdate(
|
|
"monthly-optimization",
|
|
It.IsAny<Job>(),
|
|
"0 2 1 * *",
|
|
It.IsAny<RecurringJobOptions>()
|
|
), Times.Once);
|
|
}
|
|
}
|