Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
refactor: rename CombinedDataSource to CombinedDataSources and update…
… related documentation
  • Loading branch information
thomhurst committed Nov 1, 2025
commit 7f6f2a3e2e2a7a30a64d85b55ab7f3dbc0fcdcd3
18 changes: 9 additions & 9 deletions TUnit.Analyzers.Tests/CombinedDataSourceAnalyzerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ await Verifier

public class MyClass
{
[CombinedDataSource]
[CombinedDataSources]
[Test]
public void MyTest(
[Arguments(1, 2, 3)] int value,
Expand Down Expand Up @@ -61,7 +61,7 @@ await Verifier

public class MyClass
{
[CombinedDataSource]
[CombinedDataSources]
[Test]
public void MyTest(
[Arguments(1, 2, 3)] int value,
Expand All @@ -87,7 +87,7 @@ await Verifier

public class MyClass
{
[CombinedDataSource]
[CombinedDataSources]
[MatrixDataSource]
[Test]
public void {|#0:MyTest|}(
Expand All @@ -111,7 +111,7 @@ await Verifier
"""
using TUnit.Core;

[CombinedDataSource]
[CombinedDataSources]
public class MyClass
{
public MyClass(
Expand Down Expand Up @@ -169,7 +169,7 @@ await Verifier

public class MyClass
{
[CombinedDataSource]
[CombinedDataSources]
[Test]
public void MyTest(
[Arguments(1, 2, 3)] int value,
Expand All @@ -195,7 +195,7 @@ public class MyClass
{
public static IEnumerable<int> GetNumbers() => [1, 2, 3];

[CombinedDataSource]
[CombinedDataSources]
[Test]
public void MyTest(
[MethodDataSource(nameof(GetNumbers))] int number,
Expand Down Expand Up @@ -229,7 +229,7 @@ protected override IEnumerable<Func<int>> GenerateDataSources(DataGeneratorMetad

public class MyClass
{
[CombinedDataSource]
[CombinedDataSources]
[Test]
public void MyTest(
[ClassDataSource<TestData>] int number,
Expand All @@ -252,7 +252,7 @@ await Verifier

public class MyClass
{
[CombinedDataSource]
[CombinedDataSources]
[Test]
public void MyTest(
[Arguments(1, 2, 3)] int value,
Expand Down Expand Up @@ -300,7 +300,7 @@ await Verifier
"""
using TUnit.Core;

[CombinedDataSource]
[CombinedDataSources]
public class MyClass
{
public MyClass(
Expand Down
14 changes: 7 additions & 7 deletions TUnit.Analyzers/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -463,28 +463,28 @@
<value>Data source may produce no tests</value>
</data>
<data name="TUnit0070Description" xml:space="preserve">
<value>When parameters have data source attributes, the method or class must be marked with [CombinedDataSource] to combine the parameter data sources.</value>
<value>When parameters have data source attributes, the method or class must be marked with [CombinedDataSources] to combine the parameter data sources.</value>
</data>
<data name="TUnit0070MessageFormat" xml:space="preserve">
<value>[CombinedDataSource] is required when parameters have data source attributes.</value>
<value>[CombinedDataSources] is required when parameters have data source attributes.</value>
</data>
<data name="TUnit0070Title" xml:space="preserve">
<value>[CombinedDataSource] attribute required</value>
<value>[CombinedDataSources] attribute required</value>
</data>
<data name="TUnit0071Description" xml:space="preserve">
<value>When [CombinedDataSource] is used, all parameters (except CancellationToken) must have data source attributes to provide test data.</value>
<value>When [CombinedDataSources] is used, all parameters (except CancellationToken) must have data source attributes to provide test data.</value>
</data>
<data name="TUnit0071MessageFormat" xml:space="preserve">
<value>Parameter '{0}' is missing a data source attribute. All parameters must have data sources when using [CombinedDataSource].</value>
<value>Parameter '{0}' is missing a data source attribute. All parameters must have data sources when using [CombinedDataSources].</value>
</data>
<data name="TUnit0071Title" xml:space="preserve">
<value>Parameter missing data source attribute</value>
</data>
<data name="TUnit0072Description" xml:space="preserve">
<value>Using [CombinedDataSource] together with [MatrixDataSource] is not recommended as they serve different purposes and may cause confusion.</value>
<value>Using [CombinedDataSources] together with [MatrixDataSource] is not recommended as they serve different purposes and may cause confusion.</value>
</data>
<data name="TUnit0072MessageFormat" xml:space="preserve">
<value>[CombinedDataSource] should not be used with [MatrixDataSource]. Use one or the other.</value>
<value>[CombinedDataSources] should not be used with [MatrixDataSource]. Use one or the other.</value>
</data>
<data name="TUnit0072Title" xml:space="preserve">
<value>Conflicting data source attributes</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace TUnit.Core;
/// </summary>
/// <remarks>
/// <para>
/// The <see cref="CombinedDataSourceAttribute"/> allows you to apply different data source attributes
/// The <see cref="CombinedDataSourcesAttribute"/> allows you to apply different data source attributes
/// (such as <see cref="ArgumentsAttribute"/>, <see cref="MethodDataSourceAttribute"/>, <see cref="ClassDataSourceAttribute{T}"/>)
/// to individual parameters, creating test cases from all combinations via Cartesian product.
/// </para>
Expand All @@ -36,7 +36,7 @@ namespace TUnit.Core;
/// <para><strong>Basic Usage with Arguments:</strong></para>
/// <code>
/// [Test]
/// [CombinedDataSource]
/// [CombinedDataSources]
/// public void BasicTest(
/// [Arguments(1, 2, 3)] int x,
/// [Arguments("a", "b")] string y)
Expand All @@ -55,7 +55,7 @@ namespace TUnit.Core;
/// }
///
/// [Test]
/// [CombinedDataSource]
/// [CombinedDataSources]
/// public void MixedTest(
/// [Arguments(1, 2)] int x,
/// [MethodDataSource(nameof(GetStrings))] string y,
Expand All @@ -69,7 +69,7 @@ namespace TUnit.Core;
/// <para><strong>Multiple Data Sources on Same Parameter:</strong></para>
/// <code>
/// [Test]
/// [CombinedDataSource]
/// [CombinedDataSources]
/// public void MultipleSourcesTest(
/// [Arguments(1, 2)]
/// [Arguments(3, 4)] int x,
Expand All @@ -81,7 +81,7 @@ namespace TUnit.Core;
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public sealed class CombinedDataSourceAttribute : AsyncUntypedDataSourceGeneratorAttribute, IAccessesInstanceData
public sealed class CombinedDataSourcesAttribute : AsyncUntypedDataSourceGeneratorAttribute, IAccessesInstanceData
{
protected override async IAsyncEnumerable<Func<Task<object?[]?>>> GenerateDataSourcesAsync(DataGeneratorMetadata dataGeneratorMetadata)
{
Expand All @@ -93,7 +93,7 @@ public sealed class CombinedDataSourceAttribute : AsyncUntypedDataSourceGenerato
if (parameterInformation.Length != dataGeneratorMetadata.MembersToGenerate.Length
|| parameterInformation.Length is 0)
{
throw new Exception("[CombinedDataSource] only supports parameterised tests");
throw new Exception("[CombinedDataSources] only supports parameterised tests");
}

if (dataGeneratorMetadata.TestInformation == null)
Expand Down Expand Up @@ -144,7 +144,7 @@ public sealed class CombinedDataSourceAttribute : AsyncUntypedDataSourceGenerato

if (dataSourceAttributes.Length == 0)
{
throw new InvalidOperationException($"Parameter '{parameterMetadata.Name}' has no data source attributes. All parameters must have at least one IDataSourceAttribute when using [CombinedDataSource].");
throw new InvalidOperationException($"Parameter '{parameterMetadata.Name}' has no data source attributes. All parameters must have at least one IDataSourceAttribute when using [CombinedDataSources].");
}

var allValues = new List<object?>();
Expand Down
8 changes: 4 additions & 4 deletions TUnit.TestProject/CombinedDataSourceErrorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class CombinedDataSourceErrorTests
// They should fail during test discovery/initialization, not during execution

// [Test]
// [CombinedDataSource]
// [CombinedDataSources]
// public async Task ParameterWithoutDataSource_ShouldFail(
// [Arguments(1, 2)] int x,
// int y) // Missing data source attribute - should fail
Expand All @@ -21,7 +21,7 @@ public class CombinedDataSourceErrorTests
// }

// [Test]
// [CombinedDataSource]
// [CombinedDataSources]
// public async Task NoParametersWithDataSources_ShouldFail()
// {
// // Should fail because there are no parameters with data sources
Expand All @@ -44,7 +44,7 @@ public static IEnumerable<string> GetEmptyStrings()
// Note: SkipIfEmpty is not a property of MethodDataSource
// This test is commented out for now
// [Test]
// [CombinedDataSource]
// [CombinedDataSources]
// public async Task EmptyDataSource_ShouldHandleGracefully(
// [Arguments(1)] int x,
// [MethodDataSource(nameof(GetEmptyStrings))] string y)
Expand All @@ -54,7 +54,7 @@ public static IEnumerable<string> GetEmptyStrings()
// }

[Test]
[CombinedDataSource]
[CombinedDataSources]
public async Task ParameterWithNullValues(
[Arguments(null, 1, 2)] int? x,
[Arguments(null, "a")] string? y)
Expand Down
Loading