Add [AdditionalData] type to test projects
このコミットが含まれているのは:
1 親
21ae8a57bc
コミット
e3c79f4170
7ファイル変更
+168
-12
検索条件に一致するファイルはありません
@@ -20,6 +20,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\ComputeSharp.Tests\Attributes\AdditionalDataAttribute.cs" Link="Attributes\AdditionalDataAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp.Tests\Attributes\AdditionalResourceAttribute.cs" Link="Attributes\AdditionalResourceAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp.Tests\Attributes\AllDevicesAttribute.cs" Link="Attributes\AllDevicesAttribute.cs" />
|
||||
<Compile Include="..\ComputeSharp.Tests\Attributes\CombinatorialTestMethodAttribute.cs" Link="Attributes\CombinatorialTestMethodAttribute.cs" />
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.Tests.Attributes;
|
||||
|
||||
/// <summary>
|
||||
/// An attribute to use with <see cref="CombinatorialAttribute"/> adding additional arbitrary input data.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public sealed class AdditionalDataAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AdditionalDataAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="data">The additional input data.</param>
|
||||
public AdditionalDataAttribute(params object[] data)
|
||||
{
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the additional input data for the current attribute.
|
||||
/// </summary>
|
||||
public object[] Data { get; }
|
||||
}
|
||||
@@ -8,10 +8,17 @@ namespace ComputeSharp.Tests.Attributes;
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public sealed class AdditionalResourceAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="AdditionalResourceAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="type">The additional resource type.</param>
|
||||
public AdditionalResourceAttribute(Type type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the additional resource type for the current attribute.
|
||||
/// </summary>
|
||||
public Type Type { get; }
|
||||
}
|
||||
@@ -39,6 +39,7 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
|
||||
Type[] resources = methodInfo.GetCustomAttributes<ResourceAttribute>().Select(static value => value.Type).ToArray();
|
||||
Type[] additionalResources = methodInfo.GetCustomAttributes<AdditionalResourceAttribute>().Select(static value => value.Type).ToArray();
|
||||
object[][] data = methodInfo.GetCustomAttributes<DataAttribute>().Select(static value => value.Data).ToArray();
|
||||
object[][] additionalData = methodInfo.GetCustomAttributes<AdditionalDataAttribute>().Select(static value => value.Data).ToArray();
|
||||
|
||||
if (devices.Length > 0)
|
||||
{
|
||||
@@ -54,13 +55,31 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
|
||||
{
|
||||
if (data.Length == 0)
|
||||
{
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
Assert.Fail("Invalid usage of [AdditionalData]");
|
||||
}
|
||||
|
||||
yield return new object[] { device, type, additionalType };
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
yield return new object[] { device, type, additionalType }.Concat(items).ToArray();
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
foreach (object[] additionalItems in additionalData)
|
||||
{
|
||||
yield return new object[] { device, type, additionalType }.Concat(items).Concat(additionalItems).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
yield return new object[] { device, type, additionalType }.Concat(items).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,13 +88,31 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
|
||||
{
|
||||
if (data.Length == 0)
|
||||
{
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
Assert.Fail("Invalid usage of [AdditionalData]");
|
||||
}
|
||||
|
||||
yield return new object[] { device, type };
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
yield return new object[] { device, type }.Concat(items).ToArray();
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
foreach (object[] additionalItems in additionalData)
|
||||
{
|
||||
yield return new object[] { device, type }.Concat(items).Concat(additionalItems).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
yield return new object[] { device, type }.Concat(items).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,13 +127,31 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
|
||||
|
||||
if (data.Length == 0)
|
||||
{
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
Assert.Fail("Invalid usage of [AdditionalData]");
|
||||
}
|
||||
|
||||
yield return new object[] { device };
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
yield return new object[] { device }.Concat(items).ToArray();
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
foreach (object[] additionalItems in additionalData)
|
||||
{
|
||||
yield return new object[] { device }.Concat(items).Concat(additionalItems).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
yield return new object[] { device }.Concat(items).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,13 +167,31 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
|
||||
{
|
||||
if (data.Length == 0)
|
||||
{
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
Assert.Fail("Invalid usage of [AdditionalData]");
|
||||
}
|
||||
|
||||
yield return new object[] { type, additionalType };
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
yield return new object[] { type, additionalType }.Concat(items).ToArray();
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
foreach (object[] additionalItems in additionalData)
|
||||
{
|
||||
yield return new object[] { type, additionalType }.Concat(items).Concat(additionalItems).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
yield return new object[] { type, additionalType }.Concat(items).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -127,13 +200,31 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
|
||||
{
|
||||
if (data.Length == 0)
|
||||
{
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
Assert.Fail("Invalid usage of [AdditionalData]");
|
||||
}
|
||||
|
||||
yield return new object[] { type };
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
yield return new object[] { type }.Concat(items).ToArray();
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
foreach (object[] additionalItems in additionalData)
|
||||
{
|
||||
yield return new object[] { type }.Concat(items).Concat(additionalItems).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
yield return new object[] { type }.Concat(items).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,13 +239,31 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
|
||||
|
||||
if (data.Length == 0)
|
||||
{
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
Assert.Fail("Invalid usage of [AdditionalData]");
|
||||
}
|
||||
|
||||
yield return Array.Empty<object>();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
if (additionalData.Length > 0)
|
||||
{
|
||||
yield return items;
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
foreach (object[] additionalItems in additionalData)
|
||||
{
|
||||
yield return items.Concat(additionalItems).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (object[] items in data)
|
||||
{
|
||||
yield return items;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ namespace ComputeSharp.Tests.Attributes;
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public sealed class DataAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DataAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="data">The input data.</param>
|
||||
public DataAttribute(params object[] data)
|
||||
{
|
||||
Data = data;
|
||||
|
||||
@@ -9,6 +9,10 @@ namespace ComputeSharp.Tests.Attributes;
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public sealed class DeviceAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DeviceAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="device">The target device type to use..</param>
|
||||
public DeviceAttribute(Device device)
|
||||
{
|
||||
Device = device;
|
||||
|
||||
@@ -8,10 +8,17 @@ namespace ComputeSharp.Tests.Attributes;
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
|
||||
public sealed class ResourceAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ResourceAttribute"/> instance with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="type">The resource type.</param>
|
||||
public ResourceAttribute(Type type)
|
||||
{
|
||||
Type = type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the resource type for the current attribute.
|
||||
/// </summary>
|
||||
public Type Type { get; }
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする