Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TheoryData in v2 with new support from v3 #2854

Closed
bradwilson opened this issue Dec 26, 2023 · 1 comment
Closed

Update TheoryData in v2 with new support from v3 #2854

bradwilson opened this issue Dec 26, 2023 · 1 comment

Comments

@bradwilson
Copy link
Member

The v3 TheoryData class includes new constructors and methods that are missing in v2, per #2836. Example:

public class TheoryData<T> : TheoryData
{
/// <summary>
/// Adds data to the theory data set.
/// </summary>
/// <param name="p">The data value.</param>
public void Add(T p)
{
AddRow(p);
}
}

public class TheoryData<T> : TheoryData
{
/// <summary>
/// Initializes a new isntance of the <see cref="TheoryData{T}"/> class.
/// </summary>
/// <param name="values">The initial set of values</param>
public TheoryData(IEnumerable<T> values)
{
Guard.ArgumentNotNull(values);
AddRange(values.ToArray());
}
/// <summary>
/// Initializes a new isntance of the <see cref="TheoryData{T}"/> class.
/// </summary>
/// <param name="values">The initial set of values</param>
public TheoryData(params T[] values) =>
AddRange(values);
/// <summary>
/// Adds data to the theory data set.
/// </summary>
/// <param name="p">The data value.</param>
public void Add(T p) =>
AddRow(p);
/// <summary>
/// Adds multiple data items to the theory data set.
/// </summary>
/// <param name="values">The data values.</param>
public void AddRange(params T[] values) =>
AddRows(values.Select(x => new object?[] { x }));
}

@bradwilson
Copy link
Member Author

Available in v2 2.6.5-pre.2 https://xunit.net/docs/using-ci-builds

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant