Untitled

mail@pastecode.io avatar
unknown
plain_text
6 days ago
581 B
3
Indexable
Never
using AutoFixture;
using AutoFixture.Xunit2;
using AutoFixture.Kernel;

public class CustomAutoDataAttribute : AutoDataAttribute
{
    public CustomAutoDataAttribute()
        : base(() => new Fixture().Customize(new CustomFixtureCustomization()))
    {
    }
}

public class CustomFixtureCustomization : ICustomization
{
    public void Customize(IFixture fixture)
    {
        fixture.Behaviors.OfType<ThrowingRecursionBehavior>()
            .ToList()
            .ForEach(b => fixture.Behaviors.Remove(b));
        fixture.Behaviors.Add(new OmitOnRecursionBehavior());
    }
}
Leave a Comment