@@ -121,8 +121,12 @@ public async Task CronJobThatIsScheduledEverySecondShouldBeExecuted()
121
121
{
122
122
var fakeTimer = TimeProviderFactory . GetTimeProvider ( ) ;
123
123
ServiceCollection . AddSingleton < TimeProvider > ( fakeTimer ) ;
124
- ServiceCollection . AddNCronJob ( p => p . EnableSecondPrecision = true ) ;
125
- ServiceCollection . AddCronJob < SimpleJob > ( p => p . CronExpression = "* * * * * *" ) ;
124
+ ServiceCollection . AddNCronJob ( ) ;
125
+ ServiceCollection . AddCronJob < SimpleJob > ( p =>
126
+ {
127
+ p . EnableSecondPrecision = true ;
128
+ p . CronExpression = "* * * * * *" ;
129
+ } ) ;
126
130
await using var provider = ServiceCollection . BuildServiceProvider ( ) ;
127
131
128
132
await provider . GetRequiredService < IHostedService > ( ) . StartAsync ( CancellationToken ) ;
@@ -132,6 +136,30 @@ public async Task CronJobThatIsScheduledEverySecondShouldBeExecuted()
132
136
jobFinished . ShouldBeTrue ( ) ;
133
137
}
134
138
139
+ [ Fact ]
140
+ public async Task CanRunSecondPrecisionAndMinutePrecisionJobs ( )
141
+ {
142
+ var fakeTimer = TimeProviderFactory . GetTimeProvider ( ) ;
143
+ ServiceCollection . AddSingleton < TimeProvider > ( fakeTimer ) ;
144
+ ServiceCollection . AddNCronJob ( ) ;
145
+ ServiceCollection . AddCronJob < SimpleJob > ( p =>
146
+ {
147
+ p . EnableSecondPrecision = true ;
148
+ p . CronExpression = "* * * * * *" ;
149
+ } ) ;
150
+ ServiceCollection . AddCronJob < SimpleJob > ( p =>
151
+ {
152
+ p . CronExpression = "* * * * *" ;
153
+ } ) ;
154
+ await using var provider = ServiceCollection . BuildServiceProvider ( ) ;
155
+
156
+ await provider . GetRequiredService < IHostedService > ( ) . StartAsync ( CancellationToken ) ;
157
+
158
+ fakeTimer . Advance ( TimeSpan . FromSeconds ( 61 ) ) ;
159
+ var jobFinished = await WaitForJobsOrTimeout ( 61 ) ;
160
+ jobFinished . ShouldBeTrue ( ) ;
161
+ }
162
+
135
163
[ Fact ]
136
164
public async Task LongRunningJobShouldNotBlockSchedulerWithIsolationLevelTask ( )
137
165
{
0 commit comments