Class ScenarioCaseAttribute
- Namespace
- TinyBDD
- Assembly
- TinyBDD.dll
Specifies a set of values for a data-driven scenario. Multiple instances of this attribute can be applied to a single test method to execute the scenario with different data sets.
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public sealed class ScenarioCaseAttribute : Attribute
- Inheritance
-
ScenarioCaseAttribute
- Inherited Members
Examples
[Scenario("Adding numbers")]
[ScenarioCase(1, 2, 3)]
[ScenarioCase(5, 5, 10)]
[ScenarioCase(-1, 1, 0)]
public async Task AdditionScenario(int a, int b, int expected)
{
await Given($"{a} and {b}", () => (a, b))
.When("added", x => x.a + x.b)
.Then($"equals {expected}", sum => sum == expected)
.AssertPassed();
}
Remarks
This attribute works similarly to xUnit's [InlineData] or NUnit's [TestCase],
but is specifically designed for TinyBDD scenarios. Each attribute instance defines
one row of test data.
When used with the TinyBDD framework adapters, the test will be executed once for each ScenarioCaseAttribute applied to the method.
Constructors
ScenarioCaseAttribute(params object?[])
Initializes a new instance of the ScenarioCaseAttribute class with the specified test values.
public ScenarioCaseAttribute(params object?[] values)
Parameters
valuesobject[]The values to pass to the test method.
Properties
DisplayName
Gets or sets an optional display name for this case.
public string? DisplayName { get; set; }
Property Value
Values
Gets the values for this scenario case.
public object?[] Values { get; }
Property Value
- object[]
Methods
ToString()
Returns a string representation of the scenario case values.
public override string ToString()