Skip to content

Update TheoryData in v2 with new support from v3 #2854

Closed
@bradwilson

Description

@bradwilson

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 }));
}

Activity

added a commit that references this issue on Dec 26, 2023

#2854: Add constructors and AddRange for TheoryData<T>

298b1b1
bradwilson

bradwilson commented on Dec 26, 2023

@bradwilson
MemberAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Update TheoryData in v2 with new support from v3 · Issue #2854 · xunit/xunit