0

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?

Nikos Baxevanis
  • 10,868
  • 2
  • 46
  • 80
  • I don't understand the question. `MemberAutoData` and `CurrentWeatherResponses` both look fine. Each time you run the test, `response` will be `CurrentWeatherResponse.ToString()` and `expectedWeather` will be `new Weather() {}`. See also [this](http://stackoverflow.com/a/16843837/467754), [this](http://stackoverflow.com/a/22191745/467754), and [this](http://stackoverflow.com/q/22985001/467754). – Nikos Baxevanis Nov 13 '16 at 22:23
  • Exactly this is my problem they won't be the same. Every second time i run the test all values are automatic generated... I will debug again and may can you provide more information then –  Nov 14 '16 at 21:17

0 Answers0