Skip to content

Commit c27d430

Browse files
committed
Refactors test data to use collection initializers
Uses collection initializers for test data to improve code readability and conciseness in multiple test files. This change replaces the `new object[] {}` syntax with `[] {}` making the test data definitions more compact and easier to understand.
1 parent cace332 commit c27d430

18 files changed

+171
-171
lines changed

tests/Exceptionless.DateTimeExtensions.Tests/DateTimeRangeTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,19 +70,19 @@ public void CanParseNamedRanges(string input, DateTime start, DateTime end)
7070

7171
public static IEnumerable<object[]> Inputs => new[] {
7272
new object[] { "today", _now.StartOfDay(), _now.EndOfDay() },
73-
new object[] { "yesterday", _now.SubtractDays(1).StartOfDay(), _now.SubtractDays(1).EndOfDay() },
74-
new object[] { "tomorrow", _now.AddDays(1).StartOfDay(), _now.AddDays(1).EndOfDay() },
75-
new object[] { "last 5 minutes", _now.SubtractMinutes(5).StartOfMinute(), _now },
76-
new object[] { "this 5 minutes", _now, _now.AddMinutes(5).EndOfMinute() },
77-
new object[] { "next 5 minutes", _now, _now.AddMinutes(5).EndOfMinute() },
78-
new object[] { "last jan", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(1).EndOfMonth() },
79-
new object[] { "jan", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(1).EndOfMonth() },
80-
new object[] { "noVemBer", _now.StartOfMonth(), _now.EndOfMonth() },
81-
new object[] { "deC", _now.ChangeMonth(12).StartOfMonth(), _now.ChangeMonth(12).EndOfMonth() },
82-
new object[] { "next deC", _now.ChangeMonth(12).StartOfMonth(), _now.ChangeMonth(12).EndOfMonth() },
83-
new object[] { "next nov", _now.AddYears(1).StartOfMonth(), _now.AddYears(1).EndOfMonth() },
84-
new object[] { "next jan", _now.AddYears(1).ChangeMonth(1).StartOfMonth(), _now.AddYears(1).ChangeMonth(1).EndOfMonth() },
85-
new object[] { "jan-feb", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(2).EndOfMonth() },
86-
new object[] { "now-this feb", _now, _now.AddYears(1).ChangeMonth(2).EndOfMonth() }
73+
["yesterday", _now.SubtractDays(1).StartOfDay(), _now.SubtractDays(1).EndOfDay()],
74+
["tomorrow", _now.AddDays(1).StartOfDay(), _now.AddDays(1).EndOfDay()],
75+
["last 5 minutes", _now.SubtractMinutes(5).StartOfMinute(), _now],
76+
["this 5 minutes", _now, _now.AddMinutes(5).EndOfMinute()],
77+
["next 5 minutes", _now, _now.AddMinutes(5).EndOfMinute()],
78+
["last jan", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(1).EndOfMonth()],
79+
["jan", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(1).EndOfMonth()],
80+
["noVemBer", _now.StartOfMonth(), _now.EndOfMonth()],
81+
["deC", _now.ChangeMonth(12).StartOfMonth(), _now.ChangeMonth(12).EndOfMonth()],
82+
["next deC", _now.ChangeMonth(12).StartOfMonth(), _now.ChangeMonth(12).EndOfMonth()],
83+
["next nov", _now.AddYears(1).StartOfMonth(), _now.AddYears(1).EndOfMonth()],
84+
["next jan", _now.AddYears(1).ChangeMonth(1).StartOfMonth(), _now.AddYears(1).ChangeMonth(1).EndOfMonth()],
85+
["jan-feb", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(2).EndOfMonth()],
86+
["now-this feb", _now, _now.AddYears(1).ChangeMonth(2).EndOfMonth()]
8787
};
8888
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/ExplicitDateFormatParserTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "2014-02-01", _now.Change(null, 2, 1).StartOfDay(), _now.Change(null, 2, 1).EndOfDay() },
26-
new object[] { "2014-02-01T05", _now.Change(null, 2, 1, 5).StartOfHour(), _now.Change(null, 2, 1, 5).EndOfHour() },
27-
new object[] { "2014-02-01T05:30", _now.Change(null, 2, 1, 5, 30).StartOfMinute(), _now.Change(null, 2, 1, 5, 30).EndOfMinute() },
28-
new object[] { "2014-02-01T05:30:20", _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond(), _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond() },
29-
new object[] { "2014-02-01T05:30:20.000", _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond(), _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond() },
30-
new object[] { "2014-02-01T05:30:20.000Z", _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond(), _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond() },
31-
new object[] { "2014-11-06", _now.Change(null, 11, 6).StartOfDay(), _now.Change(null, 11, 6).EndOfDay() },
32-
new object[] { "2014-12-24", _now.Change(null, 12, 24).StartOfDay(), _now.Change(null, 12, 24).EndOfDay() },
33-
new object[] { "2014-12-45", null, null },
34-
new object[] { "blah", null, null },
35-
new object[] { "blah blah", null, null }
26+
["2014-02-01T05", _now.Change(null, 2, 1, 5).StartOfHour(), _now.Change(null, 2, 1, 5).EndOfHour()],
27+
["2014-02-01T05:30", _now.Change(null, 2, 1, 5, 30).StartOfMinute(), _now.Change(null, 2, 1, 5, 30).EndOfMinute()],
28+
["2014-02-01T05:30:20", _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond(), _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond()],
29+
["2014-02-01T05:30:20.000", _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond(), _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond()],
30+
["2014-02-01T05:30:20.000Z", _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond(), _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond()],
31+
["2014-11-06", _now.Change(null, 11, 6).StartOfDay(), _now.Change(null, 11, 6).EndOfDay()],
32+
["2014-12-24", _now.Change(null, 12, 24).StartOfDay(), _now.Change(null, 12, 24).EndOfDay()],
33+
["2014-12-45", null, null],
34+
["blah", null, null],
35+
["blah blah", null, null]
3636
};
3737
}
3838
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/MonthDayFormatParserTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "02-01", _now.Change(null, 2, 1).StartOfDay(), _now.Change(null, 2, 1).EndOfDay() },
26-
new object[] { "11-06", _now.Change(null, 11, 6).StartOfDay(), _now.Change(null, 11, 6).EndOfDay() },
27-
new object[] { "12-24", _now.Change(null, 12, 24).StartOfDay(), _now.Change(null, 12, 24).EndOfDay() },
28-
new object[] { "12-45", null, null },
29-
new object[] { "blah", null, null },
30-
new object[] { "blah blah", null, null }
26+
["11-06", _now.Change(null, 11, 6).StartOfDay(), _now.Change(null, 11, 6).EndOfDay()],
27+
["12-24", _now.Change(null, 12, 24).StartOfDay(), _now.Change(null, 12, 24).EndOfDay()],
28+
["12-45", null, null],
29+
["blah", null, null],
30+
["blah blah", null, null]
3131
};
3232
}
3333
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/MonthFormatParserTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "jan", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(1).EndOfMonth() },
26-
new object[] { "nov", _now.StartOfMonth(), _now.EndOfMonth() },
27-
new object[] { "decemBer", _now.ChangeMonth(12).StartOfMonth(), _now.ChangeMonth(12).EndOfMonth() },
28-
new object[] { "blah", null, null },
29-
new object[] { "blah blah", null, null }
26+
["nov", _now.StartOfMonth(), _now.EndOfMonth()],
27+
["decemBer", _now.ChangeMonth(12).StartOfMonth(), _now.ChangeMonth(12).EndOfMonth()],
28+
["blah", null, null],
29+
["blah blah", null, null]
3030
};
3131
}
3232
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/MonthRelationFormatParserTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "this janUary", _now.AddYears(1).ChangeMonth(1).StartOfMonth(), _now.AddYears(1).ChangeMonth(1).EndOfMonth() },
26-
new object[] { "last jan", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(1).EndOfMonth() },
27-
new object[] { "next januaRY", _now.AddYears(1).ChangeMonth(1).StartOfMonth(), _now.AddYears(1).ChangeMonth(1).EndOfMonth() },
28-
new object[] { "this november", _now.StartOfMonth(), _now.EndOfMonth() },
29-
new object[] { "next november", _now.AddYears(1).StartOfMonth(), _now.AddYears(1).EndOfMonth() },
30-
new object[] { "this december", _now.ChangeMonth(12).StartOfMonth(), _now.ChangeMonth(12).EndOfMonth() },
31-
new object[] { "last november", _now.SubtractYears(1).StartOfMonth(), _now.SubtractYears(1).EndOfMonth() },
32-
new object[] { "blah", null, null },
33-
new object[] { "blah blah", null, null }
26+
["last jan", _now.ChangeMonth(1).StartOfMonth(), _now.ChangeMonth(1).EndOfMonth()],
27+
["next januaRY", _now.AddYears(1).ChangeMonth(1).StartOfMonth(), _now.AddYears(1).ChangeMonth(1).EndOfMonth()],
28+
["this november", _now.StartOfMonth(), _now.EndOfMonth()],
29+
["next november", _now.AddYears(1).StartOfMonth(), _now.AddYears(1).EndOfMonth()],
30+
["this december", _now.ChangeMonth(12).StartOfMonth(), _now.ChangeMonth(12).EndOfMonth()],
31+
["last november", _now.SubtractYears(1).StartOfMonth(), _now.SubtractYears(1).EndOfMonth()],
32+
["blah", null, null],
33+
["blah blah", null, null]
3434
};
3535
}
3636
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/NamedDayFormatParserTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "yesterday", _now.SubtractDays(1).StartOfDay(), _now.SubtractDays(1).EndOfDay() },
26-
new object[] { "today", _now.StartOfDay(), _now.EndOfDay() },
27-
new object[] { "tomorrow", _now.AddDays(1).StartOfDay(), _now.AddDays(1).EndOfDay() },
28-
new object[] { "blah", null, null },
29-
new object[] { "blah blah", null, null }
26+
["today", _now.StartOfDay(), _now.EndOfDay()],
27+
["tomorrow", _now.AddDays(1).StartOfDay(), _now.AddDays(1).EndOfDay()],
28+
["blah", null, null],
29+
["blah blah", null, null]
3030
};
3131
}
3232
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/PartParsers/AmountTimeRelationPartParserTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "1 minute ago", false, _now.SubtractMinutes(1).StartOfMinute() },
26-
new object[] { "1 minute ago", true, _now.SubtractMinutes(1).EndOfMinute() },
27-
new object[] { "1 minute from now", false, _now.AddMinutes(1).StartOfMinute() },
28-
new object[] { "1 minute from now", true, _now.AddMinutes(1).EndOfMinute() },
29-
new object[] { "22 hours ago", false, _now.SubtractHours(22).StartOfHour() },
30-
new object[] { "22 hours ago", true, _now.SubtractHours(22).EndOfHour() },
31-
new object[] { "12 days from now", false, _now.AddDays(12).StartOfDay() },
32-
new object[] { "12 days from now", true, _now.AddDays(12).EndOfDay() },
33-
new object[] { "blah", false, null },
34-
new object[] { "blah blah", true, null }
26+
["1 minute ago", true, _now.SubtractMinutes(1).EndOfMinute()],
27+
["1 minute from now", false, _now.AddMinutes(1).StartOfMinute()],
28+
["1 minute from now", true, _now.AddMinutes(1).EndOfMinute()],
29+
["22 hours ago", false, _now.SubtractHours(22).StartOfHour()],
30+
["22 hours ago", true, _now.SubtractHours(22).EndOfHour()],
31+
["12 days from now", false, _now.AddDays(12).StartOfDay()],
32+
["12 days from now", true, _now.AddDays(12).EndOfDay()],
33+
["blah", false, null],
34+
["blah blah", true, null]
3535
};
3636
}
3737
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/PartParsers/ExplicitDatePartParserTests.cs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "2014-02-01", false, _now.Change(null, 2, 1).StartOfDay() },
26-
new object[] { "2014-02-01", true, _now.Change(null, 2, 1).EndOfDay() },
27-
new object[] { "2014-02-01T05", false, _now.Change(null, 2, 1, 5).StartOfHour() },
28-
new object[] { "2014-02-01T05", true, _now.Change(null, 2, 1, 5).EndOfHour() },
29-
new object[] { "2014-02-01T05:30", false, _now.Change(null, 2, 1, 5, 30).StartOfMinute() },
30-
new object[] { "2014-02-01T05:30", true, _now.Change(null, 2, 1, 5, 30).EndOfMinute() },
31-
new object[] { "2014-02-01T05:30:20", false, _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond() },
32-
new object[] { "2014-02-01T05:30:20", true, _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond() },
33-
new object[] { "2014-02-01T05:30:20.000", false, _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond() },
34-
new object[] { "2014-02-01T05:30:20.999", true, _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond() },
35-
new object[] { "2014-02-01T05:30:20.000Z", false, _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond() },
36-
new object[] { "2014-02-01T05:30:20.999Z", true, _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond() },
37-
new object[] { "2014-11-06", false, _now.Change(null, 11, 6).StartOfDay() },
38-
new object[] { "2014-11-06", true, _now.Change(null, 11, 6).EndOfDay() },
39-
new object[] { "2014-12-24", false, _now.Change(null, 12, 24).StartOfDay() },
40-
new object[] { "2014-12-24", true, _now.Change(null, 12, 24).EndOfDay() },
41-
new object[] { "2014-12-45", true, null },
42-
new object[] { "blah", false, null },
43-
new object[] { "blah blah", true, null }
26+
["2014-02-01", true, _now.Change(null, 2, 1).EndOfDay()],
27+
["2014-02-01T05", false, _now.Change(null, 2, 1, 5).StartOfHour()],
28+
["2014-02-01T05", true, _now.Change(null, 2, 1, 5).EndOfHour()],
29+
["2014-02-01T05:30", false, _now.Change(null, 2, 1, 5, 30).StartOfMinute()],
30+
["2014-02-01T05:30", true, _now.Change(null, 2, 1, 5, 30).EndOfMinute()],
31+
["2014-02-01T05:30:20", false, _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond()],
32+
["2014-02-01T05:30:20", true, _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond()],
33+
["2014-02-01T05:30:20.000", false, _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond()],
34+
["2014-02-01T05:30:20.999", true, _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond()],
35+
["2014-02-01T05:30:20.000Z", false, _now.Change(null, 2, 1, 5, 30, 20).StartOfSecond()],
36+
["2014-02-01T05:30:20.999Z", true, _now.Change(null, 2, 1, 5, 30, 20).EndOfSecond()],
37+
["2014-11-06", false, _now.Change(null, 11, 6).StartOfDay()],
38+
["2014-11-06", true, _now.Change(null, 11, 6).EndOfDay()],
39+
["2014-12-24", false, _now.Change(null, 12, 24).StartOfDay()],
40+
["2014-12-24", true, _now.Change(null, 12, 24).EndOfDay()],
41+
["2014-12-45", true, null],
42+
["blah", false, null],
43+
["blah blah", true, null]
4444
};
4545
}
4646
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/PartParsers/MonthDayPartParserTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "02-01", false, _now.ChangeMonth(2).ChangeDay(1).StartOfDay() },
26-
new object[] { "02-01", true, _now.ChangeMonth(2).ChangeDay(1).EndOfDay() },
27-
new object[] { "11-06", false, _now.ChangeMonth(11).ChangeDay(6).StartOfDay() },
28-
new object[] { "11-06", true, _now.ChangeMonth(11).ChangeDay(6).EndOfDay() },
29-
new object[] { "12-24", false, _now.ChangeMonth(12).ChangeDay(24).StartOfDay() },
30-
new object[] { "12-24", true, _now.ChangeMonth(12).ChangeDay(24).EndOfDay() },
31-
new object[] { "12-45", true, null },
32-
new object[] { "blah", false, null },
33-
new object[] { "blah blah", true, null }
26+
["02-01", true, _now.ChangeMonth(2).ChangeDay(1).EndOfDay()],
27+
["11-06", false, _now.ChangeMonth(11).ChangeDay(6).StartOfDay()],
28+
["11-06", true, _now.ChangeMonth(11).ChangeDay(6).EndOfDay()],
29+
["12-24", false, _now.ChangeMonth(12).ChangeDay(24).StartOfDay()],
30+
["12-24", true, _now.ChangeMonth(12).ChangeDay(24).EndOfDay()],
31+
["12-45", true, null],
32+
["blah", false, null],
33+
["blah blah", true, null]
3434
};
3535
}
3636
}

tests/Exceptionless.DateTimeExtensions.Tests/FormatParsers/PartParsers/MonthPartParserTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ public static IEnumerable<object[]> Inputs
2323
{
2424
return new[] {
2525
new object[] { "jan", false, _now.ChangeMonth(1).StartOfMonth() },
26-
new object[] { "jan", true, _now.ChangeMonth(1).EndOfMonth() },
27-
new object[] { "nov", false, _now.StartOfMonth() },
28-
new object[] { "nov", true, _now.EndOfMonth() },
29-
new object[] { "decemBer", false, _now.ChangeMonth(12).StartOfMonth() },
30-
new object[] { "dec", true, _now.ChangeMonth(12).EndOfMonth() },
31-
new object[] { "blah", false, null },
32-
new object[] { "blah blah", true, null }
26+
["jan", true, _now.ChangeMonth(1).EndOfMonth()],
27+
["nov", false, _now.StartOfMonth()],
28+
["nov", true, _now.EndOfMonth()],
29+
["decemBer", false, _now.ChangeMonth(12).StartOfMonth()],
30+
["dec", true, _now.ChangeMonth(12).EndOfMonth()],
31+
["blah", false, null],
32+
["blah blah", true, null]
3333
};
3434
}
3535
}

0 commit comments

Comments
 (0)