What is really going on
NumericSequence [PropertyData] defines two iterations.
NumericSequence [PropertyData] with [AutoData] assumes there is enough data at each iteration.
However, the actual composition:
1st iteration: [PropertyData], [AutoData] 2nd iteration: [PropertyData], [n/a]
This is why in the 2nd iteration you end up running out of data.
Structure
CompositeDataAttribute refers to LSP in the sense that it is programmed against the base of all data theories, the DataAttribute class.
(That is, there is no assumption that all attributes consist of [AutoData] at the end.)
For this reason, it cannot just go from the 2nd iteration to the 1st iteration and capture some [AutoData] values, which will break the LSP.
What could you do
Make the actual composition look like:
1st iteration: [PropertyData], [AutoData] 2nd iteration: [PropertyData], [AutoData]
By defining two properties:
public static IEnumerable<object[]> FirstPropertyData { get { yield return new object[] { 1 }; } } public static IEnumerable<object[]> OtherPropertyData { get { yield return new object[] { 9 }; } }
And then the original test can be written as:
[Theory] [AutoPropertyData("FirstPropertyData")] [AutoPropertyData("OtherPropertyData")] public void Test(int n1, int n2, int n3) { }
The test is run twice, and n1 always provided [PropertyData] , and n2 and n3 always provided [AutoData] .