Skip to content

Commit 78430c4

Browse files
remove redundant code and add more UTs
1 parent 7978913 commit 78430c4

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/Microsoft.FeatureManagement/FeatureFilters/Crontab/CrontabField.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ public bool TryParse(string content, out string message)
111111
if (string.Equals(range, "*")) // asterisk represents unrestricted range
112112
{
113113
(first, last) = (_minValue, _maxValue);
114-
115-
if (_kind == CrontabFieldKind.DayOfWeek) // Corner case for Sunday: both 0 and 7 can be interpreted to Sunday
116-
{
117-
last = _maxValue - 1;
118-
}
119114
}
120115
else // range should be defined by two numbers separated with a hyphen
121116
{

tests/Tests.FeatureManagement/Crontab.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class CrontabTest
1414
[InlineData("* * * * *", true)]
1515
[InlineData("1 2 3 Apr Fri", true)]
1616
[InlineData("00-59/3,1,2-2 01,3,20-23 */10,31-1/100 Apr,1-Feb,oct-DEC/1 Sun-Sat/2,1-7", true)]
17+
[InlineData("* * * * 0-7", true)]
1718
[InlineData("Fri * * * *", false)]
1819
[InlineData("1 2 Wed 4 5", false)]
1920
[InlineData("* * * * * *", false)]
@@ -51,6 +52,7 @@ public void ValidateCronExpressionTest(string expression, bool expected)
5152
[InlineData("0-29 21 * * *", "Thu, 31 Aug 2023 21:30:00 +08:00", false)]
5253
[InlineData("* * * * Sun-Sat", "Fri, 1 Sep 2023 21:00:00 +08:00", true)]
5354
[InlineData("* * 3 9 Mon-Sun", "Sun, 3 Sep 2023 21:00:00 +08:00", true)]
55+
[InlineData("* * * * 7", "Sun, 3 Sep 2023 21:00:00 +08:00", true)]
5456
public void IsCrontabSatisfiedByTimeTest(string expression, string timeString, bool expected)
5557
{
5658
Assert.True(ValidateExpression(expression));
@@ -66,7 +68,7 @@ private bool ValidateExpression(string expression)
6668
CrontabExpression crontabExpression = CrontabExpression.Parse(expression);
6769
return true;
6870
}
69-
catch (Exception ex)
71+
catch (Exception _)
7072
{
7173
return false;
7274
}

0 commit comments

Comments
 (0)