Skip to content

Commit fddf4cf

Browse files
committed
Use TheoryData<T> for increased type safety
1 parent 44e2a53 commit fddf4cf

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

Tests/FluentAssertions.DataSets.Specs/DataSpecs.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Data;
55
using System.Diagnostics.CodeAnalysis;
66
using System.Linq;
7+
using Xunit;
78

89
namespace FluentAssertions.DataSets.Specs;
910

@@ -588,17 +589,24 @@ public enum ChangeType
588589
Removed,
589590
}
590591

591-
public static IEnumerable<object[]> AllChangeTypes =>
592-
Enum.GetValues(typeof(ChangeType)).Cast<ChangeType>().Select(t => new object[] { t });
592+
public static TheoryData<ChangeType> AllChangeTypes =>
593+
new(Enum.GetValues(typeof(ChangeType)).Cast<ChangeType>());
593594

594-
public static IEnumerable<object[]> AllChangeTypesWithAcceptChangesValues
595+
public static TheoryData<ChangeType, bool> AllChangeTypesWithAcceptChangesValues
595596
{
596597
get
597598
{
598-
return
599-
from changeType in Enum.GetValues(typeof(ChangeType)).Cast<ChangeType>()
600-
from acceptChanges in new[] { true, false }
601-
select new object[] { changeType, acceptChanges };
599+
var result = new TheoryData<ChangeType, bool>();
600+
601+
foreach (var changeType in Enum.GetValues(typeof(ChangeType)).Cast<ChangeType>())
602+
{
603+
foreach (var acceptChanges in new[] { true, false })
604+
{
605+
result.Add(changeType, acceptChanges);
606+
}
607+
}
608+
609+
return result;
602610
}
603611
}
604612

0 commit comments

Comments
 (0)