I tried to combine the member-data and auto data attribute this way:
using Xunit;
using Ploeh.AutoFixture.Xunit2;
class MemberAutoDataAttribute : CompositeDataAttribute
{
public MemberAutoDataAttribute(string memberName)
: base(
new MemberDataAttribute(memberName),
new AutoDataAttribute())
{
}
}
This is the test which implements it:
[Theory, MemberAutoData(nameof(CurrentWeatherResponses))]
public void ParseCurrentWeather_WeatherParsed(
string response,
Weather expectedWeather,
TemperatureUnit tempUnit)
{
// ...
}
And here is the CurrentWeatherResponses
member:
public static IEnumerable<object[]> CurrentWeatherResponses
{
get
{
yield return
new object[]
{
CurrentWeatherResponse.ToString(),
new Weather() {}
};
}
}
Why every second test execution all values are generated and not only the temperature unit?