I'm trying to create a simple Xunit test that will take a property (not a property.name rather the full property) as a datatype.
I've looked at the three types available so I can pass as the Inline/Member/Class Data and none of them really fit.
My properties are created like this
TokenStore nullTokenStore { get; set; } = new TokenStore();
TokenStore tokenStore { get; set; } = new TokenStore { RefreshToken = "12345", BearerToken = "fredfox" };
(so nothing out of the ordinary)
If I pass the property directly into InlineData (as is), I get an error that the property is not null and must be a const, typeof or array. If I make the property static and refer to the member names, I get a different error, but still not accepted.
My full test case looks like this
[Theory]
[InlineData(tokenStore.BearerToken, tokenStore.RefreshToken)]
public async Task Test_GetProductApiURL(TokenStore store)
{
var service = await _fixture.GetProductApiURLAsync();
Assert.NotNull(service);
Assert.NotNull(service.ReasonPhrase);
Assert.Equal((int)service.StatusCode, 200);
}
Is there a way to pass in a complete property?