diff --git a/Directory.Packages.props b/Directory.Packages.props index 0f70553..6b81a0d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -11,7 +11,7 @@ - - + + diff --git a/RyuSocks.Test.Integration/RyuSocks.Test.Integration.csproj b/RyuSocks.Test.Integration/RyuSocks.Test.Integration.csproj index 72e5f9c..80e8155 100644 --- a/RyuSocks.Test.Integration/RyuSocks.Test.Integration.csproj +++ b/RyuSocks.Test.Integration/RyuSocks.Test.Integration.csproj @@ -1,6 +1,7 @@ + Exe net9.0 false true @@ -11,7 +12,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/RyuSocks.Test/RyuSocks.Test.csproj b/RyuSocks.Test/RyuSocks.Test.csproj index f60ac9a..48aba02 100644 --- a/RyuSocks.Test/RyuSocks.Test.csproj +++ b/RyuSocks.Test/RyuSocks.Test.csproj @@ -1,6 +1,7 @@ + Exe net9.0 false true @@ -17,7 +18,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/RyuSocks.Test/Utils/EnumDataAttribute.cs b/RyuSocks.Test/Utils/EnumDataAttribute.cs index bf1fb16..b95e632 100644 --- a/RyuSocks.Test/Utils/EnumDataAttribute.cs +++ b/RyuSocks.Test/Utils/EnumDataAttribute.cs @@ -15,19 +15,29 @@ using System; using System.Collections.Generic; using System.Reflection; +using System.Threading.Tasks; +using Xunit; using Xunit.Sdk; +using Xunit.v3; namespace RyuSocks.Test.Utils { public class EnumDataAttribute : DataAttribute where T : struct, Enum { - public override IEnumerable GetData(MethodInfo testMethod) + public override bool SupportsDiscoveryEnumeration() => true; + + public override ValueTask> GetData(MethodInfo testMethod, DisposalTracker disposalTracker) { - foreach (T value in Enum.GetValues()) + T[] values = Enum.GetValues(); + TheoryDataRow[] rows = new TheoryDataRow[values.Length]; + + for (int i = 0; i < values.Length; i++) { - yield return [value]; + rows[i] = new TheoryDataRow(values[i]); } + + return ValueTask.FromResult>(rows); } } } diff --git a/RyuSocks.Test/Utils/RangeDataAttribute.cs b/RyuSocks.Test/Utils/RangeDataAttribute.cs index c9b63bd..925bd0f 100644 --- a/RyuSocks.Test/Utils/RangeDataAttribute.cs +++ b/RyuSocks.Test/Utils/RangeDataAttribute.cs @@ -15,7 +15,10 @@ using System.Collections.Generic; using System.Numerics; using System.Reflection; +using System.Threading.Tasks; +using Xunit; using Xunit.Sdk; +using Xunit.v3; namespace RyuSocks.Test.Utils { @@ -26,6 +29,8 @@ public class RangeDataAttribute : DataAttribute private readonly T _max; private readonly T[] _extraElements; + public override bool SupportsDiscoveryEnumeration() => true; + public RangeDataAttribute(T min, T max, params T[] extraElements) { _min = min; @@ -33,21 +38,21 @@ public RangeDataAttribute(T min, T max, params T[] extraElements) _extraElements = extraElements; } - public override IEnumerable GetData(MethodInfo testMethod) + public override ValueTask> GetData(MethodInfo testMethod, DisposalTracker disposalTracker) { - List data = []; + List> data = []; for (T i = _min; i < _max; i++) { - data.Add(i); + data.Add(new TheoryDataRow([i])); } foreach (T element in _extraElements) { - data.Add(element); + data.Add(new TheoryDataRow([element])); } - return [[data.ToArray()]]; + return ValueTask.FromResult>(data); } } } diff --git a/RyuSocks.Test/Utils/StringDataAttribute.cs b/RyuSocks.Test/Utils/StringDataAttribute.cs index d01d6be..6c5a629 100644 --- a/RyuSocks.Test/Utils/StringDataAttribute.cs +++ b/RyuSocks.Test/Utils/StringDataAttribute.cs @@ -17,16 +17,22 @@ using System.Collections.Generic; using System.Reflection; using System.Text; +using System.Threading.Tasks; +using Xunit; using Xunit.Sdk; +using Xunit.v3; namespace RyuSocks.Test.Utils { public class StringDataAttribute : DataAttribute { + private const char Char = 'a'; private readonly int _min; private readonly int _max; private int _count; + public override bool SupportsDiscoveryEnumeration() => true; + public StringDataAttribute(int min, int max, int count) { _min = min; @@ -41,9 +47,9 @@ public StringDataAttribute(int firstLength, int secondLength) _count = 2; } - public override IEnumerable GetData(MethodInfo testMethod) + public override ValueTask> GetData(MethodInfo testMethod, DisposalTracker disposalTracker) { - List data = []; + List> data = []; StringBuilder builder = new(); int currentMin = _min; int currentMax = _max; @@ -60,8 +66,8 @@ public override IEnumerable GetData(MethodInfo testMethod) { isMin = false; - builder.Append('a', currentMin); - data.Add([builder.ToString()]); + builder.Append(Char, currentMin); + data.Add(new TheoryDataRow(builder.ToString())); if (!isMinReverse) { @@ -90,8 +96,8 @@ public override IEnumerable GetData(MethodInfo testMethod) { isMin = true; - builder.Append('a', currentMax); - data.Add([builder.ToString()]); + builder.Append(Char, currentMax); + data.Add(new TheoryDataRow(builder.ToString())); if (!isMaxReverse) { @@ -118,7 +124,7 @@ public override IEnumerable GetData(MethodInfo testMethod) } } - return [.. data]; + return ValueTask.FromResult>(data); } } }