Recently we have been trying Unit Testing in a new project, now that we want to pass a Object to our test method with [InlineData]
, so we can utilize the same test method multiple times with multiple different data inputs.
[ClassData]
and [MemberData]
are also available, but do not seem to offer a solution, as to my understanding.
Basically, is there a way to pass Objects with XUnit, like so:
[Theory]
[InlineData(new Object { Attribute = 1 })]
public void Test(Object obj)
{
// Assert
Xunit.Assert.NotNull(obj.Attribute);
}
Or is this not the correct convention or usage?
Passing int
's and string
's works fine using [InlineData]