forked from bradymholt/cron-expression-descriptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestFormats.en-AU.cs
467 lines (390 loc) · 17.2 KB
/
TestFormats.en-AU.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
using NUnit.Framework;
using System.Globalization;
using System.Threading;
namespace CronExpressionDescriptor.Test
{
[TestFixture]
public class TestFormatsEnAU
{
[TestFixtureSetUp]
public void SetUp()
{
CultureInfo myCultureInfo = new CultureInfo("en-AU");
Thread.CurrentThread.CurrentCulture = myCultureInfo;
Thread.CurrentThread.CurrentUICulture = myCultureInfo;
}
[Test]
public void TestEveryMinute()
{
Assert.AreEqual("Every minute", ExpressionDescriptor.GetDescription("* * * * *"));
}
[Test]
public void TestEvery1Minute()
{
Assert.AreEqual("Every minute", ExpressionDescriptor.GetDescription("*/1 * * * *"));
Assert.AreEqual("Every minute", ExpressionDescriptor.GetDescription("0 0/1 * * * ?"));
}
[Test]
public void TestEveryHour()
{
Assert.AreEqual("Every hour", ExpressionDescriptor.GetDescription("0 0 * * * ?"));
Assert.AreEqual("Every hour", ExpressionDescriptor.GetDescription("0 0 0/1 * * ?"));
}
[Test]
public void TestTimeOfDayCertainDaysOfWeek()
{
Assert.AreEqual("At 11:00 PM, Monday through Friday", ExpressionDescriptor.GetDescription("0 23 ? * MON-FRI"));
}
[Test]
public void TestEverySecond()
{
Assert.AreEqual("Every second", ExpressionDescriptor.GetDescription("* * * * * *"));
}
[Test]
public void TestEvery45Seconds()
{
Assert.AreEqual("Every 45 seconds", ExpressionDescriptor.GetDescription("*/45 * * * * *"));
}
[Test]
public void TestEvery5Minutes()
{
Assert.AreEqual("Every 5 minutes", ExpressionDescriptor.GetDescription("*/5 * * * *"));
Assert.AreEqual("Every 10 minutes", ExpressionDescriptor.GetDescription("0 0/10 * * * ?"));
}
[Test]
public void TestEvery5MinutesOnTheSecond()
{
Assert.AreEqual("Every 5 minutes", ExpressionDescriptor.GetDescription("0 */5 * * * *"));
}
[Test]
public void TestWeekdaysAtTime()
{
Assert.AreEqual("At 11:30 AM, Monday through Friday", ExpressionDescriptor.GetDescription("30 11 * * 1-5"));
}
[Test]
public void TestDailyAtTime()
{
Assert.AreEqual("At 11:30 AM", ExpressionDescriptor.GetDescription("30 11 * * *"));
}
[Test]
public void TestMinuteSpan()
{
Assert.AreEqual("Every minute between 11:00 AM and 11:10 AM", ExpressionDescriptor.GetDescription("0-10 11 * * *"));
}
[Test]
public void TestOneMonthOnly()
{
Assert.AreEqual("Every minute, only in March", ExpressionDescriptor.GetDescription("* * * 3 *"));
}
[Test]
public void TestTwoMonthsOnly()
{
Assert.AreEqual("Every minute, only in March and June", ExpressionDescriptor.GetDescription("* * * 3,6 *"));
}
[Test]
public void TestTwoTimesEachAfternoon()
{
Assert.AreEqual("At 02:30 PM and 04:30 PM", ExpressionDescriptor.GetDescription("30 14,16 * * *"));
}
[Test]
public void TestThreeTimesDaily()
{
Assert.AreEqual("At 06:30 AM, 02:30 PM and 04:30 PM", ExpressionDescriptor.GetDescription("30 6,14,16 * * *"));
}
[Test]
public void TestOnceAWeek()
{
Assert.AreEqual("At 09:46 AM, only on Monday", ExpressionDescriptor.GetDescription("46 9 * * 1"));
}
[Test]
public void TestDayOfMonth()
{
Assert.AreEqual("At 12:23 PM, on day 15 of the month", ExpressionDescriptor.GetDescription("23 12 15 * *"));
}
[Test]
public void TestMonthName()
{
Assert.AreEqual("At 12:23 PM, only in January", ExpressionDescriptor.GetDescription("23 12 * JAN *"));
}
[Test]
public void TestDayOfMonthWithQuestionMark()
{
Assert.AreEqual("At 12:23 PM, only in January", ExpressionDescriptor.GetDescription("23 12 ? JAN *"));
}
[Test]
public void TestMonthNameRange2()
{
Assert.AreEqual("At 12:23 PM, January through February", ExpressionDescriptor.GetDescription("23 12 * JAN-FEB *"));
}
[Test]
public void TestMonthNameRange3()
{
Assert.AreEqual("At 12:23 PM, January through March", ExpressionDescriptor.GetDescription("23 12 * JAN-MAR *"));
}
[Test]
public void TestDayOfWeekName()
{
Assert.AreEqual("At 12:23 PM, only on Sunday", ExpressionDescriptor.GetDescription("23 12 * * SUN"));
}
[Test]
public void TestDayOfWeekRange()
{
Assert.AreEqual("Every 5 minutes, at 03:00 PM, Monday through Friday", ExpressionDescriptor.GetDescription("*/5 15 * * MON-FRI"));
}
[Test]
public void TestDayOfWeekOnceInMonth()
{
Assert.AreEqual("Every minute, on the third Monday of the month", ExpressionDescriptor.GetDescription("* * * * MON#3"));
}
[Test]
public void TestLastDayOfTheWeekOfTheMonth()
{
Assert.AreEqual("Every minute, on the last Thursday of the month", ExpressionDescriptor.GetDescription("* * * * 4L"));
}
[Test]
public void TestLastDayOfTheMonth()
{
Assert.AreEqual("Every 5 minutes, on the last day of the month, only in January", ExpressionDescriptor.GetDescription("*/5 * L JAN *"));
}
[Test]
public void TestLastWeekdayOfTheMonth()
{
Assert.AreEqual("Every minute, on the last weekday of the month", ExpressionDescriptor.GetDescription("* * LW * *"));
}
[Test]
public void TestLastWeekdayOfTheMonth2()
{
Assert.AreEqual("Every minute, on the last weekday of the month", ExpressionDescriptor.GetDescription("* * WL * *"));
}
[Test]
public void TestFirstWeekdayOfTheMonth()
{
Assert.AreEqual("Every minute, on the first weekday of the month", ExpressionDescriptor.GetDescription("* * 1W * *"));
}
[Test]
public void TestThirteenthWeekdayOfTheMonth()
{
Assert.AreEqual("Every minute, on the weekday nearest day 13 of the month", ExpressionDescriptor.GetDescription("* * 13W * *"));
}
[Test]
public void TestFirstWeekdayOfTheMonth2()
{
Assert.AreEqual("Every minute, on the first weekday of the month", ExpressionDescriptor.GetDescription("* * W1 * *"));
}
[Test]
public void TestParticularWeekdayOfTheMonth()
{
Assert.AreEqual("Every minute, on the weekday nearest day 5 of the month", ExpressionDescriptor.GetDescription("* * 5W * *"));
}
[Test]
public void TestParticularWeekdayOfTheMonth2()
{
Assert.AreEqual("Every minute, on the weekday nearest day 5 of the month", ExpressionDescriptor.GetDescription("* * W5 * *"));
}
[Test]
public void TestTimeOfDayWithSeconds()
{
Assert.AreEqual("At 02:02:30 PM", ExpressionDescriptor.GetDescription("30 02 14 * * *"));
}
[Test]
public void TestSecondInternvals()
{
Assert.AreEqual("Seconds 5 through 10 past the minute", ExpressionDescriptor.GetDescription("5-10 * * * * *"));
}
[Test]
public void TestMultiPartSecond()
{
Assert.AreEqual("At 15 and 45 seconds past the minute", ExpressionDescriptor.GetDescription("15,45 * * * * *"));
}
[Test]
public void TestSecondMinutesHoursIntervals()
{
Assert.AreEqual("Seconds 5 through 10 past the minute, minutes 30 through 35 past the hour, between 10:00 AM and 12:59 PM", ExpressionDescriptor.GetDescription("5-10 30-35 10-12 * * *"));
}
[Test]
public void TestEvery5MinutesAt30Seconds()
{
Assert.AreEqual("At 30 seconds past the minute, every 5 minutes", ExpressionDescriptor.GetDescription("30 */5 * * * *"));
}
[Test]
public void TestMinutesPastTheHourRange()
{
Assert.AreEqual("At 30 minutes past the hour, between 10:00 AM and 01:59 PM, only on Wednesday and Friday", ExpressionDescriptor.GetDescription("0 30 10-13 ? * WED,FRI"));
}
[Test]
public void TestSecondsPastTheMinuteInterval()
{
Assert.AreEqual("At 10 seconds past the minute, every 5 minutes", ExpressionDescriptor.GetDescription("10 0/5 * * * ?"));
}
[Test]
public void TestBetweenWithInterval()
{
Assert.AreEqual("Every 3 minutes, minutes 2 through 59 past the hour, at 01:00 AM, 09:00 AM, and 10:00 PM, between day 11 and 26 of the month, January through June", ExpressionDescriptor.GetDescription("2-59/3 1,9,22 11-26 1-6 ?"));
}
[Test]
public void TestRecurringFirstOfMonth()
{
Assert.AreEqual("At 06:00 AM", ExpressionDescriptor.GetDescription("0 0 6 1/1 * ?"));
}
[Test]
public void TestMinutesPastTheHour()
{
Assert.AreEqual("At 5 minutes past the hour", ExpressionDescriptor.GetDescription("0 5 0/1 * * ?"));
}
[Test]
public void TestOneYearOnlyWithSeconds()
{
Assert.AreEqual("Every second, only in 2013", ExpressionDescriptor.GetDescription("* * * * * * 2013"));
}
[Test]
public void TestOneYearOnlyWithoutSeconds()
{
Assert.AreEqual("Every minute, only in 2013", ExpressionDescriptor.GetDescription("* * * * * 2013"));
}
[Test]
public void TestTwoYearsOnly()
{
Assert.AreEqual("Every minute, only in 2013 and 2014", ExpressionDescriptor.GetDescription("* * * * * 2013,2014"));
}
[Test]
public void TestYearRange2()
{
Assert.AreEqual("At 12:23 PM, January through February, 2013 through 2014", ExpressionDescriptor.GetDescription("23 12 * JAN-FEB * 2013-2014"));
}
[Test]
public void TestYearRange3()
{
Assert.AreEqual("At 12:23 PM, January through March, 2013 through 2015", ExpressionDescriptor.GetDescription("23 12 * JAN-MAR * 2013-2015"));
}
[Test]
public void TestHourRange()
{
Assert.AreEqual("Every 30 minutes, between 08:00 AM and 09:59 AM, on day 5 and 20 of the month", ExpressionDescriptor.GetDescription("0 0/30 8-9 5,20 * ?"));
}
[Test]
public void TestDayOfWeekModifier()
{
Assert.AreEqual("At 12:23 PM, on the second Sunday of the month", ExpressionDescriptor.GetDescription("23 12 * * SUN#2"));
}
[Test]
public void TestDayOfWeekModifierWithSundayStartOne()
{
Options options = new Options();
options.DayOfWeekStartIndexZero = false;
Assert.AreEqual("At 12:23 PM, on the second Sunday of the month", ExpressionDescriptor.GetDescription("23 12 * * 1#2", options));
}
[Test]
public void TestHourRangeWithEveryPortion()
{
Assert.AreEqual("At 25 minutes past the hour, every 8 hours, between 07:00 AM and 07:59 PM", ExpressionDescriptor.GetDescription("0 25 7-19/8 ? * *"));
}
[Test]
public void TestHourRangeWithTrailingZeroWithEveryPortion()
{
Assert.AreEqual("At 25 minutes past the hour, every 13 hours, between 07:00 AM and 08:59 PM", ExpressionDescriptor.GetDescription("0 25 7-20/13 ? * *"));
}
[Test]
public void TestEvery3Day()
{
Assert.AreEqual("At 08:00 AM, every 3 days", ExpressionDescriptor.GetDescription("0 0 8 1/3 * ? *"));
}
[Test]
public void TestsEvery3DayOfTheWeek()
{
Assert.AreEqual("At 10:15 AM, every 3 days of the week", ExpressionDescriptor.GetDescription("0 15 10 ? * */3"));
}
[Test]
public void TestEvery2DayOfTheWeekInRange()
{
// GitHub Issue #58: https://github.com/bradyholt/cron-expression-descriptor/issues/58
Assert.AreEqual("Every second, every 2 days of the week, Monday through Friday", ExpressionDescriptor.GetDescription("* * * ? * 1-5/2"));
}
[Test]
public void TestEvery2DayOfTheWeekInRangeWithSundayStartOne()
{
// GitHub Issue #59: https://github.com/bradyholt/cron-expression-descriptor/issues/59
var options = new Options { DayOfWeekStartIndexZero = false };
Assert.AreEqual("Every second, every 2 days of the week, Monday through Friday",
ExpressionDescriptor.GetDescription("* * * ? * 2-6/2", options));
}
[Test]
public void TestEvery3Month()
{
Assert.AreEqual("At 07:05 AM, on day 2 of the month, every 3 months", ExpressionDescriptor.GetDescription("0 5 7 2 1/3 ? *"));
}
[Test]
public void TestEvery2Years()
{
Assert.AreEqual("At 06:15 AM, on day 1 of the month, only in January, every 2 years", ExpressionDescriptor.GetDescription("0 15 6 1 1 ? 1/2"));
}
[Test]
public void TestMutiPartRangeMinutes()
{
Assert.AreEqual("At 2 and 4 through 5 minutes past the hour, at 01:00 AM", ExpressionDescriptor.GetDescription("2,4-5 1 * * *"));
}
[Test]
public void TestMutiPartRangeMinutes2()
{
Assert.AreEqual("At 2 and 26 through 28 minutes past the hour, at 06:00 PM", ExpressionDescriptor.GetDescription("2,26-28 18 * * *"));
}
[Test]
public void TrailingSpaceDoesNotCauseAWrongDescription()
{
// GitHub Issue #51: https://github.com/bradyholt/cron-expression-descriptor/issues/51
Assert.AreEqual("At 07:00 AM", ExpressionDescriptor.GetDescription("0 7 * * * "));
}
[Test]
public void TestMultiPartDayOfTheWeek()
{
// GitHub Issue #44: https://github.com/bradyholt/cron-expression-descriptor/issues/44
Assert.AreEqual("At 10:00 AM, only on Monday through Thursday and Sunday", ExpressionDescriptor.GetDescription("0 00 10 ? * MON-THU,SUN *"));
}
[Test]
public void TestDayOfWeekWithDayOfMonth()
{
// GitHub Issue #46: https://github.com/bradyholt/cron-expression-descriptor/issues/46
Assert.AreEqual("At 00:00 AM, on day 1, 2, and 3 of the month, only on Wednesday and Friday", ExpressionDescriptor.GetDescription("0 0 0 1,2,3 * WED,FRI"));
}
[Test]
public void TestSecondsInternalWithStepValue()
{
// GitHub Issue #49: https://github.com/bradyholt/cron-expression-descriptor/issues/49
Assert.AreEqual("Every 30 seconds, starting at 5 seconds past the minute", ExpressionDescriptor.GetDescription("5/30 * * * * ?"));
}
[Test]
public void TestMinutesInternalWithStepValue()
{
Assert.AreEqual("Every 30 minutes, starting at 5 minutes past the hour", ExpressionDescriptor.GetDescription("0 5/30 * * * ?"));
}
[Test]
public void TestHoursInternalWithStepValue()
{
Assert.AreEqual("Every second, every 8 hours, starting at 05:00 AM", ExpressionDescriptor.GetDescription("* * 5/8 * * ?"));
}
[Test]
public void TestDayOfMonthInternalWithStepValue()
{
Assert.AreEqual("At 07:05 AM, every 3 days, starting on day 2 of the month", ExpressionDescriptor.GetDescription("0 5 7 2/3 * ? *"));
}
[Test]
public void TestMonthInternalWithStepValue()
{
Assert.AreEqual("At 07:05 AM, every 2 months, March through December", ExpressionDescriptor.GetDescription("0 5 7 ? 3/2 ? *"));
}
[Test]
public void TestDayOfWeekInternalWithStepValue()
{
Assert.AreEqual("At 07:05 AM, every 3 days of the week, Tuesday through Saturday", ExpressionDescriptor.GetDescription("0 5 7 ? * 2/3 *"));
}
[Test]
public void TestYearInternalWithStepValue()
{
Assert.AreEqual("At 07:05 AM, every 4 years, 2016 through 9999", ExpressionDescriptor.GetDescription("0 5 7 ? * ? 2016/4"));
}
[Test]
public void TestMinitesCombinedWithMultipleHourRanges()
{
Assert.AreEqual("At 1 minutes past the hour, at 01:00 AM and 03:00 AM through 04:59 AM", ExpressionDescriptor.GetDescription("1 1,3-4 * * *"));
}
}
}