Skip to content

Commit f43af2b

Browse files
committed
fix
1 parent ca31f1f commit f43af2b

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/ScheduledTasks/Entity/Schedule.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ public void UpdateSchedule(TaskEntityContext context, ScheduleUpdateOptions sche
110110
this.State.RefreshScheduleRunExecutionToken();
111111

112112
this.logger.UpdatedSchedule(this.State.ScheduleConfiguration.ScheduleId);
113+
114+
if (this.State.Status == ScheduleStatus.Active)
115+
{
116+
context.SignalEntity(
117+
new EntityInstanceId(nameof(Schedule), this.State.ScheduleConfiguration.ScheduleId),
118+
nameof(this.RunSchedule),
119+
this.State.ExecutionToken);
120+
}
113121
}
114122
catch (Exception ex)
115123
{

test/ScheduledTasks.Tests/Entity/ScheduleTests.cs

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,38 @@
55
using Microsoft.Extensions.Logging;
66
using Moq;
77
using Xunit;
8+
using Xunit.Abstractions;
89

910
namespace Microsoft.DurableTask.ScheduledTasks.Tests.Entity;
1011

1112
public class ScheduleTests
1213
{
13-
readonly Mock<ILogger<Schedule>> mockLogger;
1414
readonly Mock<TaskEntityContext> mockContext;
1515
readonly Schedule schedule;
1616
readonly string scheduleId = "test-schedule";
17+
readonly TestLogger logger;
1718

18-
public ScheduleTests()
19+
public ScheduleTests(ITestOutputHelper output)
1920
{
20-
this.mockLogger = new Mock<ILogger<Schedule>>(MockBehavior.Loose);
2121
this.mockContext = new Mock<TaskEntityContext>(MockBehavior.Strict);
22-
this.schedule = new Schedule(this.mockLogger.Object);
22+
this.logger = new TestLogger();
23+
this.schedule = new Schedule(this.logger);
24+
}
25+
26+
// Simple TestLogger implementation for capturing logs
27+
class TestLogger : ILogger<Schedule>
28+
{
29+
public List<(LogLevel Level, string Message)> Logs { get; } = new();
30+
31+
public IDisposable? BeginScope<TState>(TState state) where TState : notnull => null;
32+
33+
public bool IsEnabled(LogLevel logLevel) => true;
34+
35+
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
36+
{
37+
string message = formatter(state, exception);
38+
this.Logs.Add((logLevel, message));
39+
}
2340
}
2441

2542
[Fact]

0 commit comments

Comments
 (0)