Skip to content

Add an attribute to mix traditional and combinatorial data #93

Open
@asimon-od

Description

Essentially, I'm looking to be able to hand write values for some test parameters while combinatorially populating others. This would allow more control over e.g. int values than the existing range options or the veto option proposed in #3.

An (albeit useless) toy example:

/// Assumption: a > b
[Theory]
[InlineData(10, 0, true)]
[InlineData(10, 0, false)]
[InlineData(5, 2, true)]
[InlineData(5, 2, false)]
public void Example(int a, int b, bool c)
{
  // body
}

In this example, the values for a and b are hand-picked, but should be tested for both values of c. I assume it may not be possible to build this functionality on top of the existing InlineData attribute, but supposing a new keyword-style equivalent that replaced any omitted parameters with their combinatorial definitions, it could look like this:

/// Assumption: a > b
[Theory, CombinatorialData]
[PartialInlineData(10, 0)]
[PartialInlineData(10, 0)]
[PartialInlineData(5, 2)]
[PartialInlineData(5, 2)]
public void Example(int a, int b, [CombinatorialValues(true, false)] bool c)
{
  // body
}

and could also support cases where we don't want the combinatorics a la #3

[PartialInlineData(6, 2, false)]
// No need to veto [PartialInlineData(6, 2, true)] if you don't want it

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions