Home

Awesome

Tabular Attributes

Designed to be used with LightBdd Tabular Parameters to allow for specifying input and output data for tests via attributes, in a truth table format.

Differences between Tabular Attributes and InlineData

Why have test inputs and outputs specified inline with attributes?

Examples

Given the following inputs:

public class PhoneSpecs
{
    public string? Manufacturer { get; set; }
    public int ReleaseYear { get; set; }
    public int WeightInGrams { get; set; }
    public bool HasHeadphoneJack { get; set; }
}

And following outputs:

public class PhoneResult
{
    public string? PhoneName { get; set; }
    public bool IsStillAvailable { get; set; }
}

Standard

[Scenario]
[HeadIn("Manufacturer", "ReleaseYear", "WeightInGrams", "HasHeadphoneJack")][HeadOut("PhoneName",  "IsStillAvailable")]
[Inputs("Samsung",      2001,          191,             false             )][Outputs("Galaxy S20", true              )]
[Inputs("Samsung",      2000,          189,             true              )][Outputs("Galaxy S10", true              )]
[Inputs("Apple",        2020,          150,             false             )][Outputs("Iphone 10",  false             )]
[Inputs("Apple",        1986,          190,             true              )][Outputs("Iphone 2",   false             )]
public void Test_Normal()
{
	Runner.RunScenario(
		given => The_specified_phone_specs(TableFrom.Inputs<PhoneSpecs>()),
		when => The_find_phone_endpoint_is_called(),
		then => I_should_receive_results_matching(VerifiableTableFrom.Outputs<PhoneResult>()));
}

With Spaces In Header Names

[Scenario]
[HeadIn("Manufacturer", "Release Year", "Weight In Grams", "Has Headphone Jack")][HeadOut("Phone Name", "Is Still Available")]
[Inputs("Samsung",      2001,           191,               false               )][Outputs("Galaxy S20", true                )]
[Inputs("Samsung",      2000,           189,               true                )][Outputs("Galaxy S10", true                )]
[Inputs("Apple",        2020,           150,               false               )][Outputs("Iphone 10",  false               )]
[Inputs("Apple",        1986,           190,               true                )][Outputs("Iphone 2",   false               )]
public void Test_With_Spaces_In_Header_Names()
{
	Runner.RunScenario(
		given => The_specified_phone_specs(TableFrom.Inputs<PhoneSpecs>()),
		when => The_find_phone_endpoint_is_called(),
		then => I_should_receive_results_matching(VerifiableTableFrom.Outputs<PhoneResult>()));
}

With Out Of Order Headers

[Scenario]
[HeadIn("ReleaseYear", "Manufacturer", "WeightInGrams", "HasHeadphoneJack")][HeadOut("PhoneName",  "IsStillAvailable")]
[Inputs(2001,          "Samsung",      191,             false             )][Outputs("Galaxy S20", true              )]
[Inputs(2000,          "Samsung",      189,             true              )][Outputs("Galaxy S10", true              )]
[Inputs(2020,          "Apple",        150,             false             )][Outputs("Iphone 10",  false             )]
[Inputs(1986,          "Apple",        190,             true              )][Outputs("Iphone 2",   false             )]
public void Test_Out_Of_Order_Headers()
{
	Runner.RunScenario(
		given => The_specified_phone_specs(TableFrom.Inputs<PhoneSpecs>()),
		when => The_find_phone_endpoint_is_called(),
		then => I_should_receive_results_matching(VerifiableTableFrom.Outputs<PhoneResult>()));
}