2022-06-30 01:46:41 +02:00
|
|
|
|
using AutoFixture;
|
2020-11-23 15:48:05 +01:00
|
|
|
|
using AutoFixture.Xunit2;
|
|
|
|
|
|
2022-08-29 20:53:16 +02:00
|
|
|
|
namespace Bit.Test.Common.AutoFixture.Attributes;
|
|
|
|
|
|
|
|
|
|
public class CustomAutoDataAttribute : AutoDataAttribute
|
2020-11-23 15:48:05 +01:00
|
|
|
|
{
|
2022-08-29 20:53:16 +02:00
|
|
|
|
public CustomAutoDataAttribute(params Type[] iCustomizationTypes) : this(iCustomizationTypes
|
|
|
|
|
.Select(t => (ICustomization)Activator.CreateInstance(t)).ToArray())
|
|
|
|
|
{ }
|
2020-11-23 15:48:05 +01:00
|
|
|
|
|
2022-08-29 20:53:16 +02:00
|
|
|
|
public CustomAutoDataAttribute(params ICustomization[] customizations) : base(() =>
|
|
|
|
|
{
|
|
|
|
|
var fixture = new Fixture();
|
|
|
|
|
foreach (var customization in customizations)
|
2020-11-23 15:48:05 +01:00
|
|
|
|
{
|
2022-08-29 20:53:16 +02:00
|
|
|
|
fixture.Customize(customization);
|
|
|
|
|
}
|
|
|
|
|
return fixture;
|
|
|
|
|
})
|
|
|
|
|
{ }
|
2020-11-23 15:48:05 +01:00
|
|
|
|
}
|