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
3 changes: 2 additions & 1 deletion TUnit.Core/Attributes/TestData/NoDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

internal class NoDataSource : IDataSourceAttribute
{
private static readonly Task<object?[]?> _emptyRowTask = Task.FromResult<object?[]?>([]);
public static readonly NoDataSource Instance = new();

/// <inheritdoc />
public bool SkipIfEmpty { get; set; }

public async IAsyncEnumerable<Func<Task<object?[]?>>> GetDataRowsAsync(DataGeneratorMetadata dataGeneratorMetadata)
{
yield return () => Task.FromResult<object?[]?>([]);
yield return static () => _emptyRowTask;
await default(ValueTask);
}
}
4 changes: 3 additions & 1 deletion TUnit.Engine/Building/TestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,13 @@ private static Type[] TryInferClassGenericsFromDataSources(TestMetadata metadata
return resolvedTypes;
}

private static readonly IDataSourceAttribute[] _dataSourceArray = [NoDataSource.Instance];

private async Task<IDataSourceAttribute[]> GetDataSourcesAsync(IDataSourceAttribute[] dataSources)
{
if (dataSources.Length == 0)
{
return [NoDataSource.Instance];
return _dataSourceArray;
}

// Inject properties into data sources during discovery (IAsyncInitializer deferred to execution)
Expand Down
Loading