Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

InlineAutoData Data For Specific Parameter Argument

Suppose I have the following parameterized test,

[Theory]
[InlineAutoData(typeof(IFoo), null)
public void FooBar(IFoo foo, IBar bar)
{
    // Do stuff
}

The above will throw an exception about converting RuntimeType to IFoo.

My question, is how do I tell AutoFixture to generate a member for the first parameter, and use null for the second in this scenario (or is it possible)?

As far as I can tell InlineAutoData has the limitation that you have to specify data in-order and any unspecified data gets auto-generated, but that's not exactly ideal and I'm hoping I'm wrong?

like image 493
Greg B Avatar asked Mar 14 '26 22:03

Greg B


1 Answers

I'm new to this as well, but I think this will explain why: "Uses the InlineData values for the the first method arguments, and then uses AutoData for the rest (when the InlineData values run out)." per: github.com/AutoFixture/AutoFixture/wiki/Cheat-Sheet

(Added as an answer per @AlexAngas suggestion.)

like image 194
Eclipse Avatar answered Mar 17 '26 10:03

Eclipse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!