Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Funcky.Xunit/Extensions/ToTheoryDataExtension.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#if !XUNIT_V3
using System.ComponentModel;
using Xunit;

namespace Funcky.Extensions;
Expand Down Expand Up @@ -38,10 +39,16 @@ public static TheoryData<T1, T2, T3, T4, T5, T6, T7> ToTheoryData<T1, T2, T3, T4
=> source.Aggregate(new TheoryData<T1, T2, T3, T4, T5, T6, T7>(), AddElementToTheoryData);

[Pure]
[Obsolete("This overload is incorrect, the last element has to be a tuple itself.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public static TheoryData<T1, T2, T3, T4, T5, T6, T7, T8> ToTheoryData<T1, T2, T3, T4, T5, T6, T7, T8>(this IEnumerable<Tuple<T1, T2, T3, T4, T5, T6, T7, T8>> source)
where T8 : notnull
=> source.Aggregate(new TheoryData<T1, T2, T3, T4, T5, T6, T7, T8>(), AddElementToTheoryData);

[Pure]
public static TheoryData<T1, T2, T3, T4, T5, T6, T7, T8> ToTheoryData<T1, T2, T3, T4, T5, T6, T7, T8>(this IEnumerable<Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>>> source)
=> source.Aggregate(new TheoryData<T1, T2, T3, T4, T5, T6, T7, T8>(), AddElementToTheoryData);

[Pure]
public static TheoryData<T1, T2, T3, T4, T5, T6, T7, T8, T9> ToTheoryData<T1, T2, T3, T4, T5, T6, T7, T8, T9>(this IEnumerable<Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>>> source)
=> source.Aggregate(new TheoryData<T1, T2, T3, T4, T5, T6, T7, T8, T9>(), AddElementToTheoryData);
Expand Down Expand Up @@ -154,6 +161,13 @@ private static TheoryData<T1, T2, T3, T4, T5, T6, T7, T8> AddElementToTheoryData
return theoryData;
}

private static TheoryData<T1, T2, T3, T4, T5, T6, T7, T8> AddElementToTheoryData<T1, T2, T3, T4, T5, T6, T7, T8>(TheoryData<T1, T2, T3, T4, T5, T6, T7, T8> theoryData, Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8>> tuple)
{
theoryData.Add(tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, tuple.Item6, tuple.Item7, tuple.Rest.Item1);

return theoryData;
}

private static TheoryData<T1, T2, T3, T4, T5, T6, T7, T8, T9> AddElementToTheoryData<T1, T2, T3, T4, T5, T6, T7, T8, T9>(TheoryData<T1, T2, T3, T4, T5, T6, T7, T8, T9> theoryData, Tuple<T1, T2, T3, T4, T5, T6, T7, Tuple<T8, T9>> tuple)
{
theoryData.Add(tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4, tuple.Item5, tuple.Item6, tuple.Item7, tuple.Rest.Item1, tuple.Rest.Item2);
Expand Down
1 change: 1 addition & 0 deletions Funcky.Xunit/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
#nullable enable
static Funcky.Extensions.ToTheoryDataExtension.ToTheoryData<T1, T2, T3, T4, T5, T6, T7, T8>(this System.Collections.Generic.IEnumerable<System.Tuple<T1, T2, T3, T4, T5, T6, T7, System.Tuple<T8>!>!>! source) -> Xunit.TheoryData<T1, T2, T3, T4, T5, T6, T7, T8>!